Prerequisites for This example Create a Data Model and a Layout

Building an Intermixed Fields Report 20-3

8. Click Next.

9. On the Groups page, click DNAME in the Available Fields list and click the right

arrow to move this field to the Group Fields list. Figure 20–2 Group page of Report Wizard

10. Click Next.

11. On the Fields page, click the double right arrows to move all of the fields to

the Displayed Fields list, then click Next. 12. On the Totals page, click Next. 13. On the Labels page, change the labels as follows, then click Next: Note: You can enter this query in any of the following ways: ■ Copy and paste the code from the provided text file called intermix_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 20.1, Prerequisites for This example describes the sample schema requirements for this example. Fields Labels DNAME Dept. ENAME Name SAL Salary 20-4 Oracle Reports Users Guide to Building Reports

14. On the Template page, click Finish to display your report output in the Paper

Design view. It should look something like this: Figure 20–3 Paper Design view for intermixing fields report

15. Save the report as intermix_your_initials.rdf.

20.3 Add a Formula Column

To have the department names appear in the center of this group report, it is simplest to have a column in the detail group for the department names. To achieve this result, you must create a formula column in the detail group that will display the department names. To add a formula column:

1. Click the Data Model tool in the toolbar to display the Data Model view.

2. In the Data Model view, resize the G_ENAME group to be large enough to

contain a third column.

3. Click the Formula Column tool in the tool palette.

4. Click in the G_ENAME group to create a formula column.

5. Double-click the new formula column object CF_1 to display the Property

Inspector, and set the following properties: ■ Under General Information, set the Name property to DEPARTMENT. ■ Under Column, set the Datatype property to Character, and set the Width property to 14. ■ Under PlaceholderFormula, double-click the PLSQL Formula property field to display the PLSQL Editor.

6. In the PLSQL Editor, at the flashing cursor after the word begin, type the

following: return:dname;

7. Click Compile.

8. Click Close.

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.