Create a SQL query for your new report

45-10 Oracle Reports Users Guide to Building Reports Figure 45–5 Paper Design view for the XML PDS report 8. Save your report. You have created the layout for your paper report.

45.2.5 Apply alternating row colors to your report

Now that you have created the report, you can make it more user-friendly by using a summary column to apply alternating row colors. To create a summary column to count the rows: 1. In the Data Model view, click the Summary Column tool in the tool palette. If you are still in the Paper Design view, you can click the Data Model button in the toolbar to display the Data Model view.

2. Click in the XML query group G_WAREHOUSE_ID1 to create a summary

column.

3. Double-click the new summary column object CS_1 to display the Property

Inspector, and set the following properties: ■ Under General Information, set the Name property to LineNo. ■ Under Column, make sure the Column Type property is set to Summary, and that the Datatype property is set to Number. ■ Under Summary, set the Function property to Count, and set the Source property to PRODUCT_NAME. To create a procedure that changes the row colors:

1. In the Object Navigator, click the Program Units node for your report.

2. Click the Create button in the toolbar to display the New Program Unit dialog box.

3. In the New Program Unit dialog box, type linecolors as in the Name field.

Note: You can also run the provided report inventory_ report.rdf. Before you can run the report, double-click the XML query in the Data Model view, and point the XML data source to the appropriate XSD and XML files. Building a Report with an XML Pluggable Data Source 45-11

4. Select Procedure, and click OK to display the PLSQL Editor for the new program

unit. 5. In the PLSQL Editor, enter the following PLSQL code to change the text color of the alternating rows to blue: PROCEDURE LineColors IS BEGIN if :LineNo mod 2=0 then srw.set_text_colorblue; else srw.set_text_colorblack; end if; END;

6. Click Compile to compile the procedure.

If any errors display, make sure the code is correct, and that you created the summary column in the steps above.

7. Click Close.

To create a format trigger for each field that calls the procedure:

1. In the Object Navigator, under your report name, expand the Paper Layout node

and navigate to Main Section Body M_G_WAREHOUSE_ID_GRPFR R_ G_WAREHOUSE_ID M_G_WAREHOUSE_ID1_GRPFR R_G_ WAREHOUSE_ID1 .

2. Under R_G_WAREHOUSE_ID1, double-click F_PRODUCT_ID to display the

Property Inspector. Note: You can copy and paste this code from the procedure provided in the xmlpds_code.txt file. Just copy the text under Line Colors Procedure. Note: Optionally, you can also change the fill colors of the alternating rows by following the steps in the above section, and using the following PLSQL code. In this example code, we have changed the fill color of alternating rows to red and blue: PROCEDURE LineColors IS BEGIN if :LineNo mod 2=0 then srw.set_foreground_fill_colorblue; srw.set_fill_patternsolid; else srw.set_foreground_fill_colorred; srw.set_fill_patternsolid; end if; END; Note: If you cannot find a particular field, use the Find field at the top of the Object Navigator.