Create Links Between REF CURSOR Queries

Building a Paper Report with REF CURSORs 41-11

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

3. On the Style page, type My Employees in the Title field, select Group Above.

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

click Down to specify the Print Direction and move them to the Group Fields list: ■ G_conlabel ■ G_DEPARTMENT_ID ■ G_EMPLOYEE_ID 5. On the Fields page, click the following fields and click the right arrow to move them to the Displayed Fields list: ■ DEPARTMENT_NAME ■ EMPLOYEE_ID ■ START_DATE ■ END_DATE ■ JOB_ID ■ CS_port_count 6. On the Labels page, change the labels and field widths as follows:

7. On the Template page, choose Predefined template and click Beige, then click

Finish to display your report output in the Paper Design view. It should look something like this: Table 41–3 Field description of Labels page Fields Labels Width DEPARTMENT_NAME Department 30 EMPLOYEE_ID Employee ID 8 START_DATE Start Date 9 END_DATE End Date 9 JOB_ID Job ID 10 CS_port_count Total: 12 41-12 Oracle Reports Users Guide to Building Reports Figure 41–8 Paper Design view for the REF CURSOR report 8. Save the report as ref_66_your_initials.rdf.

41.8 Move the SELECT Statements Into Packages

In your current report configuration, the SELECT statements used by the REF CURSOR queries reside within the report itself. In many cases, it is advantageous to have SELECT statements reside in the packages that define the REF CURSOR types. Then, you can simply reference the packages, rather than typing the same SELECT statement directly into every report that uses it. If you need to change the SELECT statement for example, to modify or add clauses, you simply update it once in the package, rather than in every report that uses it. The steps in this section will help you to move the SELECT statements to the packages that define the REF CURSOR types. To move SELECT statements into a package:

1. In the Object Navigator, click the Program Units node for your report.

2. Click the Create button in the toolbar to display the New Program Unit dialog box.

3. In the New Program Unit dialog box, type cont_cv in the Name field.

4. Select Package Body, and click OK to display the PLSQL Editor for the new

program unit.

5. In the PLSQL Editor, use the template to enter the following PLSQL code:

PACKAGE BODY cont_cv IS function query_container p_department_id number return container_refcur is tempcv_container cont_cv.container_ refcur; begin open tempcv_container for select employee_id, Note: You can open the provided file ref_emp66.rdf and display the Paper Design view to compare your results.