Add a Second Query

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 Building a Report that Renumbers Pages by Repeating Frame 19-7

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

Design view. It should look something like this: Figure 19–5 Revised report layout in Paper Design view Note that the data is still grouped by the Sales Representative with customer data listed below each Sales Representative. But now, the individual products sold to the customers are listed below each customer. The report now has multiple pages.

19.5 Set Properties and Format Fields

To set properties and format the fields of your report:

1. In the Object Navigator, click the Paper Layout node and click the Expand All

button in the toolbar.

2. Double-click the repeating frame icon next to the R_G_ENAME node to display

the Property Inspector, and set the following properties: ■ Under Repeating Frame, set the Maximum Records per Page property to 1. 3. In the Object Navigator, double-click the repeating frame icon next to the R_G_ CUSTID1 node to display the Property Inspector, and set the following properties: ■ Under Repeating Frame, set the Vert. Space Between Frames property to 0.25 to specify 0.25 inches 0.5 centimeters of vertical space between instances of the repeating frame; that is, between each customer record. ■ Under General Layout, set the Page Protect property to Yes to specify that the first instance of the repeating frame that is, the first customer record must all fit on the same logical page. amount Amount 9 Fields Labels Width