36.3 Create an After Parameter Form Trigger and a Format Trigger

The steps in this section will show you how to create two triggers. The first trigger will use the SRW.SET_FORMAT_ORDER built-in procedure to format the Main section of the report first, then the Header and Trailer sections. The second trigger will fetch the page number for each category, sub-category, and record, and place that information into the table you created in Section 36.2, "Create a table in the database to hold the TOC data".

36.3.1 Create an After Parameter Form trigger

An After Parameter Form trigger is a function that executes after the Parameter Form is executed. In this section, you will set the trigger to change the order of the report execution, so that the Main section formats first.

To create an After Parameter Form trigger:

In Reports Builder, open the provided file multilevel_source.rdf.

In the Object Navigator, under your report name (MULTILEVEL_SOURCE), expand the Report Triggers node.

Right-click AFTER PARAMETER FORM, then choose PL/SQL Editor from the pop-up menu.

You can also copy and paste the code from the provided file, multilevel_code.txt.

Click Compile.

Once the code has compiled, click Close.

Save your report as multilevel_your_initials.rdf.

36.3.2 Create a format trigger

In this section, you will create a format trigger based on the field F_PROD_SUBCATEGORY. This field displays the sub-category, which is the product name. This sub-category falls under the main category, which is the product department. This format trigger will fetch the page number for each product name, so that the table of contents will enable the user to navigate to various parts of the report based on the department name, then the product name.