Prerequisites for This Example Create the Data Model with Two Linked Queries

Building a Report that Suppresses Labels 21-3

5. Click OK.

6. When the query displays in the Data Model view, right-click the query name Q_

1 , then choose Property Inspector from the pop-up menu to set the following property: ■ Under General Information, set the Name property to Q_DEPT. 7. Follow the steps above to create another query named Q_EMP, with the following SELECT statement: SELECT DEPTNO, ENAME, JOB FROM EMP ORDER BY ENAME 8. In the Data Model view, click the Data Link tool in the tool palette.

9. Drag a link between DEPTNO in Q_DEPT and DEPTNO1 in Q_EMP. Your data

model should now look like this: Figure 21–2 Data Model view of the Suppress Labels report 10. Save your report as suppresslabels_your_initials.rdf. Note: You can enter this query in any of the following ways: ■ Copy and paste the code from the provided text file called suppresslabels_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. Also note that if you have not installed the Pictures table into the sample schema, you will not be able to create this query. 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 21.1, Prerequisites for This Example describes the sample schema requirements for this example. 21-4 Oracle Reports Users Guide to Building Reports

21.3 Create a Formula Column and a Summary Column

The steps in this section will show you how to add a formula column to the Q_EMP or detail query you built in the previous section that will return a value every time a detail record is returned. You will then add a summary column to the Q_DEPT or master query that will count the number of times this formula column returns a value. Before you create either of these columns, you may want to expand the size of your groups for better visibility. To do so, select the yellow group box. Click the bottom frame, then drag it down about 0.25 inches 0.5 centimeters. If you do this for both groups, you will have enough room to add your new columns.

21.3.1 Create a formula column in the detail query

This section will show you how to create a formula column that will return a single value. To create a formula column: 1. In the Data Model view, click the Formula Column tool in the tool palette.

2. Click in the Q_EMP query, under the JOB column to create a formula column.

3. 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 DETAIL_VAL. ■ Under PlaceholderFormula, click the PLSQL Formula property field to display the PLSQL Editor. 4. In the PLSQL Editor, use the template to enter the following PLSQL code: function DETAIL_VALFormula return Number is begin return1; end;

5. Click Compile.

6. When the code is compiled, click Close.

21.3.2 Create a summary column in the master query

The steps in this section will show you how to create and customize a summary column in the master query that will depend on the information returned by the formula column. To create a summary column: 1. In the Data Model view, click the Summary Column tool in the tool palette.

2. Click in the Q_DEPT query, under the LOC column to create a summary column.

3. Double-click the new summary column object CS_1 to display the Property

Inspector, and set the following properties: ■ Under General Information, set the Name property to COUNT_DETAIL. Tip: If you receive errors when compiling, compare your code against the code provided. You can also simply copy and paste the code from suppresslabels_code.txt. Building a Report that Suppresses Labels 21-5 ■ Under Summary, set the Function property to Count, set the Source property to DETAIL_VAL, and set the Reset At property to G_DEPTNO. Your data model now contains both the formula and summary columns, and should look like this: Figure 21–3 Data Model view with formula and summary columns 4. Save your report as suppresslabels_your_initials.rdf.

21.4 Create the report layout

In this section, you will create a default layout for your report. You will then add all the necessary layout objects for your checks.

21.4.1 Create the initial layout of your report

To create the initial layout:

1. In the Data Model view, right-click on the canvas, then choose Report Wizard.

2. In the Report Wizard, on the Report Type page, select Create Paper Layout only.

3. On the Style page, select Group Above.

4. On the Groups page, click the following groups in the Available Groups list and

click Down to specify the Print Direction and move them to the Displayed Groups list: ■ G_DEPTNO ■ G_DEPTNO1 5. On the Fields page: ■ Click the double right arrows to move all of the fields to the Displayed Fields list. ■ In the Displayed Fields list, click DEPTNO1 then click the left arrow to move this field back to the Available Fields list. ■ Do the same for the COUNT_DETAIL and DETAIL_VAL fields. 6. On the Labels page, make any desired changes to the labels. 7. On the Template page, select Predefined Template and click Blue, then click Finish to display your report output in the Paper Design view. It should look something like this: