Create a report block to display the table of contents Run your simple table of contents report to paper

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. 35-12 Oracle Reports Users Guide to Building Reports Figure 35–10 Sample index for the paper report

35.3.1 Create a table in the database to hold the information for the index

The steps in this section will show you how to create a table in the database that will hold the page numbers for the items you want to list in the index. If you are not sure if you can create a table in the database, contact the database administrator. To create a table in the database: 1. Follow the steps in Section 35.2.1, Create a table in the database to hold the TOC data to create a new table in the database, using the following code: create table index_example term varchar2100, page number; 2. Press Enter. You should see a notification that the table has been created. 3. Exit SQLPlus.

35.3.2 Create a format trigger

The steps in this section will show you how to create a format trigger based on the customers last name. You will use the SRW.GET_PAGE_NUM built-in function to find the page number for the current customer, and insert that page number into the table you created in the previous section. To create a format trigger: 1. In Reports Builder, open the report, toc_your_initials.rdf. Building a Paper Report with a Simple Table of Contents and Index 35-13 2. Click the Paper Layout button in the toolbar to display the Paper Layout view.

3. In the Paper Layout view, right-click the field F_CUST_LAST_NAME, then

choose Property Inspector from the pop-up menu. 4. Under Advanced Layout, double-click the Format Trigger property field to display the PLSQL Editor. 5. In the PLSQL Editor, use the template to enter the following code: function F_CUST_LAST_NAMEFormatTrigger return boolean is PageNum number; begin -- get pagenumber srw.get_page_numpageNum; -- insert into table insert into index_example values :Cust_last_name||, ||:Cust_first_name, PageNum; return TRUE; end;

6. Click Compile.

7. If there are compilation errors, match your code to the code we have provided either in the example RDF file or in this chapter, then compile it again.

8. Once there are no compilation errors, click Close.

9. Save your report as toc_index_your_initials.rdf.

35.3.3 Add a query to the data model

The steps in this section will show you how to add a query to your data model that will retrieve the individual customer names and the page numbers for your index. To add the query:

1. 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.

2. In the SQL Query Statement field, enter the following SELECT statement:

SELECT SUBSTRTERM,1,1 INITIAL_LETTER, TERM, PAGE FROM INDEX_EXAMPLE ORDER BY TERM Note: You can enter this code by copying and pasting it from the provided text file called toc_index_code.txt. Note: You can enter this query in any of the following ways: ■ Copy and paste the code from the provided text file called toc_index_code.txt into the Data Source definition field. ■ Click Query Builder to build the query without entering any code manually. ■ Type the code in the Data Source definition field.