Prerequisites for This Example Create a Data Model and a Group Above Layout

19-4 Oracle Reports Users Guide to Building Reports

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

arrow to move this field to the Group Fields list. 10. Move REPID to the Group Fields list, too, then click Next. Figure 19–2 Selecting group fields in the Report Wizard

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

the Displayed Fields list, then click CUSTID and click the left arrow to move it back to the Available Fields list, then click Next.

12. On the Totals page, click Next.

13. On the Labels page, change the labels and field widths as follows, then click Next:

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 19.1, Prerequisites for This Example describes the sample schema requirements for this example. Fields Labels Width ENAME Rep Name 10 REPID Rep ID 6 NAME Customer Name 20 ADDRESS Address 20 LOCATION Location 20 AREA_PHONE Area Phone 12 CREDITLIMIT Credit Limit 8 Building a Report that Renumbers Pages by Repeating Frame 19-5 Figure 19–3 Specifying labels and widths in the Report Wizard

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

Design view.

15. Save the report as pagenum_your_initials.rdf.

19.3 Add a Second Query

In the Paper Design view, the data is grouped by the Sales Representative with customer data listed below each Sales Representative. Figure 19–4 Report layout in the Paper Design view All the data will display on one page and the individual sales transactions for each customer is not yet available. You will need an additional query in the Data Model to accomplish this. 19-6 Oracle Reports Users Guide to Building Reports To add a new query to the report: 1. Click the Data Model button in the toolbar. 2. In the Data Model view, click the SQL Query tool in the tool palette then click in an open area of the Data Model view, somewhere to the right of query Q_1, to display the SQL Query Statement dialog box.

3. In the SQL Query Statement field, enter the following SELECT statement:

SELECT CUSTID,PRODNAME,AMOUNT FROM SALES ORDER BY CUSTID

4. Click OK to display the new query in the Data Model view.

5. In the Data Model view, click the Data Link tool in the tool palette.

6. Using the cross hairs of the cursor, click CUSTID in the G_NAME group and drag

the cursor to custid1 in the G_custid1 group, then release the mouse button to link the CUSTID and custid1 fields between the two groups. 7. Position the Report Editor window to display it alongside the Object Navigator so that you can view both windows simultaneously.

8. In the Object Navigator, under the Data Model node, expand the Groups node.

Then, under the Paper Layout node, expand the Main Section node. Compare these two structures and note that even though additional data is made available in the Data Model by adding query Q_2, the Paper Layout will not use this additional data unless modified to do so. We will do this next.

19.4 Redefault the Layout

To redefault the layout to use the additional query data: 1. In the Object Navigator, click the report name.

2. Choose Tools Report Wizard to re-enter the wizard.

3. In the Report Wizard, on the Groups page, click G_custid1 in the Available

Groups list and click Down to specify the Print Direction and move this group to the Displayed Groups list.

4. On the Fields page, click prodname and amount in the Available Fields list and

click the right arrow to move these fields to the Displayed Fields list. 5. On the Labels page, change the labels and field widths as follows: Note: You can enter this query in any of the following ways: ■ Copy and paste the code from the provided text file called pagenum_code.txt into the SQL Query Statement field. ■ Click Query Builder to build the query without entering any code manually. ■ Type the code in the SQL Query Statement field. Fields Labels Width prodname Product Name 30