Create a data link between two queries

45-12 Oracle Reports Users Guide to Building Reports

3. In the Property Inspector, under Advanced Layout, double-click the Format

Trigger property field to display the PLSQL Editor. 4. In the PLSQL Editor, use the template to enter the following PLSQL code: function F_PRODUCT_IDformatTrigger return Boolean is begin LineColors; return TRUE; end; 5. Add a format trigger for the following fields, using the same code as in the previous step. Be sure not to delete the first line of the code, where the format trigger name is defined: ■ F_PRODUCT_NAME ■ F_QUANTITY_ON_HAND ■ F_WAREHOUSE_ID1 6. Save your report. 7. Click the Run Paper Layout button in the toolbar to run your report to paper. Your report should look something like this: Figure 45–6 XML PDS Report with Alternating Row Colors You have now applied alternating row colors to your report.

45.2.6 Filter your XML data using a group filter

If you have a lot of data in your XML file, you might want to consider sorting and filtering it. You can do so by creating a group filter and a hierarchy. The steps in this section will show you how to create a filter that will only show the inventory items for a user-defined quantity amount. The filter will be based on a parameter that the user Note: Make sure you do not touch the boldface text. Simply type in the code below this text to create the format trigger. You can copy and paste this code from the procedure provided in the xmlpds_code.txt file. Just copy the text under Format Trigger Code. Building a Report with an XML Pluggable Data Source 45-13 can enter at runtime. You will then create a hierarchy in your data model to group the data in your report. To create a user parameter and a group filter: 1. In the Object Navigator, under the User Parameters node, create a new user parameter called P_MAXQTY, with a Datatype of Number, Width of 20, and Initial Value of 50 see Section 4.11.2, Creating a user parameter . 2. In the Data Model view, double-click the G_WAREHOUSE_ID1 group in the XML query to display its Property Inspector.

3. In the Property Inspector, under Group:

■ set the Filter Type property to PLSQL. ■ click the PLSQL filter property field to display the PLSQL Editor. 4. In the PLSQL Editor, use the template to enter the following PLSQL code: function G_WAREHOUSE_ID1GroupFilter return boolean is begin if :quantity_on_hand :P_maxqty then return TRUE; else return false; end if; end;

5. Click Compile, and fix any errors.

6. When the code compiles successfully, click Close.

7. Save your report. 8. Click the Run Paper Layout button in the toolbar to run your report to paper. Notice how a Parameter Form now displays where you can adjust the quantity of items displayed in your report. You can also run the provided report inventoryreport.rdf to view the results in Reports Builder. 9. Save your report. To create a hierarchy for the XML query: 1. In the Data Model view, click the PRODUCT_ID column in the XML query, then drag it between the query name and the G_WAREHOUSE_ID1 group. Your data model should look like this: Note: You can also copy and paste this code from the provided file called xmlpds_code.txt. Copy the code under the heading Group Filter Code. Note: If you are not familiar with compiling PLSQL, refer to a PLSQL reference manual.