Prerequisites for This Example Create a Basic Tabular Report

Building a Report with Conditional Highlighting 22-3

7. On the Data page, enter the following SELECT statement in the Data Source

definition field: SELECT ALL EMPLOYEES.FIRST_NAME, EMPLOYEES.LAST_NAME, EMPLOYEES.EMPLOYEE_ID, EMPLOYEES.SALARY FROM HR.EMPLOYEES

8. Click Next.

9. On the Fields page, click the right arrow to move the following fields to the

Displayed Fields list, then click Next. Make sure you move them in the following order: ■ EMPLOYEE_ID ■ FIRST_NAME ■ LAST_NAME ■ SALARY 10. On the Totals page, click Next. 11. On the Labels page, click Next. 12. On the Template page, select Predefined Template and click Beige, then click Finish to preview your report output in the Paper Design view. It should look something like this: Note: You can enter this query in any of the following ways: ■ Copy and paste the code from the provided text file called condhigh_code.txt into the Data Source definition field. ■ Click Query Builder to build the query without entering any code manually. ■ Type the code in the Data Source definition field. Note: If you are not already connected to a database, you will be prompted to connect to the database when you click Query Builder or Next. Ensure that you connect to a database that has the appropriate schema for this example. Section 22.1, Prerequisites for This Example describes the sample schema requirements for this example. 22-4 Oracle Reports Users Guide to Building Reports Figure 22–2 Paper Design view for the initial tabular report Now, let us format the data to make it more meaningful. To format the report:

1. In the Paper Design view, select the Salary column by clicking once on the column

of data. 2. Click the Currency button in the toolbar. A currency symbol immediately appears next to all of the values. 3. Click the Commas button. 4. Click the Add Decimal button twice. Two decimal places are added to the right of the decimal point. The Salary column of your report should now look like this: Building a Report with Conditional Highlighting 22-5 Figure 22–3 Formatted salary column 5. Change the alignment of your columns by doing the following:

a. Click the Salary column heading, then click the Align Center button in the

toolbar.

b. Click the Salary column once, then click the Align Right button in the toolbar.

c. While the Salary column is selected, Shift-click to select the column heading

too, then click and drag one of the right black squares to size the column and column heading.

d. Click the Employee Id column heading, Shift-click to select the Employee Id

column too, then click the Align Center button in the toolbar. 6. The Paper Design view of your report should now look like this: Figure 22–4 Paper Design view of the tabular report 7. Save your report as condhigh_your_initials.rdf. 22-6 Oracle Reports Users Guide to Building Reports

22.3 Add Conditional Formatting to the Report

The steps in this section will show you how to add conditional formatting so that salaries greater than or equal to 10,000 will be highlighted in bold, red text, and salaries between 4,999 and 10,000 will be highlighted in bold text. Since the data retrieved cannot be both greater than or equal to 10,000 and between 4,999 and 10,000, you will need to create two separate format exceptions. In this section, you will see how to create each distinct format exception. To add conditional formatting:

1. In the Paper Design view, right-click the Salary column of data not the Salary

column heading, then choose Conditional Formatting. 2. In the Conditional Formatting dialog box, click New to create a new Format Exception.

3. In the Format Exception dialog box, make sure SALARY is selected.

4. Next to SALARY, choose Greater Than or Equal from the list.

5. In the next box, type 10000.

6. Under Format, click the icon next to Text Color to display the color palette.

7. Click Red.

8. Click Font, then choose Bold.

9. Click OK to accept the new font style.

You should now see the following options selected in the Format Exception dialog box: Figure 22–5 Format Exception dialog box

10. Click OK.

Note: You can choose as many options as you want in the Format Exception dialog box, such as text color, style, and font.