In this chapter, you will learn about reports that include a simple table of contents and index.
Generating a table of contents or index is not supported for matrix reports.
When you have large paper report, it is sometimes easier for your users to navigate through the report if you include a table of contents. Using Reports Builder, you can generate a table of contents that displays at the beginning of your paper report.
Normally, Reports Builder formats the report starting with the Header section, then the Main section, followed by the Trailer section. With the functionality demonstrated in this example report, Reports Builder can format any section first to create information that is only known at the time of formatting, such as page numbers, then use that information in the formatting of a previous section.
In this example, you will use the built-in procedure called SRW.SET_FORMAT_ORDER to generate the Main section of the report first, then the Header and Trailer sections. Doing so enables you to generate the page numbers for the report in the Main section, then display the page numbers in the table of contents in the Header section.
Although you can use SRW.SET_FORMAT_ORDER to change the order in which the report is formatted, the report will still display the Header section first, then the Main section, and finally the Trailer section. You can use SRW.SET_FORMAT_ORDER to simply change the formatting order, but not the display order of the report sections.
You will use the After Parameter Form trigger and a format trigger to place the page numbers temporarily in a table you create in the database. You will then create a simple tabular report that displays at the beginning of your report, that lists the category and its page number. Finally, you will create an index that simply lists the record and the page number in the Trailer section of the report.
For information on creating a multilevel table of contents, refer to Chapter 36, "Building a Paper Report with a Multilevel Table of Contents".
In this example, you will generate a list of all the e-mail addresses for your customer database, which contains thousands of records. First, you want to categorize the customers (in this case, by country), then generate a table of contents so you can easily find the e-mail address for the desired customer. Then, you will learn how to create an index for your report.
As you build this example report, you will:
Create a table in the database to hold the TOC data using SQL*Plus.
Create a group above report using the Report Wizard.
Create an After Parameter Form trigger and a format trigger using the PL/SQL Editor to change the order in which the report sections are executed and fetch the page number for each record.
Create a second query in the data model with a formula column that calculates the page range for the data under each country name.
Create a report block to display the table of contents using the Report Block Wizard to create a tabular report block in the Header section to display the country name and page number.
Create a format trigger to generate a page number for every customer record.
Add a query to the data model using the Data Model view to create another query that retrieves the necessary information for the index.
To see a sample table of contents and index report, open the examples folder named
tocindex, then open the Oracle Reports example named
toc_index.rdf. For details on how to open it, see "Accessing the Example Reports" in the Preface.