Add a Formula Column

Building an Intermixed Fields Report 20-5 9. Click the title bar of the Report Editor to make it the active window again.

20.4 Add a Field

Now that you have added the formula column to the data model, you need to add a corresponding field to display it. You can easily do this by invoking the re-entrant Report Wizard. To add a field:

1. Choose Tools Report Wizard.

2. On the Report Type page, select Create Paper Layout Only.

3. On the Fields page:

■ Click DEPARTMENT in the Available Fields list and click the right arrow to move it to the Displayed Fields list. ■ Click and drag DEPARTMENT in the Displayed Fields list until it is located between ENAME and SAL.

4. Click Finish to preview your report output in the Paper Design view. It should

look something like this: Figure 20–4 Paper Design view of the intermixing fields report

20.5 Remove a Redundant Field

After you have added a field for the formula column, you will notice that the department values appear in two places. To eliminate this redundancy, you need to remove the master field and its heading. To remove a field and its label:

1. In the Paper Design view, shift-click on the first instance of the label Dept. and the

value next to it.

2. Choose Edit Delete.

20-6 Oracle Reports Users Guide to Building Reports Figure 20–5 Output displayed in Paper Design view

20.6 Suppress Redundant Values

Notice in your output that the department values are properly positioned, but they repeat for every record in the department. What you really want is for the department values to appear once for each department. To accomplish this task, you will first create a global variable to be used in comparing the current department value to the previous one. You will then write a Format Trigger to determine which values to suppress based upon the comparison within each departments records. To create a global variable:

1. In the Object Navigator, click the Program Units node.

2. Click the Create button in the toolbar. The New Program Unit dialog box displays.

3. Type global in the Name field and select Package Spec.

Figure 20–6 New Program Unit dialog box

4. Click OK.

5. In the PLSQL Editor, type the following PLSQL: PACKAGE global IS prev_val varchar214;