Create a second query in the data model

Building a Paper Report with a Simple Table of Contents and Index 35-9 function TOC_pagesFormula return Char is begin if :fromPage = :toPage then return :fromPage; else return :fromPage ||-|| :toPage; end if; end;

9. Click Compile.

10. Once the code is compiled, click Close.

11. Save the report.

35.2.5 Create a report block to display the table of contents

The steps in this section will show you how to create a tabular report block in the Header section of your report. This report block will display the headings in the table of contents in this example, the country name, and the page range where the information can be found in the report. To create a tabular report block in the Header section:

1. In the Paper Layout view, click the Header Section button in the toolbar.

2. Click the Report Block tool in the tool palette, then draw an area about about 5

inches 12.5 centimeters wide and 1.5 inches 4 centimeters high in the Paper Layout view. When you release the mouse button, the Report Block Wizard displays.

3. On the Style page, select Tabular, then click Next.

4. On the Groups page, click G_TOPIC and click Down to move it to the Displayed

Groups list, then click Next. 5. On the Fields page, click each of the following fields in the Available Fields list, then click the right arrow to move them to the Displayed Fields list, then click Next : ■ TOPIC ■ TOC_pages 6. On the Labels page, click Next. 7. On the Template page, click Finish. Your report block displays in the Paper Layout view: Figure 35–7 Paper Layout view of the Header Section

8. Save your report.

Note: You can also copy and paste this code from the provided file, called toc_index_code.txt. 35-10 Oracle Reports Users Guide to Building Reports

35.2.6 Run your simple table of contents report to paper

To run your report to paper: ■ Click the Run Paper Layout button in the toolbar. The table of contents displays on the first page of the report, and looks something like the following: Figure 35–8 Table of contents page of the report You can navigate to various pages in your report to view the data for each country. For example, when you navigate to page 1, you will see the e-mail addresses for the customers in Argentina: Note: To generate the table of contents TOC, you must click the Run Paper Layout button. If you click the Paper Design view button, the change of format order will not take effect, thus the TOC will not be generated. Building a Paper Report with a Simple Table of Contents and Index 35-11 Figure 35–9 Results for customers in Argentina For information on creating a multilevel table of contents, see Chapter 36, Building a Paper Report with a Multilevel Table of Contents .

35.3 Create an Index

In this section, you will create an index that displays at the end of your report. This index will simply display the customers name and the page number on which the name appears. This indexing technique is useful when users want to find a specific customers name, but are not sure what category for example, country to reference. Note: At this point, you can compare your report against the example file we have provided, toc.rdf. First, compile the PLSQL by choosing Program Compile All, then run the report to paper.