Professional Documents
Culture Documents
Build Reports
D12997GC10
Production 1.0
June 2002
D34781
Author Copyright Oracle Corporation, 2002. All rights reserved.
Publisher
John B Dawson
Contents
.....................................................................................................................................................
Contents
Preface
Profile xvi
Resources xvii
Typographic Conventions xviii
Introduction
Course Objectives I-3
Course Content I-5
.....................................................................................................................................................
Oracle9i Reports Developer: Build Reports iii
Contents
.....................................................................................................................................................
.....................................................................................................................................................
iv Oracle9i Reports Developer: Build Reports
Contents
.....................................................................................................................................................
Lesson 8: Enhancing Reports Using the Data Model: Queries and Groups
Overview 8-3
Describing the Report Data Model 8-5
Modifying Properties of a Query 8-7
Changing the Group Structure 8-15
The Group Hierarchy 8-17
Ordering Data in a Group Hierarchy 8-19
Filtering Data in a Group 8-23
Summary 8-25
Practice Session Overview: Lesson 8 8-27
Practice Session: Lesson 8 8-28
.....................................................................................................................................................
Oracle9i Reports Developer: Build Reports v
Contents
.....................................................................................................................................................
Lesson 10: Enhancing Reports Using the Data Model: Creating Columns
Overview 10-3
The Data Model Column Types 10-5
Maintaining Data Source Columns 10-7
Using a Data Source Column to Output Contents of a File 10-9
Creating a Column 10-11
Creating Summary Columns 10-13
Example Report Displaying Subtotals 10-15
Example Report Displaying Percentages 10-17
Creating Formula Columns 10-21
Creating Placeholder Columns 10-23
Example Report to Populate a Placeholder 10-25
Summary 10-27
Practice Session Overview: Lesson 10 10-29
Practice Session: Lesson 10 10-30
.....................................................................................................................................................
vi Oracle9i Reports Developer: Build Reports
Contents
.....................................................................................................................................................
.....................................................................................................................................................
Oracle9i Reports Developer: Build Reports vii
Contents
.....................................................................................................................................................
.....................................................................................................................................................
viii Oracle9i Reports Developer: Build Reports
Contents
.....................................................................................................................................................
.....................................................................................................................................................
Oracle9i Reports Developer: Build Reports ix
Contents
.....................................................................................................................................................
Appendix A: Solutions
Practice Session Overview: Lesson 2 A-3
Practice Session Solutions: Lesson 2 A-4
Practice Session Overview: Lesson 3 A-8
Practice Session Solutions: Lesson 3 A-9
Practice Session Overview: Lesson 4 A-11
Practice Session Solutions: Lesson 4 A-12
Practice Session Overview: Lesson 5 A-18
Practice Session Solutions: Lesson 5 A-19
Practice Session Overview: Lesson 6 A-23
Practice Session Solutions: Lesson 6 A-24
Practice Session Overview: Lesson 7 A-27
Practice Session Solutions: Lesson 7 A-28
Practice Session Overview: Lesson 8 A-30
Practice Session Solutions: Lesson 8 A-31
Practice Session Overview: Lesson 9 A-33
Practice Session Overview: Lesson 10 A-40
Practice Session Solutions: Lesson 10 A-41
.....................................................................................................................................................
x Oracle9i Reports Developer: Build Reports
Contents
.....................................................................................................................................................
Glossary
.....................................................................................................................................................
Oracle9i Reports Developer: Build Reports xi
Contents
.....................................................................................................................................................
.....................................................................................................................................................
xii Oracle9i Reports Developer: Build Reports
14
................................
Web Reporting
Lesson 14: Web Reporting
.....................................................................................................................................................
Objectives
Instructor Note
Topic Timing
Lecture 45 minutes
Practice 30 minutes
Total 75 minutes
......................................................................................................................................................
14-2 Oracle9i Reports Developer: Build Reports
Overview
.....................................................................................................................................................
Overview
Introduction
Using Oracle9i Reports, you can easily publish data from any source, in any format,
with high fidelity to the Web. Earlier in this course, you learned how to build a simple
Web report using the Report Wizard and a standard HTML template supplied by
Oracle9i Reports.
You can also use your favorite HTML authoring tool to build the static portion of your
HTML page and then add dynamic content to the Web page using the Report Block
Wizard in Oracle9i Reports.
In this lesson, you learn more about building reports for the Web and how to customize
and enhance your reports using style sheets and the Web Source editor.
Objectives
After completing this lesson, you should be able to do the following:
• Identify the attributes of a high quality Web report
• Describe the JavaServer Page run-time environment
• Describe static and dynamic Web reporting
• Add dynamic content to an HTML page using the Report Block Wizard
• Identify the Reports custom JSP tags
• Customize Web reports using style sheets
• Customize Web reports using the Web Source editor
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 14-3
Lesson 14: Web Reporting
.....................................................................................................................................................
Instructor Note
Point out some of the features in the report above:
• Alternating row colors
• Format masks
• Use of a Web service to dynamically generate the values for the Local Currency
column
If asked, this functionality was implemented by creating a Java class and importing
it into the report. Specifically, the Java class was creating using JDeveloper. The
class called the Web service and returned the desired result. The class was then
imported into the report using the Java Importer. For more information see OTN.
• Web headings with icons (Mail and Help)
• Navigation tab on the left
......................................................................................................................................................
14-4 Oracle9i Reports Developer: Build Reports
High Quality Web Publishing
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 14-5
Lesson 14: Web Reporting
.....................................................................................................................................................
......................................................................................................................................................
14-6 Oracle9i Reports Developer: Build Reports
Creating Reports for the Web
.....................................................................................................................................................
Static Reports
The word static describes something that is fixed and unchanging. A static report is
one that displays the same data each time the report is invoked. The data is fetched
once and displayed on a Web page. Consider a paper report that has been pushed to the
Web. If you do not execute the paper report (RDF) again, and generate the Web output
(HTML or PDF) using the Web Wizard or File > Generate to File, the output remains
the same, that is, it is static.
Static reporting is sufficient for certain types of applications. A report that displays
data that does not change, such as historical data, does not require frequent refreshing.
Dynamic Reports
If your requirement is to publish the most recent data available when the information
is requested, a static report will not meet your needs. Your report must be dynamic.
The word dynamic describes something marked with continuous and productive
activity or change. Pertaining to software applications, dynamic refers to operations
performed on the fly that are based on decisions made while a program is executing,
instead of beforehand.
To achieve this in Oracle9i Reports, you embed a report block within a Web page.
Each time the report is executed, the data is fetched from the data source and the Web
page displays the most current information.
In this lesson, you will add dynamic content to a Web page.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 14-7
Lesson 14: Web Reporting
.....................................................................................................................................................
</body>
Instructor Note
Demonstration
Open the emprev.htm page, in order to add report data. Define the Data Model to
retrieve department managers and their salaries.
1 Display the Data Model view and invoke the Data Wizard using the right-mouse-
button menu.
2 Define the query using Query Builder:
DEPARTMENTS: department_name
EMPLOYEES: first_name, last_name, job_id, salary
3 Group by DEPARTMENT_ID. Finish the Wizard.
Now create the Report Block and add it to the Web page:
4 Display the Web Source view. Locate the “Your report block goes here” comment.
5 Select Insert > Report Block. Select Group Left, display both groups (down
direction), display all fields, and select the Beige template. Click Finish.
6 Run the Web layout.
Display the Web source again and show the students the code Reports Builder created.
......................................................................................................................................................
14-8 Oracle9i Reports Developer: Build Reports
Adding Dynamic Content to a Web Page
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 14-9
Lesson 14: Web Reporting
.....................................................................................................................................................
......................................................................................................................................................
14-10 Oracle9i Reports Developer: Build Reports
Creating a Report Block
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 14-11
Lesson 14: Web Reporting
.....................................................................................................................................................
<rw:report id="report">
<rw:objects id="objects">
Data Model & Business Logic (XML)
<layout>
Paper Layout (XML)
</layout>
</rw:objects>
<HTML>
Web Layout (JSP)
Graph (XML)
</HTML>
</rw:report>
......................................................................................................................................................
14-12 Oracle9i Reports Developer: Build Reports
Examining the Web Source Code
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 14-13
Lesson 14: Web Reporting
.....................................................................................................................................................
rw:foreach Tag
...
<rw:foreach id="R_G_EMPLOYEE_ID_1" src="G_EMPLOYEE_ID">
<tr>
<td <rw:headers id="HFEMPLOYEEID"
src="HBEMPLOYEEID"/>. . .
<td <rw:headers id="HFEmployee"
src="HBEmployee"/> . . .
...
rw:field Tag
...
<td <rw:headers id="HFEMPLOYEEID"
src="HBEMPLOYEEID"/> class="OraCellNumber">
<rw:field id="F_EMPLOYEE_ID" src="EMPLOYEE_ID"
nullValue=" "> F_EMPLOYEE_ID </rw:field></td>
...
......................................................................................................................................................
14-14 Oracle9i Reports Developer: Build Reports
Examining the Web Source Code
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 14-15
Lesson 14: Web Reporting
.....................................................................................................................................................
<rw:style id="rwbeige">
<link rel="StyleSheet" type="text/css" href="rwbeige.css">
</rw:style>
…
......................................................................................................................................................
14-16 Oracle9i Reports Developer: Build Reports
Customizing Reports JSPs
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 14-17
Lesson 14: Web Reporting
.....................................................................................................................................................
U\
<thead>
<tr>
<th <rw:id id="HBEMPLOYEEID" asArray="no"/>
class="OraColumnHeader"> Employee Id </th>
…
<th <rw:id id="HBSALARY" asArray="no"/> align="right"
bgcolor="yellow"> Salary </th>
</tr>
</thead>
......................................................................................................................................................
14-18 Oracle9i Reports Developer: Build Reports
Customizing Reports JSPs
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 14-19
Lesson 14: Web Reporting
.....................................................................................................................................................
Instructor Note
Continue with the same demonstration.
Add a format mask for the salary column. Locate the rw:field tag for F_SALARY
and add the : formatMask="$999,999.00" attribute.
Run the Web layout to test.
......................................................................................................................................................
14-20 Oracle9i Reports Developer: Build Reports
Customizing Reports JSPs
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 14-21
Lesson 14: Web Reporting
.....................................................................................................................................................
Summary
......................................................................................................................................................
14-22 Oracle9i Reports Developer: Build Reports
Summary
.....................................................................................................................................................
Summary
Adding Dynamic Content to a Web Page
With Oracle9i Reports, you can open an existing Web page in Reports Builder and add
dynamic report data to the page.
• Use the Data Wizard to define a data model.
• Create a report block at the desired location in the Web page using the Web Source
editor and the Report Block Wizard.
• Save your report as a Reports JSP.
Reports JSPs
The Web layout for your report definition is delimited by the HTML tags in the source
code. Reports JSP custom tags in this section include rw:foreach, rw:id, and
rw:field.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 14-23
Lesson 14: Web Reporting
.....................................................................................................................................................
Practice 14 Overview
......................................................................................................................................................
14-24 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 14
.....................................................................................................................................................
Introduction
In this practice, you will create a Web report by adding dynamic report data to an
existing HTML page. You will also customize the Web report by using JSP tag
attributes.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 14-25
Lesson 14: Web Reporting
.....................................................................................................................................................
......................................................................................................................................................
14-26 Oracle9i Reports Developer: Build Reports
15
................................
Extending Functionality
Using XML
Lesson 15: Extending Functionality Using XML
.....................................................................................................................................................
Objectives
Instructor Note
Topic Timing
Lecture 40 minutes
Practice 15 minutes
Total 55 minutes
......................................................................................................................................................
15-2 Oracle9i Reports Developer: Build Reports
Overview
.....................................................................................................................................................
Overview
Introduction
In an earlier lesson, you were introduced to Extensible Markup Language, or XML.
Recall that XML enables business-to-business exchanges of data across applications
and platforms. You learned how to use XML as a data source in a report.
It is also possible to build a report definition using XML tags. This XML report
definition can be run by itself or can be applied to another report at run time to
customize the output for a specific audience.
In this lesson, you will learn how to build a report using XML tags, apply
customizations to a report at runtime, and apply batch update to existing reports.
Objectives
After completing this lesson, you should be able to do the following:
• Describe the benefits of using XML report definitions
• Create XML report definitions
• Apply XML report definitions to an existing report
• Debug XML report definitions
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 15-3
Lesson 15: Extending Functionality Using XML
.....................................................................................................................................................
Instructor Note
A customization file can be applied to an existing .RDF or XML file. For an XML
report to run by itself, it must contain a full report definition comprising a full Data
Model and layout.
File xmlresult.xml contains the XML output for xmlresult.rdf. You may
want to generate the XML output yourself (File > Generate to File > XML). The XML
file contains the report structure as well as the queried data. It is driven from the Data
Model and has no dependency on any defined layout. You can apply an XML
customization file to this XML output that would define a visual layout.
Technical Note
For more information see the section “Customizing Reports with XML” in the
Oracle9iAS Reports Services Publishing Reports manual.
......................................................................................................................................................
15-4 Oracle9i Reports Developer: Build Reports
Why Use XML Report Definitions?
.....................................................................................................................................................
Run-Time Customizations
You can apply customizations to change the look and feel of a report at run time
without changing the original report. This allows for a report to be different for
different audiences. For example, labels can be designed according to geography, or
colors and format masks can be designed on a per user or user group basis.
Furthermore, Oracle9i Reports extends the possible types of Reports XML
customizations by enabling you to create an entire Data Model in XML. This includes
the creation of multiple data sources, linking between data sources, and group
hierarchies within each data source. Data Model support through Reports XML
customization means that any Data Model that can be created with Reports Builder
can now be created by specifying XML. You can also set properties for Data Model
objects using XML.
Batch Updates
Using an XML report definition, you can apply batch updates to existing reports. You
have the option of saving the combined definition to a file. The advantage is that you
can quickly update a large number of reports without having to open each file in
Reports Builder to make the changes.
Product Openess
XML support in Oracle9i Reports provides a mechanism for exchanging data with
third-party applications. It also offers a way to furnish data to tools that accept XML
output for data analysis, and XML is easily displayed on the Web.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 15-5
Lesson 15: Extending Functionality Using XML
.....................................................................................................................................................
Instructor Note
The Document Type Definition (DTD) files are what give XML tags life and meaning.
Oracle9i Reports Developer includes a DTD file that defines the tags that can be used
in a report definition. For more information on XML tags, refer to the Reports Builder
Reference online Help system.
File fullxml.xml contains a full XML report definition. Use the Reports Builder to
run this report.
Note: A full XML definition contains a data model and a layout. A partial XML
definition contains a layout only.
......................................................................................................................................................
15-6 Oracle9i Reports Developer: Build Reports
Creating and Using XML Report Definitions
.....................................................................................................................................................
Example
The following is a sample of a partial report definition:
<report name="employee" DTDVersion="1.0">
<layout>
<section name="main">
<field name="f_sal" source="sal" textColor="red "/>
<field name="f_mgr" source="mgr" fontSize="14"
font="Roman"/>
<field name="f_deptno" source="deptno" fontStyle="bold"
fontEffect="undereline"/>
</section>
</layout>
</report>
Every XML report definition, whether full or partial, must contain the required tag
pair, <report> </report>. The <report> tag indicates the beginning of the report
customization, its name, and the version of the Document Type Definition (DTD) file
that is being used with this XML customization. The </report> tag indicates the end of
the report customization. A full report requires both a data model and layout and
therefore requires the <data></data> and <layout></layout> tags and their contents.
The report name attribute in the <report> tag can be any name you wish, and can be
different than the name of the .rdf file. The name attributes in the <field> and
<section> tags match the names of the fields and sections. As a result, the attributes
will be applied to the fields and sections listed.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 15-7
Lesson 15: Extending Functionality Using XML
.....................................................................................................................................................
......................................................................................................................................................
15-8 Oracle9i Reports Developer: Build Reports
Creating and Using XML Report Definitions
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 15-9
Lesson 15: Extending Functionality Using XML
.....................................................................................................................................................
......................................................................................................................................................
15-10 Oracle9i Reports Developer: Build Reports
Creating and Using XML Report Definitions
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 15-11
Lesson 15: Extending Functionality Using XML
.....................................................................................................................................................
......................................................................................................................................................
15-12 Oracle9i Reports Developer: Build Reports
Creating and Using XML Report Definitions
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 15-13
Lesson 15: Extending Functionality Using XML
.....................................................................................................................................................
......................................................................................................................................................
15-14 Oracle9i Reports Developer: Build Reports
Creating and Using XML Report Definitions
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 15-15
Lesson 15: Extending Functionality Using XML
.....................................................................................................................................................
Instructor Note
Use datamod.xml —which is the example from the previous page— to customize
l15cus.rdf using the RWRUN command with the customize option. Note that the
query Q_sal_summary contains a bind reference, :loc_nr.
Make sure to run l15cus.rdf first so that you can compare the results. Send the
ouput to a PDF file.
......................................................................................................................................................
15-16 Oracle9i Reports Developer: Build Reports
Running XML Report Definitions
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 15-17
Lesson 15: Extending Functionality Using XML
.....................................................................................................................................................
• Run by itself
• Batch updates
rwconverter source="(...)"
dest=... customize=...
batch=yes
Instructor Note
For applying XML definitions stored in the database, you may need to spread out the
XML report definition over several columns because of the upper limit on the size of
VARCHAR2 columns. In this case, you will have to code the built-in
SRW.ADD_DEFINITION several times in the report trigger.
......................................................................................................................................................
15-18 Oracle9i Reports Developer: Build Reports
Running XML Report Definitions
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 15-19
Lesson 15: Extending Functionality Using XML
.....................................................................................................................................................
• XML parser
• Tracing option
• Using Reports Builder
Instructor Note
Run a trace on XML file fullxml.xml and show the result.
......................................................................................................................................................
15-20 Oracle9i Reports Developer: Build Reports
Debugging XML Report Definitions
.....................................................................................................................................................
Technical Note
For more information on the XML parser, refer to the Oracle Technology Network
(http://otn.oracle.com).
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 15-21
Lesson 15: Extending Functionality Using XML
.....................................................................................................................................................
Summary
......................................................................................................................................................
15-22 Oracle9i Reports Developer: Build Reports
Summary
.....................................................................................................................................................
Summary
• Using XML report definitions:
– Run-time customizations
– Batch updates
– Stand-alone reports
• Applying XML report definitions:
– From the command line
– From PL/SQL
• Debugging XML report definitions:
– The XML parser
– The trace option
– Using Reports Builder
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 15-23
Lesson 15: Extending Functionality Using XML
.....................................................................................................................................................
Practice 15 Overview
......................................................................................................................................................
15-24 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 15
.....................................................................................................................................................
Introduction
Using XML you can build fully functional reports or partial reports that can serve as a
customization file.
You will run an XML file and apply an XML definition to an existing report.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 15-25
Lesson 15: Extending Functionality Using XML
.....................................................................................................................................................
......................................................................................................................................................
15-26 Oracle9i Reports Developer: Build Reports
16
................................
Objectives
Instructor Note
Topic Timing
Lecture 50 minutes
Practice 30 minutes
Total 80 minutes
......................................................................................................................................................
16-2 Oracle9i Reports Developer: Build Reports
Overview
.....................................................................................................................................................
Overview
Introduction
Parameters enable you to develop dynamic report documents that produce variable
report output depending on the parameter value that you enter at run time. This lesson
shows you how to create and reference user and system parameters and how to
customize a Paper Parameter Form to display parameters at run time.
Objectives
After completing this lesson, you should be able to do the following:
• Control report output by creating and referencing a parameter
• Control parameter input using a list of values
• Manipulate reports at run time using system parameters
• Provide for user input of parameters by building a Paper Parameter Form
• Customize a Paper Parameter Form layout
• Use HTML Parameter Form extensions
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-3
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
User Parameters
Instructor Note
Briefly mention that user parameters can be used with pluggable data sources in
Oracle9i Reports. This lesson covers parameters in a SQL query.
Technical Note
For more information on using parameters with pluggable data sources, see the eClass
Oracle9i Reports: Integrate Pluggable Data Sources.
......................................................................................................................................................
16-4 Oracle9i Reports Developer: Build Reports
Creating User Parameters
.....................................................................................................................................................
Parameter Properties
Property Description
Datatype Specify whether parameter value is Character, Number, or Date;
default is Number when created in the Object Navigator.
Width Specify maximum allowable width of parameter value; maximum is
64 KB.
Input Mask Allow users to enter a numeric or date value using a specific format.
Initial Value Specify the value to use. You can override this value at run time from
the command line or parameter form.
Validation Validate the parameter value. Enter a PL/SQL function.
Trigger
List of Values Create a list of values from which users select a valid value at run
time.
Type of Pluggable Used by the PDS for acquiring single sign-on information. It identifies
Data Source that parameter as containing sign-on information for that PDS
connection.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-5
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
Referencing Parameters in a
Report Query
Instructor Note
Explain the differences between a bind and a lexical reference. Note that substitution
for a bind reference happens after the SELECT statement is parsed; whereas, for a
lexical reference, this happens before the SELECT statement is parsed.
Be brief; there are examples on the next pages.
......................................................................................................................................................
16-6 Oracle9i Reports Developer: Build Reports
Referencing Parameters in a Report Query
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-7
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
Instructor Note
Run L16BIND.JSP. You want to restrict the Order Mode.
Add to the query: AND O.ORDER_MODE = :P_ORDERMODE
Notice the message telling you that the parameter is being created.
In the Object Navigator, show the user parameters.
In the parameter Property Inspector, show that the default data type is CHARACTER.
Change the following: Width=8, Initial Value=direct. Run the paper layout. Now run
the Web layout.
Show the other method of creating a parameter. In the Object Navigator, create a
parameter called P_CUST and show the properties. Point out that the default data type
is NUMBER, so be careful of the data type when you create parameters. Set the initial
value to 101.
Add to the query: AND O.CUSTOMER_ID > :P_CUST
......................................................................................................................................................
16-8 Oracle9i Reports Developer: Build Reports
Referencing Parameters in a Report Query
.....................................................................................................................................................
Examples
SELECT CUST_LAST_NAME, ACCOUNT_MGR_ID
FROM CUSTOMERS
WHERE CUSTOMER_ID = :P_CUST
This statement enables you to enter a specific customer number at run time. For
example, if you enter 102, the WHERE clause uses the value 102 to restrict data
fetched and to fetch the one customer that has ID 102.
SELECT CUST_LAST_NAME, ACCOUNT_MGR_ID
FROM CUSTOMERS
ORDER BY DECODE(:SORT, 1, CUST_LAST_NAME,
2, NLS_TERRITORY,
ACCOUNT_MGR_ID)
This statement enables you to output different versions of the report:
• Enter 1 for the parameter SORT to display the output ordered by customer name.
• Enter 2 to display the output ordered by NLS_territory.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-9
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
Instructor Note
Demonstration:
Add a lexical parameter to alter the order of output.
Add to query: ORDER BY &P_ORDCLAUSE . Show the error. The parameter is not
created by default, so the syntax ORDER BY <null> is not valid.
Create the lexical parameter in the Object Navigator. Show the properties. Point out
the default data type and size and modify as required: CHARACTER, 50.
Set an initial value. This time, include the keywords ORDER BY
C.CUST_LAST_NAME DESC, so that you can leave the clause blank at run time.
Now add the reference to the end of the query: &P_ORDCLAUSE.
Run with different values, including NULL.
Continue the demonstration to add a dynamic list of values to the bind parameter and a
static list to the lexical parameter, or teach the next page and then demonstrate. Run
the report using the Paper Design and then run the report in a browser.
......................................................................................................................................................
16-10 Oracle9i Reports Developer: Build Reports
Referencing Parameters in a Report Query
.....................................................................................................................................................
Examples
The following statements use lexical references to substitute parts of the query at run
time:
• To specify a WHERE clause, ORDER BY clause, or both at run time (as two
separate parameters):
SELECT CUST_LAST_NAME, ACCOUNT_MGR_ID
FROM CUSTOMERS
&P_WHERE_CLAUSE
&P_ORD_CLAUSE
• To specify a WHERE clause, ORDER BY clause, or both at run time (as one
parameter):
SELECT CUST_LAST_NAME, ACCOUNT_MGR_ID
FROM CUSTOMERS
&P_WHERE_ORD_CLAUSE
• To specify two column names and the table names at run time:
SELECT &P_CUSTNAME CUST, &P_ACCTMGR MGR
FROM &P_TABLE
Note: When you use lexical references in the SELECT list, you must, at run time,
specify the same number of items of the correct data type, as defined in the Data
Model.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-11
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
Instructor Note
Use the whiteboard to work through a SQL example of the first and third points shown
in the slide.
......................................................................................................................................................
16-12 Oracle9i Reports Developer: Build Reports
Hints and Tips for Referencing Parameters
.....................................................................................................................................................
Example
The following statement does not cause a syntax error when P_ORDER_CLAUSE is
NULL.
SELECT...FROM...
&P_ORDER_CLAUSE
The following statement does cause a syntax error when P_ORDER_CLAUSE is
NULL.
SELECT...
FROM...
ORDER BY &P_ORDER_CLAUSE
Remember to define an initial value for lexical parameters that affect the validity of
the statement, and to validate those that you allow a user to enter at run time. Initial
values are required for lexical parameters used for column and table names.
Note: Always use column aliases when substituting column names with lexical
references.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-13
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
2 3
4
5
Instructor Note
Use l16bind.jsp to demonstrate a static list of values for payment type, or by
creating a number of different ORDER BY clauses.
Examples:
ORDER BY C.CUST_LAST_NAME DESC (our initial value)
ORDER BY C.CUST_LAST_NAME
ORDER BY O.ORDER_ID DESC
Make sure the Restrict List to Predetermined Values check box is clear to allow for
other values. Run the report. Select one of the ORDER BY clauses from the list of
values. Run the report again. Select ORDER BY O.ORDER_ID, but delete DESC.
Suggest that students can use column aliases to make the ORDER BY clause more
readable.
......................................................................................................................................................
16-14 Oracle9i Reports Developer: Build Reports
Creating a List of Values
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-15
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
1
3
2
5
Instructor Note
Demonstrate a dynamic list of values by selecting a list of customer IDs and names
from the CUSTOMERS table.
Select the Restrict List to Predetermined Values check box.
Demonstrate the Hide First Column check box. Explain to the students that they can
select more than one column in the SELECT statement so that they can display a more
descriptive list to the user. The first column should be the value that restricts the query.
Run the report and show that this time you cannot edit or enter your own value.
......................................................................................................................................................
16-16 Oracle9i Reports Developer: Build Reports
Creating a List of Values
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-17
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
System Parameters
Instructor Note
Demonstration:
Show the system parameters in the Object Navigator.
Explain the DESNAME, DESFORMAT, and DESTYPE parameters briefly.
COPIES: Only if destination is a printer
CURRENCY, THOUSANDS, DECIMAL: Only if symbols are used in format masks
Remind the students that these are also arguments that they can include on the
command line for RWBUILDER or RWRUN. However, the following command line
options have been deprecated in Oracle9i Reports:
Command Line Option to use instead
Option
BACKGROUND Use the BATCH command line option.
CURRENCY Set the NLS_CURRENCY evnironment variable.
DECIMAL Set the NLS_NUMERIC_CHARACTERS environment variable.
THOUSANDS Set the NLS_NUMERIC_CHARACTERS environment variable.
Run the report with DESTYPE set to File, DESNAME set to my_rep.rtf, and
DESFORMAT set to .rtf.
......................................................................................................................................................
16-18 Oracle9i Reports Developer: Build Reports
Referencing System Parameters
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-19
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
Initial Value £
Instructor Note
The diagram above shows the method described opposite.
Mention the alternative: Setting NLS_LANG and using the L, G, and D symbols
(which are used by the currency symbols in the stylebar). NLS is discussed later in the
course.
Demonstration: Alter the format of F_ORDER_TOTAL to $N,NNN,NN0.00 (there
are some credit orders that are more than $1 million).
Change CURRENCY initial value to FF (or something else).
Run the report.
You might want to point out that the currency parameter does not appear on the
current default run-time parameter form (if nobody mentions it before you). You can
show it later, if you want, when you create a parameter form.
If you have time: Create a program item for the demonstration report (you can save
time by creating this before the lesson). The command line should be:
<oracle home>\bin\rwrun report=reportname
userid=<user/password@host> currency=FF
Show that this command overrides the initial value of the parameter.
......................................................................................................................................................
16-20 Oracle9i Reports Developer: Build Reports
Referencing System Parameters
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-21
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
+ Report properties:
• Width
• Height
• Number of Pages
Instructor Note
Demonstrate how to display the Paper Parameter Form in the Report Editor:
• Show the Paper Parameter Form icon in the top left corner of the Report editor.
• Show the menu option View > Change View > Paper Parameter Form.
• Show the Paper Parameter Form node and icon in the Object Navigator.
The Paper Parameter Form layout is currently blank; no parameter form is defined.
You may want to show that there is no File Link tool in the Paper Parameter Form
toolbar.
Point out that although you can create your parameter form from scratch, it is usually
easier to let Reports Builder do some of the work by creating a Default Paper
Parameter Form and then modifying it. This is discussed on the next page.
......................................................................................................................................................
16-22 Oracle9i Reports Developer: Build Reports
Building a Paper Parameter Form
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-23
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
Instructor Note
Demonstration:
Continue with the previous demonstration report that contains a parameter.
Build a parameter form.
Insert p2q40.gif or some other graphics. Save the report and run it in a browser.
Show the Property Inspector for a field and for some boilerplate text. Point out the
default naming convention, PF and PB.
You can alter parameter properties from the field as well as in the Data Model
parameter object.
......................................................................................................................................................
16-24 Oracle9i Reports Developer: Build Reports
Building a Paper Parameter Form
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-25
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
......................................................................................................................................................
16-26 Oracle9i Reports Developer: Build Reports
Using Parameter Form HTML Extensions
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-27
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
Header
Footer
......................................................................................................................................................
16-28 Oracle9i Reports Developer: Build Reports
Using Parameter Form HTML Extensions
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-29
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
Summary
......................................................................................................................................................
16-30 Oracle9i Reports Developer: Build Reports
Summary
.....................................................................................................................................................
Summary
• Parameter types:
– User parameters:
References: bind or lexical
List of values: dynamic (bind only) or static
– System parameters
• Modifying parameter values at run time:
– Pass the parameter on the RWRUN command line
– Allow users to change values in the run-time parameter form
• Creating a run-time parameter form:
– Build a parameter form with the Parameter Form Builder
– Customize the paper parameter form layout in the Report editor
– Evaluate using HTML Parameter Form extensions
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-31
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
Practice 16 Overview
......................................................................................................................................................
16-32 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 16
.....................................................................................................................................................
Introduction
In this practice session, you create bind and lexical parameters to restrict records in the
report. You add lists of values to select valid values at run time.
You then create your own default parameter form and customize it to include extra text
and graphics.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-33
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
......................................................................................................................................................
16-34 Oracle9i Reports Developer: Build Reports
Practice Session: Lesson 16
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 16-35
Lesson 16: Creating and Using Report Parameters
.....................................................................................................................................................
......................................................................................................................................................
16-36 Oracle9i Reports Developer: Build Reports
17
................................
Embedding a Graph in a
Report
Lesson 17: Embedding a Graph in a Report
.....................................................................................................................................................
Objectives
Instructor Note
Topic Timing
Lecture 30 minutes
Practice 30 minutes
Total 60 minutes
......................................................................................................................................................
17-2 Oracle9i Reports Developer: Build Reports
Overview
.....................................................................................................................................................
Overview
Introduction
In this lesson, you learn to display a graph in a report at run time.
Objectives
After completing this lesson, you should be able to do the following:
• Create and display a graph in a paper report using the Graph Wizard
• Create and display a graph in a Web report using the Graph Wizard
• Edit the Web source to customize a graph in a Web report
• Use graph hyperlinks
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 17-3
Lesson 17: Embedding a Graph in a Report
.....................................................................................................................................................
......................................................................................................................................................
17-4 Oracle9i Reports Developer: Build Reports
Creating and Embedding a Graph in a Report
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 17-5
Lesson 17: Embedding a Graph in a Report
.....................................................................................................................................................
Instructor Note
Suggested demonstration:
Open l17pie.jsp and create a pie graph. Category: DEPARTMENT_NAME.
Data: sumSALARYPerDEPARTMENT_NAME. Position the graph at the beginning
of the report.
Note: On the layout page, be sure that the category column is in the ‘Slices’ area. You
may need to drag DEPARTMENT_NAME from the Groups area to the Slices area.
......................................................................................................................................................
17-6 Oracle9i Reports Developer: Build Reports
Creating and Embedding a Graph in a Report
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 17-7
Lesson 17: Embedding a Graph in a Report
.....................................................................................................................................................
......................................................................................................................................................
17-8 Oracle9i Reports Developer: Build Reports
Creating and Embedding a Graph in a Report
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 17-9
Lesson 17: Embedding a Graph in a Report
.....................................................................................................................................................
Graph XML
</rw:graph>
Instructor Note
Continue with l17pie.jsp. Insert a graph into the Web source.
1 Open the Web Source view.
Continue with the steps on the opposite page.
......................................................................................................................................................
17-10 Oracle9i Reports Developer: Build Reports
Creating and Embedding a Graph in a Report
.....................................................................................................................................................
Use the Web Source editor to modify or add attributes. In the slide opposite, the width
and height attributes were included to customize the size of the graph in the Web
report. The graph hyperlink will invoke a drill down report on a specific employee.
You can also customize a graph by modifying the graph XML.
Instructor Note
2 Scroll down in the code and locate the comment Insert Graph Here.
3 Select Insert > Graph to invoke the Graph Wizard.
4 Graph type: Bar
5 Category: DEPARTMENT_NAME
6 Data Columns: SumSalaryPerDEPARTMENT_NAME
7 Finish the Wizard.
8 Run the Web layout to test.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 17-11
Lesson 17: Embedding a Graph in a Report
.....................................................................................................................................................
• Document
on same
machine
• Any
destination
• Any URL
Instructor Note
Explain briefly what the last example on the opposite page means. You will look into
this in detail in a later chapter and provide a more elegant solution.
This is the URL syntax for a JSP-based report. In the URL specification, wlord-pc
is the name of the Web server, and us.oracle.com is the domain name. The port is
7777. The rest of the URL specification contains the report module to be executed
along with various parameters.
Note: Oracle9iAS Reports Services is needed to execute a report using graph
hyperlinks. You cannot run such a report with Reports Builder.
......................................................................................................................................................
17-12 Oracle9i Reports Developer: Build Reports
Using a Graph Hyperlink
.....................................................................................................................................................
Usage Notes
• You can set another report as the graph hyperlink. This second report will run from
your first report output.
• The Additional Attributes (HTML) property for Parameter Form fields cannot be
used to add additional HTML attributes to a link defined by a graph hyperlink.
• You cannot set a graph hyperlink by using PL/SQL.
• You must set the Hyperlink Destination property for a graph hyperlink that
specifies another layout object as its destination.
Examples
• A document on the same machine:
file:///C|corp_policy/car/lease.pdf
• Any URL:
http://wlord-pc.us.oracle.com:7777/myexamples/
emp.jsp?server=rep1-wlord&userid=hr/hr@wl81&
destype=cache&desformat=htmlcss&emp_id=&EMPLOYEE_ID
Technical Note
When delimiting parameters in a URL, you can use the ampersand (&) or the plus sign
(+). The ampersand is more commonly used and recommended. The ampersand
immediately preceding EMPLOYEE_ID indicates substitution.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 17-13
Lesson 17: Embedding a Graph in a Report
.....................................................................................................................................................
Summary
......................................................................................................................................................
17-14 Oracle9i Reports Developer: Build Reports
Summary
.....................................................................................................................................................
Summary
• Use the Graph Wizard to create and embed a simple graph in your report.
• Reenter the Graph Wizard to make changes to the graph object, such as its position
in the report.
• Customize a graph in a Web report by editing the attributes of the Reports JSP
custom tag, rw:graph.
• Use the graph hyperlink property to implement drill-down functionality.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 17-15
Lesson 17: Embedding a Graph in a Report
.....................................................................................................................................................
Practice 17 Overview
......................................................................................................................................................
17-16 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 17
.....................................................................................................................................................
Introduction
In this practice session you open existing reports to add graphs using the Graph
Wizard. You reenter the Graph Wizard to change the characteristics of a graph. You
will also add and customize a graph in a Web report.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 17-17
Lesson 17: Embedding a Graph in a Report
.....................................................................................................................................................
Run the paper layout to test. Resize the graph in the Paper Layout, if necessary.
d
e Save report as p17q1.jsp.
2 Reenter the Graph Wizard to change the characteristics of the graph created in the
previous exercise.
a Give the graph the following characteristics:
Title Order Total per Sales Rep
Graph Type Horizontal Bar
Graph Subtype Bar
......................................................................................................................................................
17-18 Oracle9i Reports Developer: Build Reports
Practice Session: Lesson 17
.....................................................................................................................................................
In the Paper Layout, ensure that the graph is postitioned beneath the product
b
group.
c Run the paper layout and test the report.
d Save the report as p17q4.jsp.
5 Continue with report p17q4.jsp.
a Add a bar graph to the Web source for the data group G_PRODUCT. Use the
same data group, category, and value settings as in the previous exercise.
Hint: You want to insert the graph just before the termination of the rw:foreach
tag for the group G_NAME.
b Run the Web layout to test. Ensure that a graph displays for each sales
respresentative.
c Resize the graph to a width of 800 and a height of 450.
d Save the report as p17q5.jsp. Run the Web layout to test.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 17-19
Lesson 17: Embedding a Graph in a Report
.....................................................................................................................................................
......................................................................................................................................................
17-20 Oracle9i Reports Developer: Build Reports
18
................................
Objectives
Instructor Note
Topic Timing
Lecture 50 minutes
Practice 45 minutes
Total 95 minutes
......................................................................................................................................................
18-2 Oracle9i Reports Developer: Build Reports
Overview
.....................................................................................................................................................
Overview
Introduction
Matrix or cross product reports show cells of information that relate to values
appearing across the top and down the left side of the report.
In an earlier lesson, you created a matrix report using the Report Wizard. In this
lesson, you modify the Data Model and layout objects to enhance your matrix reports.
Objectives
After completing this lesson, you should be able to do the following:
• Design a matrix Data Model
• Design a matrix Paper Layout
• Modify a matrix structure
• Create additional matrix summaries
• Create a matrix with group report
• Create a nested matrix report
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 18-3
Lesson 18: Enhancing Matrix Reports
.....................................................................................................................................................
4
2
Instructor Note
Demonstration: l18mat.rdf.
Mention that the Wizard creates a single-query matrix. You can build multiple-query
matrices, but it is not often necessary unless you have very complex data with large
queries and outer joins that are difficult to combine in one query. This course discusses
single-query models only.
Step through the Wizard and explain each of the groups and matrix summaries above.
Carefully explain the Salary column and that this is used to calculate the SumSalary
value in the cross product group. SumSalary becomes the cell, not Salary itself.
For large reports, it is more efficient to calculate the summary in the query if you do
not require the individual salary records. However, you can still create the cell with a
summary as it has some useful properties, such as being able to use Value if Null,
which is explained later.
......................................................................................................................................................
18-4 Oracle9i Reports Developer: Build Reports
The Matrix Data Model
.....................................................................................................................................................
Simple Matrix Style The Report Wizard creates three basic data groups:
• One row of record values (Department_Name)
• One column of record values (Job_ID)
• One group of cells, where each cell contains data related to each row and column
combination.
There is an extra group that surrounds the row and column groups. It is called the cross
product group and contains the summary column that forms each cell value,
SumSalary, as well as the summaries to total the row and column values.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 18-5
Lesson 18: Enhancing Matrix Reports
.....................................................................................................................................................
F_department_na F_Sumsalary
1 2 3
Instructor Note
Demonstration:
Continue with l18mat.rdf. Show the Paper Layout. This matrix report was created
with a special template that includes additional spacing. No extra objects have been
added, but the layout has been adjusted so that it is easier to explain and understand the
objects and layers in the Paper Layout.
As well as the repeating frames, point out the position of the summaries.
Details for creating the matrix object are also discussed later in this lesson, with the
nested matrix layout.
......................................................................................................................................................
18-6 Oracle9i Reports Developer: Build Reports
The Matrix Paper Layout
.....................................................................................................................................................
Simple Matrix Style The Report Wizard creates the following objects:
• One repeating frame with print direction of Down to hold the row values
• One repeating frame with print direction of Across to hold the column values
• A field for the summary of the cell values; the source is SumSalary, which resides
in the cross product group
• Fields for the row and column values, as well as for the row, column, and report
summaries if applicable
• A matrix object that corresponds to the cross product group; this object intersects
the row and column repeating frames, and contains the cell field
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 18-7
Lesson 18: Enhancing Matrix Reports
.....................................................................................................................................................
F_CITY 2
1 F_SumsalaryPerJOB_I F_SumsalaryPerCITY
F_SumsalaryPer
3
Instructor Note
Remember that you can set column properties from either the column or the paper
layout field’s Property Inspector. When demonstrating, use the field, because all
necessary properties are available.
Regarding Product Order for the matrix cell: The default value for this property is
<down group> <across group>, for example G_DEPARTMENT_NAME G_JOB_ID.
The print direction for the group G_DEPARTMENT_NAME is down, and the print
direction for the group G_JOB_ID is across.
......................................................................................................................................................
18-8 Oracle9i Reports Developer: Build Reports
Creating Matrix Summaries
.....................................................................................................................................................
The Reset At option has the same effect as in other report styles. When you create
summaries with the Wizard, each summary resets for each occurrence of the group.
For example, the department summary resets for each department. If you want the
summary values to accumulate throughout the report, change Reset At to a higher
level, such as Report.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 18-9
Lesson 18: Enhancing Matrix Reports
.....................................................................................................................................................
......................................................................................................................................................
18-10 Oracle9i Reports Developer: Build Reports
Creating the Simple Matrix Report Manually
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 18-11
Lesson 18: Enhancing Matrix Reports
.....................................................................................................................................................
1 4
5
Region: F_CITY
F_SumsalaryPerTITLE F _SumsalaryPerCITY
Total: F_SumsalaryPer
Instructor Note
Demonstration: l18matgrp.rdf.
......................................................................................................................................................
18-12 Oracle9i Reports Developer: Build Reports
Building a Matrix with Group Report
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 18-13
Lesson 18: Enhancing Matrix Reports
.....................................................................................................................................................
Instructor Note
Demonstration: l18nest.rdf.
This matrix was also built using the template with additional spaces.
Remind students that Oracle9i Reports Developer supports single-query, nonsparse
nested matrix reports (suppressing unnecessary blank rows and columns). To achieve
this, set the Child Dimension group property to Yes, indicating that a group is a child
dimension group in the nested matrix Data Model. Note that the lines between groups
inside the cross product group are now solid instead of dotted.
......................................................................................................................................................
18-14 Oracle9i Reports Developer: Build Reports
Building a Nested Matrix
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 18-15
Lesson 18: Enhancing Matrix Reports
.....................................................................................................................................................
Instructor Note
Demonstration:
Continue with l18nest.rdf, and explain the extra repeating frame.
Use this report to explain the matrix object in more detail, and how to create it.
Show the matrix nodes in the Object Navigator. Delete one of the matrix objects. The
Dimension and Frequency nodes disappear. Re-create the matrix object. The nodes
reappear, but there is no explicit matrix node for the matrix object name. In the paper
layout, select the matrix object and open the Property Inspector.
......................................................................................................................................................
18-16 Oracle9i Reports Developer: Build Reports
Building a Nested Matrix
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 18-17
Lesson 18: Enhancing Matrix Reports
.....................................................................................................................................................
F_SumSALARY F_SumSALPerDEPA
F_Sum_CITY
F_SumSALPerJOB_
Instructor Note
Demonstration:
Modify l18nest (instructions below), or show the end result in l18nstsm.rdf.
Field names on the slide and in the report have been changed so that they fit on the
page, but are still meaningful and similar to the Wizard default names. (Also refer to
hidden PowerPoint slide and notes page for additional teaching aids.)
Show the Property Inspector for the different summaries and explain Product Order.
Create the additional summary to show region subtotals:
1 In Data Model, create another summary in the cross product group. Name:
CS_Sum_CITY. Source: SumSALARY. Product Order: G_CITY. Reset At:
G_CITY.
2 In the Paper Layout, make sure that Flex Mode is on, and then enlarge the city
repeating frame downward to make room for the field.
3 Create a field using the Field tool. Name: F_Sum_CITY. Source:
CS_Sum_CITYSum. Reset At: G_CITY. Product Order: G_CITY.
4 Run the paper layout.
......................................................................................................................................................
18-18 Oracle9i Reports Developer: Build Reports
Building a Nested Matrix
.....................................................................................................................................................
The diagram also shows a fourth summary, F_Sum_CITY, which you might want to
create yourself to produce a subtotal for each region.
1 Create another summary in the cross product group.
2 Create a layout field and place it as shown in the diagram, in the R_G_CITY
repeating frame (use the Object Navigator to identify it). The following table
shows the property settings.
Field Name Reset At Product Order
F_Sum_CITY G_CITY G_CITY
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 18-19
Lesson 18: Enhancing Matrix Reports
.....................................................................................................................................................
Displaying Zeros
Instructor Note
Demonstration:
Value if Null is available either from the summary column Property Inspector or from
the field’s Property Inspector, in the Column section. The quickest and easiest way to
access the Property Inspector is to double-click the cell field in the Paper Design view.
Optional demonstrations:
Show how to add the text TOTALS about the department totals column on the right
side of the output. Add it in the Paper Design, and then show it in the Paper Layout.
Show how to rotate the column values. You cannot rotate fields, so delete the column
field (F_JOB_ID). Use the text tool to create an object in the column repeating frame
and enter &JOB_ID (direct reference to the column value). Now you can rotate this
object to display it on its side and take less room for each column.
......................................................................................................................................................
18-20 Oracle9i Reports Developer: Build Reports
Building a Nested Matrix
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 18-21
Lesson 18: Enhancing Matrix Reports
.....................................................................................................................................................
Summary
......................................................................................................................................................
18-22 Oracle9i Reports Developer: Build Reports
Summary
.....................................................................................................................................................
Summary
Letting the Wizard and Template Work for You
Use the Report Wizard to create your matrix, even if you need to modify it later.
Allowing the Wizard to create the initial Paper Layout saves you a lot of time.
If you make many modifications to your Wizard reports, consider creating or
modifying a template to include object spacing horizontally and vertically, between
frames, fields, and so on. This helps you to select and manipulate the objects in the
Paper Layout.
Note: You can override the default template properties for the Matrix and Matrix with
Group sections of an existing template.
Matrix Structure
The Data Model and Paper Layout of a matrix report contain special features, and
relationships between objects, to reflect the cross product structure of the report.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 18-23
Lesson 18: Enhancing Matrix Reports
.....................................................................................................................................................
Practice 18 Overview
......................................................................................................................................................
18-24 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 18
.....................................................................................................................................................
Introduction
In this practice session, you use an existing matrix report to investigate the different
methods of displaying the cell values and the implications. You use an existing SQL
query to create a nested matrix report. You then add row- and column-level summaries
to the report and display zeros for null values.
If you have time, include the product names instead of the product IDs and rotate the
names.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 18-25
Lesson 18: Enhancing Matrix Reports
.....................................................................................................................................................
......................................................................................................................................................
18-26 Oracle9i Reports Developer: Build Reports
Practice Session: Lesson 18
.....................................................................................................................................................
f Use the Data Model view to create summaries for each month and for the level
month and product.
Property Value
Name SumMonth
Product Order G_MONTH
Function Sum
Source SumTOTAL_VALUE
Reset At G_MONTH
Property Value
Name SumMonthProduct
Product Order G_MONTH G_PRODUCT_ID
Function Sum
Source SumTOTAL_VALUE
Reset At G_PRODUCT_ID
Use the Paper Layout view to create the fields. You must expand the
g
appropriate repeating frame.
h Run the paper layout to test the report.
i Save the report as p18q2.jsp. Do not close it.
3 Continue with the report from the previous exercise.
a Add zeros for null values in the cells.
b Ensure that the report shows only three product columns on each page.
c Format all numeric data to be right aligned.
d Add commas and two decimal places where appropriate.
e Run the paper layout to test the report.
f Save the report as p18q3.jsp and close it.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 18-27
Lesson 18: Enhancing Matrix Reports
.....................................................................................................................................................
......................................................................................................................................................
18-28 Oracle9i Reports Developer: Build Reports
19
................................
Objectives
Instructor Note
Topic Timing
Lecture 50 minutes
Practice 45 minutes
Total 95 minutes
......................................................................................................................................................
19-2 Oracle9i Reports Developer: Build Reports
Overview
.....................................................................................................................................................
Overview
Introduction
This lesson identifies different trigger types and creates conditional trigger code to
control report output. It also explains how to improve productivity and maintenance by
sharing and reusing commonly referenced code. Finally, you will learn about
publishing reports based on database events.
Objectives
After completing this lesson, you should be able to do the following:
• Describe the different types of triggers
• Describe sample uses of the different types of triggers
• Write and reference common code
• Create and reference a PL/SQL library
• Publish a report based on a database event
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-3
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
• Report:
– Five triggers
– Report Triggers node in Object Navigator
• Data Model:
– Formula (column)
– Filter (group)
– Parameter validation
• Layout: Format trigger on most objects
Trigger Code
Boolean:
true
false
Character
Number
Date
......................................................................................................................................................
19-4 Oracle9i Reports Developer: Build Reports
Types of Triggers in Reports
.....................................................................................................................................................
Trigger Code
When you create a trigger such as a report trigger or a PL/SQL formula, the Program
Unit editor supplies a template for the function block, giving the basic syntax that you
require.
You can change the name of the function.
The value that you return must match the return data type in the function declaration.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-5
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
Before
Parameter F
Form
1 2 If readonly=yes 3
F
If > 1 page
After Before Between After
Parameter page1 page2
Report Pages Report
Form
F F
Instructor Note
Report triggers appear in the Object Navigator in the order in which they fire.
......................................................................................................................................................
19-6 Oracle9i Reports Developer: Build Reports
Using Report Triggers
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-7
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
• Query syntax
SELECT CUSTOMER_ID, CUSTOMER_NAME
FROM CUSTOMERS
&p_where_clause
ORDER BY CUSTOMER_NAME
Instructor Note
Stress the improved efficiency of a dynamic WHERE clause, used when users
sometimes require restricted records and sometimes require all records.
Write on whiteboard:
WHERE ID = :P_CUSTOMER OR :P_CUSTOMER IS NULL
Then put a big cross beside this code.
This is what some developers would do to return all customers if the parameter is
NULL, but stress this is not efficient. Ask why not.
The OR clause prevents the Oracle server from using an index, whether or not the user
specifies a value.
The dynamic clause ensures that the WHERE clause allows an index to be used if the
user specifies a value.
Point out that the code returns TRUE in both cases, so this function is transparent to
the user.
......................................................................................................................................................
19-8 Oracle9i Reports Developer: Build Reports
Using Report Triggers
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-9
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
Group Filter
• Restrict records in a group
• Perform PL/SQL for each record
FUNCTION G_empGroupFilter RETURN BOOLEAN IS
BEGIN
IF :department_name = 'Operations' AND
:salary > 5000 THEN
RETURN(my_function);
ELSE
RETURN(TRUE);
END IF;
END;
• PL/SQL filters result in all records being fetched
......................................................................................................................................................
19-10 Oracle9i Reports Developer: Build Reports
Using Data Model Triggers
.....................................................................................................................................................
Example
Use a group filter that calls a function for some records in the G_emp group,
depending on the department in the master group.
1 Open the Property Inspector for the G_emp group.
2 Change Group Filter to PL/SQL.
The PL/SQL Filter property appears.
3 Select the PL/SQL Filter property to open the PL/SQL editor.
4 Enter the code. This filter code must return a boolean value of true or false.
Note: It is more efficient to use a WHERE clause in a query when possible. You
cannot use a WHERE clause in this case, because you want to process all records and
call the function for some.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-11
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
Parameter Validation
• Example: Do not allow report output to be sent
directly to a printer.
FUNCTION DESTYPEValidTrigger RETURN BOOLEAN IS
BEGIN
IF :DESTYPE = 'Printer' THEN
RETURN(FALSE);
ELSE
RETURN(TRUE);
END IF;
END;
Instructor Note
Point out that the values for DESTYPE are case-sensitive; you must enter the value
with an initial capital, otherwise the condition is never true.
......................................................................................................................................................
19-12 Oracle9i Reports Developer: Build Reports
Using Data Model Triggers
.....................................................................................................................................................
Example To prevent report output from being sent directly to a printer, test the value
of the DESTYPE system parameter.
1 Open the Property Inspector for the DESTYPE parameter.
2 Select Validation Trigger to open the PL/SQL editor.
3 Enter the code and make sure that the value Printer has an initial capital.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-13
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
Format triggers:
• Exist on most layout objects
• Can suppress an entire layout section (master
group frame): No records fetched
• Can suppress the display of individual records
(repeating frame): All records fetched
Instructor Note
This is a very brief introduction, to focus attention on the paper layout. The following
pages contain examples of using a format trigger.
However, it is worth making the point that a format trigger on a frame to suppress an
entire layout can prevent data being retrieved, but a format trigger on a repeating
frame to suppress individual records does not.
Remind the students of conditional formatting, discussed earlier, and point out that a
format trigger has been automatically created.
......................................................................................................................................................
19-14 Oracle9i Reports Developer: Build Reports
Using Layout Triggers
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-15
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
Dept: 10
Dept: f_deptno
Name Salary
Name Salary
No employees in
1 this department
Dept: 40
No employees in
this department
......................................................................................................................................................
19-16 Oracle9i Reports Developer: Build Reports
Using Layout Triggers
.....................................................................................................................................................
Example
1 Create a summary column, :count_emp, in the master group that counts the
number of employee records (reset = master group).
2 Create a piece of boilerplate text, “No employees in this department”.
3 Position the text behind the column heading frame.
4 Code a format trigger on the column heading:
function hide_headings return boolean is
begin
if :count_emp = 0 then
return(false);
else
return(true);
end if;
end;
5 Either code the reverse logic in the format trigger of the boilerplate text item
created in step 2 or ensure that the column heading frame has a solid fill.
Note: You should code format triggers at the highest possible level of the paper layout
hierarchy. The format trigger on the column headings frame suppresses all objects
enclosed by the frame. Do not duplicate code unnecessarily by coding the same trigger
on all individual objects in the frame; this can cause increased processing and
maintenance overheads.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-17
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
Employee Details
Employee Details
King 17-JUN-87 24000
f_name f_date f_salary Kochhar 21-SEP-89 17000
De Haan 13-JAN-93
Employee17000
Details
f_name f_date
King 17-JUN-87
Kochhar 21-SEP-89
2 De Haan 13-JAN-93
1 3
Instructor Note
Explain the example using the diagram above.
If you want to demonstrate it, you must modify the code, because there are no
pay_clerks in the EMPLOYEES table. For example, you could test for your own
userid.
......................................................................................................................................................
19-18 Oracle9i Reports Developer: Build Reports
Using Layout Triggers
.....................................................................................................................................................
Example
1 In the layout, create two repeating frames sourced by the same group. One
repeating frame must contain a salary field, the other must not.
Note: You can create two separate default layouts and modify the layout as
required.
2 Place one repeating frame behind the other.
3 Add a format trigger to suppress the top repeating frame (the one that contains the
salary field), or alternatively use conditional formatting:
function pay_clerks_see_this return boolean is
begin
if :user_type = 'PAY_CLERK' then
return(true);
else
return(false);
end if;
end;
Note: User_type can be a column or parameter that is initialized at run time.
4 Either code the reverse logic on the other repeating frame or ensure that the top
repeating frame (containing salary) has a solid fill.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-19
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
Employee Details
Employee Details
King 17-JUN-87 24000 1
f_name f_date f_salary
Kochhar 21-SEP-89 17000
De Haan 13-JAN-93
Employee17000
Details
King 17-JUN-87
Kochhar 21-SEP-89
De Haan 13-JAN-93
......................................................................................................................................................
19-20 Oracle9i Reports Developer: Build Reports
Using Layout Triggers
.....................................................................................................................................................
Requirement: Dynamically Hide Fields Given the same employee details report
as before, hide the salary field without rearranging the other fields in the repeating
frame. The report contains a gap in the layout when the salary field is not displayed.
Example Place the format trigger on the salary field to display it only when payment
clerks run the report. The code is the same as before:
function pay_clerks_see_this return boolean is
begin
if :user_type = 'PAY_CLERK' then
return(true);
else
return(false);
end if;
end;
In this example, you do not need to create any additional layout object or code.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-21
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
1
2
3 4
Instructor Note
Stress that the repeating frame must be variable.
This example uses the modulus SQL function:
IF MOD(:count_column, 3) = 0
Modulus returns the remainder of the first argument divided by the second argument.
Therefore, the modulus is 0 for every third record. When the condition is true, the
extra space is printed.
Mention that the number can be supplied as a parameter.
L19SPACE.RDF is a prebuilt example. Enter a number in the parameter P_SPACE.
Spacing is output after that number of records.
......................................................................................................................................................
19-22 Oracle9i Reports Developer: Build Reports
Using Layout Triggers
.....................................................................................................................................................
Example
1 Create a transparent rectangle inside the repeating frame to increase spacing
conditionally at run time.
2 In the repeating frame Property Inspector, set Vertical Elasticity to Variable.
3 In the Data Model, create a summary column named COUNT_COLUMN that
counts the number of records retrieved (Reset=Report).
4 On the rectangle, create a format trigger that references the summary column, as
shown on the opposite page.
Note: You can vary the number of records in each group dynamically at run time by
creating a parameter.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-23
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
Instructor Note
Most developers make less use of PL/SQL code and libraries in reports than they do in
forms. If students have attended the Oracle9i Forms Developer class, they will be
familiar with this topic.
Demonstration:
Create a report-level program unit. Create a library. Copy the program unit to the
library. Save the library. Attach the library to a report. Remind students that library
program units cannot directly reference Reports variables.
Point out that Reports Builder loads only the library program units that are referenced
in the report.
Remind students that you can also store code in the database as stored procedures and
functions. Warn them that they must not confuse a library that is saved in the database
with database stored procedures; they are not the same.
......................................................................................................................................................
19-24 Oracle9i Reports Developer: Build Reports
Writing Common Code
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-25
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
Event-Based Reporting
Event-Based Reporting
Oracle Advanced
PL/SQL Workflow Queuing
Reports E-mail
Cache Printer
File
......................................................................................................................................................
19-26 Oracle9i Reports Developer: Build Reports
Publish Reports Based on Database Events
.....................................................................................................................................................
Technical Note
Advanced Queuing is the message queuing functionality of the Oracle database.
Oracle Workflow is a tool that manages complex user-based business processes. For
more information refer to the Oracle Technology Network, http://otn.oracle.com.
See Oracle9iAS Reports Services Publishing Reports to the Web manual for more
information on the Event-Driven Publishing.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-27
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
Instructor Note
Oracle9iAS Reports Services is needed for event-based reporting. You cannot run an
event-driven report with Reports Builder.
......................................................................................................................................................
19-28 Oracle9i Reports Developer: Build Reports
Publish Reports Based on Database Events
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-29
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
Summary
......................................................................................................................................................
19-30 Oracle9i Reports Developer: Build Reports
Summary
.....................................................................................................................................................
Summary
Using PL/SQL Triggers
Select the most applicable type of trigger for your requirement.
Report-level triggers fire once for each of the five events during the report execution.
Data Model triggers can affect which records are processed and how they are
processed.
Layout triggers affect the way in which objects are formatted.
Event-Driven Publishing
Use the PL/SQL procedures and functions in the event-driven publishing API to
automatically submit jobs to Oracle9iAS Reports Services when an event occurs in the
database.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-31
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
Practice 19 Overview
......................................................................................................................................................
19-32 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 19
.....................................................................................................................................................
Introduction
In this practice session, you create a format trigger to conditionally flag one of two
paper layouts for the same data. You also conditionally flag some records in a report
by creating and referencing a report-level (local) PL/SQL function. You then move the
code into a new PL/SQL library and alter the reference to use the library function
instead.
If you have time, restrict the number of records processed in a report by creating your
own group filter.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-33
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
c Create a Tabular layout using the following columns from the query
Column
order_id
order_date
order_total
d Create a user parameter, user_type, that has two possible values: Sales
Representative and Sales Clerk.
e Ensure that only the Group Above layout is displayed when the user type is
Sales Representative, and that only the Tabular layout is displayed when the
user type is Sales Clerk.
Hint: As an alternative to coding format triggers, you can also use conditional
formatting.
To test the result, display the USER_TYPE parameter in the margin of the
report.
Make sure that you can enter a parameter value at run time.
f Save the report as p19q1.rdf.
......................................................................................................................................................
19-34 Oracle9i Reports Developer: Build Reports
Practice Session: Lesson 19
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 19-35
Lesson 19: Coding PL/SQL Triggers
.....................................................................................................................................................
......................................................................................................................................................
19-36 Oracle9i Reports Developer: Build Reports
20
................................
Extending Functionality
Using the SRW Package
Lesson 20: Extending Functionality Using the SRW Package
.....................................................................................................................................................
Objectives
Instructor Note
Topic Timing
Lecture 50 minutes
Practice 45 minutes
Total 95 minutes
......................................................................................................................................................
20-2 Oracle9i Reports Developer: Build Reports
Overview
.....................................................................................................................................................
Overview
Introduction
This lesson provides examples of the contents and use of the Reports Builder built-in
package. The package contains program units that you can reference in your
PL/SQL code.
Objectives
After completing this lesson, you should be able to do the following:
• Describe the contents of the Reports Builder built-in package
• Output messages at run time
• Execute a second report from within another report
• Create and populate temporary tables within a report
• Modify visual attributes dynamically at run time
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 20-3
Lesson 20: Extending Functionality Using the SRW Package
.....................................................................................................................................................
SRW.SET_BOOKMARK SRW.DO_SQL
SRW.SET_FONT_STYLE SRW.RUN_REPORT
SRW.SET_MAXROW SRW.TRACE_START
SRW.MESSAGE SRW.PROGRAM_ABORT
Instructor Note
This can be a very long and very boring lesson potentially, or it can be interesting and
entertaining (format masks).
Try to keep explanations of code clear but very concise; outline some procedures and
concentrate on a few. Where possible, have prebuilt demonstrations and show most of
the code rather than writing it.
Mention that all parts of the package must be prefixed by the package name, SRW. (If
asked, the acronym SRW stands for SQL Report Writer.) Also point out
SRW.PROGRAM_ABORT. You can raise this packaged exception to stop report
execution at any stage.
The diagram shows only some of the package. Not all the examples above are
discussed in this lesson. For further details, investigate the Help system in the same
way that you encourage your students.
......................................................................................................................................................
20-4 Oracle9i Reports Developer: Build Reports
Contents of the Reports Builder Built-in Package
.....................................................................................................................................................
Rules
• You can only call the contents of the SRW package from within Reports Builder.
Other tools, such as Forms Builder, do not recognize this package.
• You must always reference an SRW procedure, function, or exception by
preceding it with the package name, SRW ; for example, SRW.MESSAGE or
SRW.DO_SQL.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 20-5
Lesson 20: Extending Functionality Using the SRW Package
.....................................................................................................................................................
Outputting Messages
• Warning:
WHEN <exception> THEN
SRW.MESSAGE (999, ‘Warning: report continues’);
• Error:
WHEN <exception> THEN
SRW.MESSAGE (999, ‘Warning: report terminated’);
RAISE SRW.PROGRAM_ABORT;
• Exceptions:
– SRW.INTEGER_ERROR
– SRW.NULL_ARGUMENTS
Instructor Note
If you have not already mentioned it during a previous demonstration, point out that
SRW.MESSAGE does not override any Reports default messages.
The difference between the warning and the error is that, for the error, you terminate
the report by raising SRW.PROGRAM_ABORT.
Compare the difference from the MESSAGE built-in in Forms Builder (if students are
familiar with Forms Builder): SRW.MESSAGE does not override the default Reports
Builder error messages in the way that ON-ERROR and ON-MESSAGE triggers do in
Forms Builder. At run time, you see both user-defined and Reports Builder default
messages, where applicable.
......................................................................................................................................................
20-6 Oracle9i Reports Developer: Build Reports
Outputting Messages
.....................................................................................................................................................
Outputting Messages
Introduction
The SRW.MESSAGE packaged procedure displays a message with a code and text
string, which you specify. The message is displayed in the following format:
MSG-code: text
The message is displayed in a small dialog box. The user must acknowledge the
message before continuing.
Is It a Warning or an Error?
SRW.MESSAGE does not implicitly terminate the report execution. You can choose to
issue a warning message that enables the report to continue execution after the user
accepts the message.
To force the report to terminate after outputting the message, raise the exception
SRW.PROGRAM_ABORT.
Note: You cannot suppress or replace the default message that Reports Builder gives if
you abort a report. Your own error message augments the existing messages.
Causes of Exceptions
Exception Name Cause
SRW.INTEGER_ERROR You entered a code that is not a numeric integer.
SRW.NULL_ARGUMENTS You omitted the code number or text message or
both.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 20-7
Lesson 20: Extending Functionality Using the SRW Package
.....................................................................................................................................................
Executing a Report
1 KING.LIS 2
xxx xxxxxxx
KING xxx xxxxxxx
KOCHHAR
KOCHHAR.LIS
DE HAAN
yyy yyyyyyy
yyy yyyyyyy
DE HAAN.LIS
zzz zzzzzzz
zzz zzzzzzz
SRW.RUN_REPORT
Instructor Note
Mention that you can code this nested example on a group filter, which processes each
manager record, and can enable you to send each report to a different filename. Move
quickly to the next slide, which shows some syntax.
......................................................................................................................................................
20-8 Oracle9i Reports Developer: Build Reports
Executing a Nested Report
.....................................................................................................................................................
Example
Run a report called MANAGERS that retrieves the employee record for each manager.
Call the EMPS report (for example, from a group filter). EMPS retrieves the employee
records of all employees managed by the current manager only.
Sample code to implement this example appears on the following page.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 20-9
Lesson 20: Extending Functionality Using the SRW Package
.....................................................................................................................................................
Executing a Report
• Example:
SRW.RUN_REPORT
('Report=EMPS
DESTYPE=FILE
DESNAME='||:LAST_NAME||'.LIS
BATCH=YES
MGRNO='||TO_CHAR(:MANAGER_ID));
• Exceptions:
– SRW.RUN_REPORT_FAILURE
– SRW.RUN_REPORT_BATCHNO
• Function: SRW.GETERR_RUN
Instructor Note
Talk through the SRW.RUN_REPORT syntax, which you can code in the group filter.
Point out that you restrict the employees to those of the current manager by using a
parameter.
You pass the manager’s last name as a parameter to supply a unique filename for each
report.
Mention that you should use TO_CHAR to convert the MANAGER_ID to character
type to reference it in the character string argument. However, although PL/SQL often
successfully converts mismatched datatypes, you should still advise students to use the
TO_CHAR function for efficiency and also to avoid upgrade problems, because
Oracle does not guarantee to support this kind of internal functionality in future
releases.
Note: You cannot run a report on Reports Services when using SRW.RUN_REPORT.
......................................................................................................................................................
20-10 Oracle9i Reports Developer: Build Reports
Executing a Nested Report
.....................................................................................................................................................
Note: Use LAST_NAME to create the output filename for each manager; use
MANAGER_ID to restrict the EMPS query.
Causes of Exceptions
Reports Builder raises a specific exception that applies to the SRW.RUN_REPORT
procedure in two cases:
Exception Name Causes
SRW.RUN_REPORT_FAILURE Detail report does not exist.
Detail report failed during execution.
SRW.RUN_REPORT_BATCHNO BATCH parameter is used inconsistently:
master report running with BATCH=YES,
called a detail report with BATCH=NO
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 20-11
Lesson 20: Extending Functionality Using the SRW Package
.....................................................................................................................................................
Restricting Data
Q_EMP
EMPLOYEE_ID LAST_NAME
100 KING
G_EMP 101 KOCHHAR
102 DE HAAN
EMPLOYEE_ID
LAST_NAME
Instructor Note
Ask the students where to set the Maximum Rows property to restrict the rows
fetched. Answer: In the Property Inspector for a query.
SRW.SET_MAXROW provides the same function programmatically.
Stress the warning on the opposite page:
SRW.SET_MAXROW must be set in the Before Report trigger. If you call it after the
Before Report trigger, Reports Builder raises the SRW.MAXROW_UNSET
exception.
If you handle SRW.MAXROW_INERR, always raise SRW.PROGRAM_ABORT.
......................................................................................................................................................
20-12 Oracle9i Reports Developer: Build Reports
Restricting Data
.....................................................................................................................................................
Restricting Data
Introduction
Use SRW.SET_MAXROW to restrict the maximum number of records you want to
retrieve for a specified query. Reports Builder uses only the retrieved rows of the
query in subsequent processing, such as computations and summaries.
Suppressing a Query
At run time, you can choose not to display any data from a query by setting the
maximum number of records to zero. This prevents Reports Builder from retrieving
any records from the database.
Example
Below is a function to display data for the Q_emp query only if a value of one or more
is entered in a run-time parameter called HOW_MANY:
FUNCTION FETCHIT RETURN BOOLEAN IS
BEGIN
IF :HOW_MANY >= 1 THEN
SRW.SET_MAXROW ( 'Q_emp', :how_many);
ELSE
SRW.SET_MAXROW('Q_emp', 0);
END IF;
RETURN(TRUE);
EXCEPTION
WHEN SRW.MAXROW_UNSET THEN
SRW.MESSAGE (100,
'Data was fetched before SRW.MAXROW was called');
RAISE SRW.PROGRAM_ABORT;
WHEN SRW.MAXROW_INERR THEN
SRW.MESSAGE(200, 'Contact someone clever!' );
RAISE SRW.PROGRAM_ABORT;
END;
You must set SRW.SET_MAXROW in the Before Report trigger; that is, after the
query has been parsed but before it has been executed. If you call it after the Before
Report trigger, Reports Builder raises the SRW.MAXROW_UNSET exception.
If you handle SRW.MAXROW_INERR, always raise SRW.PROGRAM_ABORT,
because your report has an internal problem and you cannot guarantee the outcome.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 20-13
Lesson 20: Extending Functionality Using the SRW Package
.....................................................................................................................................................
Initializing Fields
FUNCTION F_LOGICAL_PAGEFormatTrigger
RETURN BOOLEAN IS
my_page number;
BEGIN
SRW.GET_PAGE_NUM(my_page); 2
SRW.SET_FIELD_NUM(0,my_page+3);
RETURN(TRUE);
END;
......................................................................................................................................................
20-14 Oracle9i Reports Developer: Build Reports
Initializing Fields
.....................................................................................................................................................
Initializing Fields
You can dynamically initialize the value in a layout field by using the relevant
SET_FIELD packaged procedure; for example:
• SRW.SET_FIELD_CHAR (0, 'a text string')
• SRW.SET_FIELD_NUM (0, 1234)
• SRW.SET_FIELD_DATE (0, '01-JAN-2002')
The first argument is always 0 (zero); you can set the value of the current object.
These procedures are relevant only in the format trigger of a field of the correct type. If
you use a procedure that conflicts with the field type, it has no effect in the report;
Reports Builder ignores the code and does not raise an error.
Example Create a function to display the logical page number plus three in a field
called F_NEWPAGE.
Because the logical page number variable is available only in the report layout, not in
the Data Model, you cannot calculate the value in a data column. Therefore, you use a
paper layout field to get the current page number and output a new number by
initializing the same field.
Make use of a packaged procedure called SRW.GET_PAGE_NUM to retrieve the
current logical page number into a local PL/SQL variable, as in the format trigger code
opposite.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 20-15
Lesson 20: Extending Functionality Using the SRW Package
.....................................................................................................................................................
• Example:
SRW.DO_SQL('CREATE TABLE SRW_LOG
(RPT_NAME VARCHAR2(40),
REC_NUM NUMBER,
MSG_TEXT VARCHAR2(80))' );
• Exception: SRW.DO_SQL_FAILURE
Instructor Note
Stress that you can usually code DML statements directly as a PL/SQL statement in
your trigger. It is inefficient to use SRW.DO_SQL for DML statements unless it is
necessary, as in the example above where the table does not exist until run time. In this
case, if you code the INSERT statement directly as PL/SQL, you cause a validation
error: “Table or view does not exist.”
Mention that if you want to create a temporary table and use it in a query in the same
report, you must create the table before the Before Report trigger.
Note that DML statements are not valid in layout format triggers.
......................................................................................................................................................
20-16 Oracle9i Reports Developer: Build Reports
Performing DDL Statements
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 20-17
Lesson 20: Extending Functionality Using the SRW Package
.....................................................................................................................................................
Borderwidth
Tuesday, January 2002 Fill pattern
Format mask
Define a bookmark
Car Policy
......................................................................................................................................................
20-18 Oracle9i Reports Developer: Build Reports
Setting Format Attributes
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 20-19
Lesson 20: Extending Functionality Using the SRW Package
.....................................................................................................................................................
• Visual attributes:
SRW.SET_FILL_PATTERN('solid');
SRW.SET_BORDER_WIDTH(250);
SRW.SET_FORMAT_MASK('Day, Month yyyy ' );
• Defining a bookmark:
SRW.SET_BOOKMARK('Car Policy');
Instructor Note
The slide shows only a few examples. There is a complete code example on the next
page. However, stress that many more examples are documented in the online Help
system. Some attributes are ignored for character mode.
Demonstration: l20mask.rdf.
This is a tabular report. Show the mask that is coded at report level, program unit:
SAL_MASK. Point out the different attributes and explain their purposes.
Show the format trigger on F_SALARY that calls the mask in a conditional piece of
code depending on the value of SALARY.
Stress that you must include the statement return(true); at the end of the
function.
Run the paper layout.
......................................................................................................................................................
20-20 Oracle9i Reports Developer: Build Reports
Setting Format Attributes
.....................................................................................................................................................
Example
Conditionally set the following attributes if salary is greater than $12000:
Attribute Value
Background fill color Blue
Fill pattern Sandpaper
Font style Italic
Font face Helvetica
Font weight Extra bold
Text color White
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 20-21
Lesson 20: Extending Functionality Using the SRW Package
.....................................................................................................................................................
…
<rw:field id="F_SALARY" src="SALARY“. . .
formatTrigger="mystyles">
F_SALARY
</rw:field>
…
Instructor Note
The H in SRW.RIGHT_HJUST is for horizontal justification.
......................................................................................................................................................
20-22 Oracle9i Reports Developer: Build Reports
Setting Format Attributes
.....................................................................................................................................................
Example
In the example on the opposite page, the formatTrigger attribute contains the name of
the function mystyles. When executed, mystyles will set the following attributes on
the salary field:
Attribute Value
Justification Right
Text color Red
Font weight Bold
Font style Italic
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 20-23
Lesson 20: Extending Functionality Using the SRW Package
.....................................................................................................................................................
Summary
......................................................................................................................................................
20-24 Oracle9i Reports Developer: Build Reports
Summary
.....................................................................................................................................................
Summary
• The SRW package contains procedures, functions, and exceptions.
Remember that you can raise the exception SRW.PROGRAM_ABORT in your
PL/SQL code to stop report processing at any time.
• The SRW package provides a number of features, including:
– Executing a second report from within a report process, using
SRW.RUN_REPORT
– Support for DDL statements, using SRW.DO_SQL, to enable you to create or
drop temporary tables from PL/SQL code in a report
– Conditional formatting and display using SRW.SET_<attributes>
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 20-25
Lesson 20: Extending Functionality Using the SRW Package
.....................................................................................................................................................
Practice 20 Overview
......................................................................................................................................................
20-26 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 20
.....................................................................................................................................................
Introduction
In this practice session, you highlight values based on conditional PL/SQL code.
You build a master report that enables you to call a detail report and generate a
separate PDF file for each detail report.
If you have time, you add report-level triggers to an existing report to write
messages to a temporary table at various stages of report execution.
• Write PL/SQL functions as local PL/SQL (report-level), and reference the code in
a condition within the relevant object trigger in the report.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 20-27
Lesson 20: Extending Functionality Using the SRW Package
.....................................................................................................................................................
......................................................................................................................................................
20-28 Oracle9i Reports Developer: Build Reports
Practice Session: Lesson 20
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 20-29
Lesson 20: Extending Functionality Using the SRW Package
.....................................................................................................................................................
b The same trigger should also insert the current date, userid, and “Starting
Report” into this table.
INSERT INTO RUNREPORT
(DATE_RUN, USER_RUN, COMMENTS)
VALUES (SYSDATE, USER, ' Starting Report')
Hint: Think about how you code the single quotes.
c Compile the PL/SQL code and close the window.
d Save the report as p20q4.jsp.
e Run the paper layout.
f Using SQL*Plus, verify that your table exists and was populated successfully.
g Log on to SQL*Plus (in Microsoft Windows, select the SQL*Plus icon in the
Oracle group) using the same userid as you used for Reports.
h Display all records in the RUNREPORT table.
SQL> col comments format a40
SQL> SELECT * FROM RUNREPORT;
i Try running the report more than once. When you run the report a second time,
the table already exists and Reports Builder raises an exception. Make the
necessary change to your code so that the report runs even when the table
exists
j Write a trigger that inserts a record with the comment “Printing another page”
whenever it begins a new page.
k Write a trigger that inserts a record with the comment “Report completed”
when the report finishes.
l Save the report as s20q4l.jsp. Generate the output to a PDF file. Verify
the results in SQL*Plus.
......................................................................................................................................................
20-30 Oracle9i Reports Developer: Build Reports
21
................................
Objectives
Instructor Note
Topic Timing
Lecture 30 minutes
Practice 15 minutes
Total 45 minutes
......................................................................................................................................................
21-2 Oracle9i Reports Developer: Build Reports
Overview
.....................................................................................................................................................
Overview
Introduction
When you are ready to publish your reports, all the Web server and application server
tools you need are available in the Oracle9i Application Server (Oracle9iAS).
In this lesson, you will learn about the architecture of relevant Oracle9iAS
components in combination with its reports publishing component, Oracle9iAS
Reports Services. You learn how to make report requests, and about the options
available for managing and monitoring Reports Services.
Objectives
After completing this lesson, you should be able to do the following:
• Describe the Oracle9iAS Reports Services architecture
• Distinguish between the JSP runtime architecture and the servlet runtime
architecture
• Define the different methods of invoking a report
• List the options for managing and monitoring Reports Services
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-3
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
......................................................................................................................................................
21-4 Oracle9i Reports Developer: Build Reports
Why Use Oracle9iAS Reports Services?
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-5
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
......................................................................................................................................................
21-6 Oracle9i Reports Developer: Build Reports
Why Use Oracle9iAS Reports Services?
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-7
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
Oracle9iAS Components
Instructor Note
Note that when referring to a multi-tier architecture, the term tier refers to the logical
location of the components that comprise the Oracle9iAS Reports Services
architecture. Each of the tiers, though, could reside on the same or different machines.
......................................................................................................................................................
21-8 Oracle9i Reports Developer: Build Reports
Oracle9iAS Reports Services Architecture
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-9
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
......................................................................................................................................................
21-10 Oracle9i Reports Developer: Build Reports
Oracle9iAS Reports Services Architecture
.....................................................................................................................................................
Technical Note
For more information on data source single sign-on, see the Oracle9iAS Reports
Services, Publishing Reports to the Web manual.
For information about the requirements and procedures required for setting up SSO-
related components, such as the Oracle Internet Directory, see the Oracle Internet
Directory Administrator's Guide and the Oracle HTTP Server Administrator's Guide
on the Oracle9iAS documentation CD and on the Oracle Technology Network (http://
otn.oracle.com).
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-11
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
HTTP
CORBA/IIOP CORBA/IIOP
OID
Reports
Oracle9iAS
Reports Services Engine
PDS
CORBA/IIOP
rept.rdf Reports
rept.jsp Engine
PDS
......................................................................................................................................................
21-12 Oracle9i Reports Developer: Build Reports
Oracle9iAS Reports Services Runtime Architecture
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-13
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
URL syntax:
http://vesuvius.world.com:80/reports/rwservlet?
report=emp_dept.rdf&desformat=html&destype=cache&
server=repsrv1&dept_param=10
Technical Note
For information on testing reports deployment without installing Oracle9iAS, refer to
the Oracle9i Reports Technical Note How to Execute Reports Services from 9iDS on
the Oracle Technology Network (http://otn.oracle.com).
......................................................................................................................................................
21-14 Oracle9i Reports Developer: Build Reports
Making a Request to Run a Report
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-15
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
• SERVER = <server_name>
• MODULE|REPORT = <runfile>
• DESTYPE = FILE, PRINTER, MAIL, CACHE,
LOCALFILE, SYSOUT,ORACLEPORTAL
• DESNAME = <desname>
• DESFORMAT = PDF, HTML, HTMLCSS, RTF,
DELIMITED, XML
......................................................................................................................................................
21-16 Oracle9i Reports Developer: Build Reports
Making a Request to Run a Report
.....................................................................................................................................................
Example
1 Invoke the command line. In Windows NT, Select Start > Run.
2 Enter the command string, for example:
RWCLIENT.EXE SERVER=server1 REPORT=my_rep.rdf DESTYPE=FILE
DESFORMAT=PDF DESNAME=my_rep_output.pdf
This command references an executable file that parses and transfers the command
line to the specified Oracle9iAS Reports server. The report is run immediately.
Technical Note
For a complete list of command line arguments, refer to Oracle9iAS Reports Services,
Publishing Reports to the Web documentation.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-17
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
RWCLIENT...
SCHEDULE=monthly_last_weekday_from_17:00_Jan_22,_2002_
retry_3_after_1_hour
TIME
......................................................................................................................................................
21-18 Oracle9i Reports Developer: Build Reports
Making a Request to Run a Report
.....................................................................................................................................................
Syntax
The full syntax of the SCHEDULE parameter is:, [SCHEDULE=] string,
where the string is, [FREQ from] TIME [retry {n} + after LEN]
FREQ = hourly|daily|weekly|monthly|{every
LEN|DAYREPEAT}|{last {WEEKDAYS| weekday | weekend} before
{n}+}
TIME = CLOCK [DATE] [INCR]
CLOCK = <hh:mm>
DATE=<calendar date>
INCR = {+LEN} | {next SUFFIX}
LEN = {n} * SUFFIX
SUFFIX = <time, date, FREQ>
Example
SCHEDULE=hourly_from_09:00am_Mar_01,_2002
SCHEDULE=last_weekday_from_17:00_Oct_23,_2001_retry_3_after_
1_hour
Note: This syntax is necessary only if you want to control your report jobs from the
command line. You can also specify the scheduled time and frequency of a report
when you define a new job in the easy-to-use Queue Manager screen, which you learn
about later in this lesson.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-19
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
Reports Caching
......................................................................................................................................................
21-20 Oracle9i Reports Developer: Build Reports
Making a Request to Run a Report
.....................................................................................................................................................
Reports Caching
Include the TOLERANCE parameter in your command line to set the maximum
acceptable time (in minutes) for reusing a report's cached output when a duplicate job
is detected. Setting the time tolerance on a report reduces the processing time when
duplicate jobs are found.
Setting TOLERANCE=60 means that Reports Services can detect a duplicate report
request from the same userid and return the existing cached output to the client
without rerunning the report if the existing report output is 60 minutes old or less.
Setting TOLERANCE=0 forces the report to rerun for each request. This is the default
behavior.
Cached Output
Reports Services uses a parameter CACHEDIR to determine where to place the
cached output.
The default directory is <oracle_home>\reports\cache.
Technical Note
For more information on Oracle9iAS Reports Services, see the eClass Oracle9iAS
Reports Services: Deploy Internet Reports. Also refer to Oracle9iAS Reports Services,
Publishing Reports to the Web documentation.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-21
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
......................................................................................................................................................
21-22 Oracle9i Reports Developer: Build Reports
Managing and Monitoring Oracle9iAS Reports Services
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-23
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
......................................................................................................................................................
21-24 Oracle9i Reports Developer: Build Reports
Managing and Monitoring Oracle9iAS Reports Services
.....................................................................................................................................................
Administrator Privilege
In the <servername>.ora file, the first line gives an encrypted password,
IDENTIFIER=.
You can set this password the first time that you start the Reports Services. At the
login prompt, select any username and password to assign as Administrator.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-25
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
Queue Manager
Past jobs
Current jobs
Scheduled jobs
Queue Manager
All my jobs
All jobs
Refresh
Instructor Note
To delete a queued job, there is a menu option, Job > Remove.
......................................................................................................................................................
21-26 Oracle9i Reports Developer: Build Reports
Managing and Monitoring Oracle9iAS Reports Services
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-27
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
RSVR1
Queue
Manager
RSVR2
......................................................................................................................................................
21-28 Oracle9i Reports Developer: Build Reports
Managing and Monitoring Oracle9iAS Reports Services
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-29
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
Summary
......................................................................................................................................................
21-30 Oracle9i Reports Developer: Build Reports
Summary
.....................................................................................................................................................
Summary
• Oracle9iAS Reports Services provides a flexible architecture for the distribution
and automated management of report generation engines on the same server and
across multiple servers, in both Web-based and non Web-based environments.
• Run a report using several methods:
– RWCLIENT
– URL syntax
– Oracle9iAS Portal
– SRW.RUN_REPORT
– Event-Driven Publishing API
• Oracle9iAS Reports Services Runtime Architecture
– Run Web layouts using the JSP runtime architecture.
– Run paper layouts using the Servlet runtime architecture.
• Use Oracle Enterprise Manager to monitor Oracle9iAS Reports Services.
• Use Queue Manager to view and schedule reports.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-31
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
Practice 21 Overview
......................................................................................................................................................
21-32 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 21
.....................................................................................................................................................
Introduction
You publish your reports using Oracle9iAS Reports Services in the Oracle9i
Application Server. This practice session consists of paper-based questions to test your
understanding of Oracle9iAS Reports Services.
Instructor Note
Because Oracle9iAS is not part of the classroom setup environment, students will not
be able to actually deploy reports on the Web. However, encourage students to work
with the scenario in the practice and become familiar with the structure of the URL for
deploying reports on the Web, as well as creating entries in the key map file to
simplify the command line arguments.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 21-33
Lesson 21: Maximizing Performance Using Oracle9iAS Reports Services
.....................................................................................................................................................
The report should be executed by repserver4, and the output should be in HTML
format and go directly to Oracle9iAS Reports cache. Access the data by
connecting to the Sales database using a username of scott, a password of
tiger, and salesdb as the database connect string. Construct the URL to run
the report using the Reports servlet.
2 So that you do not have to enter such a long URL each time you run the
SalesByDept report, create a key entry for the key map file.
a Name the key sales. You can also restrict the data in the report by passing it
a value for the runtime parameter p_deptno. Be sure to include the parameter in
the map file entry.
b Reconstruct the URL to run the report using the key. Pass in a value of 70 for
p_deptno.
3 In addition to using a URL, what are the other methods for requesting a report?
4 What is the JSP runtime architecture used for?
5 Which two facilities can be used to monitor Oracle9iAS Reports Services?
......................................................................................................................................................
21-34 Oracle9i Reports Developer: Build Reports
22
................................
Building Reports:
Efficiency Guidelines
Lesson 22: Building Reports: Efficiency Guidelines
.....................................................................................................................................................
Objectives
Instructor Note
Topic Timing
Lecture 40 minutes
Practice 15 minutes
Total 55 minutes
......................................................................................................................................................
22-2 Oracle9i Reports Developer: Build Reports
Overview
.....................................................................................................................................................
Overview
Introduction
A report does not run in a vacuum. It is dependent on the underlying hardware,
software, and network connection. Because of this complex interrelationship,
performance is always an issue. The second part of this lesson focuses on performance
in the run-time environment and gives you a number of performance tips. You should
also realize that Report applications are portable across multiple platforms and
multiple languages. You can reduce cross-platform development effort by planning for
platform-specific features or restrictions. In this lesson, you also learn how to build
reports to run on various platforms, and in different environments and languages.
Objectives
After completing this lesson, you should be able to do the following:
• Describe the various areas to investigate to improve performance
• Use the performance measuring tools
• Describe the facilities available for building reports to run in other languages
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 22-3
Lesson 22: Building Reports: Efficiency Guidelines
.....................................................................................................................................................
Tuning Reports
• No absolute rules
• Investigate specific areas:
– Data Model
– Paper Layout
– Web Layout and JSP report definitions
– Run-time arguments
Instructor Note
Explain the Trace option. Ask the students what was time-consuming in the profile
output on the opposite page. Answer: Formatting and laying out the data rather than
querying and fetching.
......................................................................................................................................................
22-4 Oracle9i Reports Developer: Build Reports
Tuning Oracle9i Reports
.....................................................................................................................................................
The Reports Trace Option The Reports Trace option produces a file that describes
the series of steps completed during the execution of the report. You have the option to
log all events or only a subset of events such as SQL execution or breakpoints. The
trace file can provide very useful information for performance evaluation, and also
tells you what executed when.
Tracing can be set for various methods of report execution, for both RDF and JSP
report definitions containing SQL and non SQL data sources, such as the XML and
Text pluggable data sources.
To set the Trace option, use the TRACEFILE=<filename> command line argument
when running the report, or from the main menu select Program > Tracing.
Typical profile output is shown below:
Reports Profiler Statistics
TOTAL ELAPSED Time: 29.00 seconds
Reports Time: 24.00 seconds (82.75% of TOTAL)
ORACLE Time: 5.00 seconds (17.24% of TOTAL
UPI: 1.00 seconds
SQL: 4.00 seconds
In this profile output, you see the execution time (total elapsed time) for the report, the
amount of time spent formatting the retrieved data (Reports time), and the amount of
time spent waiting for the data to be retrieved (Oracle time), comprised of time spent
establishing the database connection, parsing and executing the SQL statement (UPI
time), and the time spent fetching the data and executing SRW.DO_SQL() statements,
EXEC_SQL statements, PL/SQL cursors, and so forth (SQL time).
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 22-5
Lesson 22: Building Reports: Efficiency Guidelines
.....................................................................................................................................................
Performance Measurement
......................................................................................................................................................
22-6 Oracle9i Reports Developer: Build Reports
Tuning Oracle9i Reports
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 22-7
Lesson 22: Building Reports: Efficiency Guidelines
.....................................................................................................................................................
......................................................................................................................................................
22-8 Oracle9i Reports Developer: Build Reports
Tuning Oracle9i Reports
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 22-9
Lesson 22: Building Reports: Efficiency Guidelines
.....................................................................................................................................................
......................................................................................................................................................
22-10 Oracle9i Reports Developer: Build Reports
Tuning Oracle9i Reports
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 22-11
Lesson 22: Building Reports: Efficiency Guidelines
.....................................................................................................................................................
• Frames
• Object size
• Format triggers
• Fetching ahead
• Bursting and distribution
......................................................................................................................................................
22-12 Oracle9i Reports Developer: Build Reports
Tuning Oracle9i Reports
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 22-13
Lesson 22: Building Reports: Efficiency Guidelines
.....................................................................................................................................................
• Frames
• Object size
• Format triggers
• Fetching ahead
• Bursting and distribution
......................................................................................................................................................
22-14 Oracle9i Reports Developer: Build Reports
Tuning Oracle9i Reports
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 22-15
Lesson 22: Building Reports: Efficiency Guidelines
.....................................................................................................................................................
• RUNDEBUG=NO
• Array processing
• LONGCHUNK
• PARAMFORM
• Batch processing
......................................................................................................................................................
22-16 Oracle9i Reports Developer: Build Reports
Tuning Oracle9i Reports
.....................................................................................................................................................
Technical Note
For more information on tuning your reports, see the whitepaper Tuning Oracle9i
Reports on the Oracle Technology Network (http://otn.oracle.com).
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 22-17
Lesson 22: Building Reports: Efficiency Guidelines
.....................................................................................................................................................
Instructor Note
Mention the different environments briefly.
Explain the MODE parameter.
......................................................................................................................................................
22-18 Oracle9i Reports Developer: Build Reports
Different Development and Run-Time Environments
.....................................................................................................................................................
Bitmapped Environment
This environment has a unit of pixel and typically supports a mouse. Interaction with
the host computer is continuous.
The bitmapped Designer allows you, as a developer, to take advantage of the graphical
user interface.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 22-19
Lesson 22: Building Reports: Efficiency Guidelines
.....................................................................................................................................................
Instructor Note
uifont.ali is in the Windows installation directory
<oracle_home>\tools\common90.
......................................................................................................................................................
22-20 Oracle9i Reports Developer: Build Reports
Developing Reports to Run in Different GUIs
.....................................................................................................................................................
Example
In the uifont.ali file on Microsoft Windows, map Motif and Mac fonts to
Microsoft Windows:
/* Motif fonts */
lucidatypewriter= "Courier New"
lucidabright= "Times New Roman"
fixed = "Courier New"
/* Mac fonts */
"Avant Garde"= "Arial"
"New York"= "Times New Roman"
In the uifont.ali file on UNIX (motif), map Microsoft Windows fonts to Motif:
/* Microsoft Windows fonts */
"Courier New" = lucidatypewriter
"Times New Roman"= lucidabright
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 22-21
Lesson 22: Building Reports: Efficiency Guidelines
.....................................................................................................................................................
• NLS_LANG
• DEVELOPER_NLS_LANG, USER_NLS_LANG
NLS_LANG=French_France.WE8DEC
Unicode:
NLS_LANG=<lang>_<territory>.UTF8
Instructor Note
Recommend that students use the same language and territory settings on both the
client and the server. On the server, use the ALTER SESSION command to change
parameters NLS_LANGUAGE, and NLS_TERRITORY.
......................................................................................................................................................
22-22 Oracle9i Reports Developer: Build Reports
Building Reports to Run in Different Languages
.....................................................................................................................................................
Example NLS_LANG=French_France.WE8DEC
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 22-23
Lesson 22: Building Reports: Efficiency Guidelines
.....................................................................................................................................................
Translating an Application
......................................................................................................................................................
22-24 Oracle9i Reports Developer: Build Reports
Building Reports to Run in Different Languages
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 22-25
Lesson 22: Building Reports: Efficiency Guidelines
.....................................................................................................................................................
Summary
......................................................................................................................................................
22-26 Oracle9i Reports Developer: Build Reports
Summary
.....................................................................................................................................................
Summary
• Analyze the performance of your reports using the Trace option in Oracle9i
Reports, as well as the SQL trace facility in the database. Tune reports by
optimizing SQL, minimizing calls to the database, and minimizing the amount of
unnecessary format processing required for the layout of returned data.
• Using Oracle’s translation tool, TranslationHub, the NLS parameters, and various
features in Oracle9i Reports, you can build multilingual report applications.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 22-27
Lesson 22: Building Reports: Efficiency Guidelines
.....................................................................................................................................................
Practice 22 Overview
......................................................................................................................................................
22-28 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 22
.....................................................................................................................................................
Introduction
Report performance is always an issue. Reports Builder offers a few tools that allow
you to measure performance. In this practice you will use them and interpret the
results.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports 22-29
Lesson 22: Building Reports: Efficiency Guidelines
.....................................................................................................................................................
......................................................................................................................................................
22-30 Oracle9i Reports Developer: Build Reports
A
................................
Solutions
Appendix A: Solutions
.....................................................................................................................................................
Instructor Note
If your setup environment uses Reports Builder 9.0.2, you need to be aware of known
issues with that release, as they may affect instructor demonsrations and student
practices.
• Query Builder: You cannot open tables containing user-defined objects in Query
Builder because Query Builder does not recognize these object types. These tables
include CUSTOMERS, OC_CORPORATE_CUSTOMERS, OC_CUSTOMERS,
OC_INVENTORIES, OC_ORDERS, OC_PRODUCT_INFORMATION,
PRODUCT_INFORMATION, PRODUCTS, and WAREHOUSES. To create a
report with one of these tables, you have to enter the query directly.
• Query Builder: Using the Sort option causes Reports Builder to crash. Refer to bug
#2352728 in the bug database (http://bug.us.oracle.com) for more information.
• Report Wizard: If you create a report using an object column (e.g.,
CUST_ADDRESS in the CUSTOMERS table) and then reenter the Wizard to
make modifications to the report or the layout, the selections you initially made for
that object column are not retained. Refer to bug #2294059 in the bug database for
more information.
• Templates: If you open one of the predefined templates in Reports Builder and
save it as another name, you receive “REP-69: Internal error”. Note, however, the
template is saved correctly under that new name. Refer to bug #2353764 in the bug
database for more information.
• Creating Columns: Suppose you create a report using the Report Wizard and then
manually create columns in the Data Model view of the Report Editor. In order to
display the new columns, you reenter the Wizard to update the layout. Reentering
the Wizard destroys the data model and you will receive several error messages
(e.g., “invalid reset group”) when you finish the Wizard and the paper layout
attempts to run. Refer to bug #2288263 in the bug database for more information.
• Matrix Reports: If you create a matrix with group report and save it as a JSP, you
will get an error: “ID attribute of rw:field tag is not unique”. Refer to bug
#2310757 in the bug database for more information.
......................................................................................................................................................
A-2 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 2
.....................................................................................................................................................
Introduction
This practice session consists of a combination of practical and paper-based
questions.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-3
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-4 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 2
.....................................................................................................................................................
cClose the Paper Design view. From the File menu, select Print > Preview. In
the Previewer window, experiment with the horizontal and vertical split screen
features.
Select File > Print Preview. To split the Previewer horizontally: Select the
small gray area at the top of the right scroll bar. Press the left mouse
button down and drag the gray area. As you do this, you see that a thick
dotted line is dragged down the Previewer. Depress the left mouse button
when you have reached the desired split point. Now you have two
windows, which work independently from each other.
Move the split bar back to its original position.
To split the Previewer vertically: Select the small gray area at the left of
the horizontal scroll bar at the bottom of the window. Press the left mouse
button down and drag the gray area. As you do this, you see that a thick
dotted line is dragged right across the Previewer. Depress the left mouse
button when you have reached the desired split point. Now you have two
windows, which work independently from each other.
d Close the Previewer window.
In the Previewer, click Close Previewer.
4 Open report p2q4.jsp and run the Web layout.
Select File > Open, locate p2q4.jsp, and click Open.
Select Program > Run Web Layout from the menu or select the Run Web
Layout icon on the horizontal toolbar.
a What style of report is this?
It is a Group Left master/detail report.
b How many groups of data are in this report?
There are two groups of data.
c How many pages are there in this report?
There are no pages in a Web report. In Reports Builder, run the paper
layout to determine the number of pages. There are three pages in this
report.
d Close the browser.
In the browser, click Close.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-5
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-6 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 2
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-7
Appendix A: Solutions
.....................................................................................................................................................
Introduction
The questions in the practice session provide an introduction to the Reports Builder
interface. You open and navigate through an existing report definition and use the
Help system to obtain information about some of the Report executables.
......................................................................................................................................................
A-8 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 3
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-9
Appendix A: Solutions
.....................................................................................................................................................
3 Using the same report, switch to the Paper Layout view of the Report Editor.
In the Object Navigator, select F_CUSTOMER_ID.
Hint: Use the Find field at the top of the Object Navigator.
Notice the object that is selected in the Paper Layout view.
Fully expand the Paper Layout node and select R_G_ORD_ID.
Notice the object that is selected in the Paper Layout view.
While the Report Editor window is active, select View > Change View > Paper
Layout from the menu.
Activate the Object Navigator window.
Click in the Find field and enter F_. The Navigator expands the appropriate
node and highlights the first object that meets the entered value.
In the Paper Layout view the field F_CUSTOMER_ID is selected.
In the Object Navigator window, select the Paper Layout node and select
Expand All in the vertical toolbar; or select View > Expand All from the
menu. Select R_G_ORD_ID.
In the Paper Layout view, the repeating frame R_G_ORD_ID is selected.
4 Using the same report, run the Web layout.
Select Program > Run Web Layout from the menu, or select the Run Web
Layout iconic button from the horizontal toolbar.
5 Use Help Contents to answer the following questions:
From the menu, select Help > Help Contents. Use the Index tab to locate each
term.
a What is RWSERVLET?
Enter RWSERVLET. RWSERVLET is the executable for the Reports
Servlet.
b What is RWCLIENT?
Enter RWCLIENT. RWCLIENT is the executable for the Reports Client.
It parses and transfers the command line to the Reports Server.
c What is the Web Source view?
Enter Web Source. The Web Source is a view of the Report Editor that
displays the source code for your Web report, including JSP and HTML
tags.
......................................................................................................................................................
A-10 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 4
.....................................................................................................................................................
Introduction
The questions in the practice session are intended to ensure that you have a good
understanding of how to create various styles of reports using the Report Wizard.
Note: When you are completing the practice sessions, keep to the filenaming
conventions that the questions specify. You might need these files in later practices.
In addition, note the field headings and widths. With many reports, you need to
change these to achieve the desired result.
Many of the practice sessions ask you to rename files beforehand; be sure to use
Save As, not Save, so that you do not overwrite the existing file name.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-11
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-12 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 4
.....................................................................................................................................................
2 Using the reentrant Report Wizard, make the following modifications (test your
report frequently).
Select Tools > Report Wizard from the menu or the right-mouse-button
menu.
a Modify the query to sort the data in descending order of salary.
On the Data tab choose Query Builder.
In the Query Builder window select Sort. Copy the SALARY column to
the Sorted Columns, select it, and select Sorting Order Descending. Close
the Sort dialog box and the Query Builder.
Click Finish to test your report.
b Add a summary to show the total salary value.
Reenter the Report Wizard by choosing Report Wizard from the menu.
On the Totals tab select SALARY and click Sum.
c Ensure the width of SALARY and TOTAL is 6.
Make the necessary changes on the Labels tab.
d Select the Green template.
Select the Green template on the Templates tab and click Finish to test
your report.
e Save the report to a file named p4q2.rdf .
Select File > Save As from the menu and save the file to disk.
3 Using the reentrant Wizard, modify the report to create a break report.
a Select the report style Group Above.
Select the report style on the Style tab.
b Modify the query and remove the join clause so that the report contains all
employees and not just managers.
Select the Data tab. Edit the query, removing the join clause
HR.DEPARTMENTS.MANAGER_ID=HR.EMPLOYEES.EMPLOYEE_ID.
Watch for syntax errors!
c Group the report by the department name.
On the Groups tab copy DEPARTMENT_NAME to the Group Fields
area.
d Save the report as p4q3.rdf.
Select File > Save As from the menu and save the file to disk.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-13
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-14 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 4
.....................................................................................................................................................
5 Using the reentrant Wizard, modify the report to create a Form Letter style.
Select Tools > Report Wizard from the menu or the right-mouse-button
menu.
On the Style tab select Form Letter.
a Modify the query to include order information for each customer:
On the Data tab, modify the query text as follows:
select c.cust_first_name || c.cust_last_name Name,
c.cust_address, o.order_id, o.order_total
from customers c, orders o
where c.customer_id = o.customer_id
b In the text area, enter some free-flowing text for each order. For example:
Order No. &<ORDER_ID> has been shipped to &<NAME> in &<C_CITY>.
The order has a total value of &<ORDER_TOTAL> dollars.
Thank you for your business.
Copy the fields that you want to use to the Form Letter Text area and
enter your free-flowing text.
c Select a different template and click Finish.
On the Template page in the Wizard, select any one of the predefined
templates. Click Finish.
d Save the report as p4q5.rdf.
Select File > Save As from the menu and save the file to disk.
6 Create a new report.
Create a new report by selecting the Report node in the Object Navigator and
choosing Create icon.
As an alternative you can also select File > New > Report from the menu.
a Create both a Web and paper layout. Select the matrix report style.
On the first page, select Create the radio button Create both Web and
Paper Layout. On the Style page choose Matrix.
b For the query, import the contents of p4q6.sql.
Choose Import SQL Query and select p4q6.sql from the Import dialog
box.
c Display customer names down the left side of the page.
Copy NAME to the Matrix Row Fields area.
d Display product numbers across the top of the page.
Copy PRODUCT_ID to the Matrix Column Fields area.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-15
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-16 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 4
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-17
Appendix A: Solutions
.....................................................................................................................................................
Introduction
In this practice session, you will reuse some of the reports that you created in the last
session.
......................................................................................................................................................
A-18 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 5
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-19
Appendix A: Solutions
.....................................................................................................................................................
2 Open report p4q3.rdf. Make the following changes in the Paper Design:
To open the file select File > Open from the menu or select Open from the
toolbar.
Run the report by selecting it in the Object Navigator and then selecting
Program > Run Paper Layout from the menu or selecting Run Paper Layout
from the toolbar.
a Add a border with a 2 pt. width around the total for each department.
Select the column for department total and choose Line Color from the
vertical toolbar. Select any color to add the border. With the column
selected, format the width of the border: select Format > Line > Line
Width > 2 pt.
b Add commas and two decimal places to the SALARY field and the total and
make them right-justified. Do not forget to justify the column header for the
SALARY field accordingly.
Select the total, the column, and its header, then select Align Right from
the style bar or select Format > Justify > Right from the menu.
While the column is selected choose Commas and then Add Decimal Place
from the style bar. Repeat the action for the second decimal place. You can
also select the options from the Format menu.
c Make the same changes to the total at the end of the report. Move the grand
total so that it aligns with the SALARY field (you must do this manually; use
the ruler guides to help you).
Select the column, then choose Align Right from the style bar or select
Format > Justify > and from the menu.
While the column is selected choose Commas and then Add Decimal Place
from the style bar. Repeat the action for the second decimal place. You can
also select the options from the Format menu.
d Change the color of the employee data heading to blue.
Select a label, and choose Select Parent Frame from the style bar. Select
Fill Color from the vertical toolbar.
e Make whatever other changes you like.
No formal solution.
f Save the report to a file named p5q2.rdf and close it.
......................................................................................................................................................
A-20 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 5
.....................................................................................................................................................
3 Open report p5q3_a.rdf. Make the following changes in the Paper Design:
To open the file select File > Open from the menu or select Open from the
toolbar.
Run the report by selecting it in the Object Navigator and then selecting
Paper Layout from the menu or selecting Run Paper Layout from the toolbar.
a Add a date at the top center of the page. Give it any format you want.
Hint: Choose the font, style, and text color you want before inserting the date.
Select Insert > Date and Time from the menu.
b Make whatever other changes you like.
No formal solution.
c Save the report to a file named p5q3.rdf and close it.
4 Open report p4q6.jsp. Make the following changes in the Paper Design:
To open the file select File > Open from the menu or select Open from the
toolbar.
Run the report by selecting it in the Object Navigator and then selecting
Program > Run Paper Layout from the menu or selecting Run Paper Layout
from the toolbar.
a Right-justify the Product ID field.
Select the Product ID field, then select Align Right from the style bar or
select Format > Justify > Right from the menu.
b Add commas and two decimal places to the cells and summaries and make
them right-justified.
Select the columns and choose Align Right from the style bar or select
Format > Justify > End from the menu.
While the columns are selected choose Commas and then Add Decimal
Place from the style bar. You can also select the options from the Format
menu.
c Why are some of the cell and summary values displayed with asterisks? What
can you do to correct this?
The addition of the comma and two decimal places increased the width of
the data such that it exceeded the display size. To correct this, reenter the
Wizard and increase the width of the cell and summary fields. Select
Report Wizard from the right-mouse-button menu. Select the Labels tab
and choose a width more suitable for displaying the formatted values. Try
a width of 6.
d Add a blue line color to the parent frame of NAME.
Select the column NAME and choose Select Parent Frame from the style
bar. Select Line Color from the vertical toolbar.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-21
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-22 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 6
.....................................................................................................................................................
Introduction
In this practice session, you open an existing template, which is one of the standard
templates shipped with the Oracle9i Reports Developer installation.
You modify objects in the margin and body sections and save the template to a new
filename. Then, you apply the modified template to an existing report and note the
differences.
Instructor Note
The practice does not include modifying the preferences file to register predefined
templates. You can suggest that the students do so, if you have time and if your class
setup allows students to modify the preference file and to write to the
<ORACLE_HOME>\reports\templates directory.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-23
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-24 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 6
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-25
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-26 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 7
.....................................................................................................................................................
Introduction:
In this practice session, you create simple reports for the Web using the Report
Wizard. You also examine the Web source code to identify specific JSP tags.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-27
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-28 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 7
.....................................................................................................................................................
Which JSP tag identifies the overall appearance and formatting of the data in
f
the Web report?
The rw:style tag identifies the style sheet for the report.
g Which JSP tag delimits the data model and layout information? Can you view
this information in the Reports Builder?
The rw:objects tag delimits the data model and the layout information for
a Reports JSP. Reports Builder hides this information. To see it, use a text
editor such as Wordpad.
h Run the Web layout to test. Save the report as p7q1.jsp.
2 Create a report for the Web that displays current product information.
a Use the Report Wizard to create a new tabular report called Our Products.
Include the following data from the PRODUCT_INFORMATION table:
Column Label
product_id Product No.
product_name Name
product_description Description
catalog_url Catalog URL
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-29
Appendix A: Solutions
.....................................................................................................................................................
Introduction
In this practice session, you modify an existing tabular report and create a break
report. Using two different techniques, you restrict the records in a report.
......................................................................................................................................................
A-30 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 8
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-31
Appendix A: Solutions
.....................................................................................................................................................
3 Modify p8q1.jsp to restrict the report to customers who have a credit limit
greater than 1500. You need to modify the query properties.
a Include CREDIT_LIMIT in the query statement, although you do not need to
display it. Restrict the query statement to show those customers who have a
credit limit greater than 1500.
In the Data Model select the query Q_1. Press the right-mouse-button to
open the Query Dialog or open it from the Property Inspector.
Enter WHERE CREDIT_LIMIT > 1500 directly in the query statement
area.
b Save the report as p8q3.jsp and run the Web layout.
......................................................................................................................................................
A-32 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 9
.....................................................................................................................................................
Introduction
In this practice session, you include new data in a report by adding a query to an
existing single-query report using the Data Wizard. You also practice linking data
from different queries to alter the report structure. You will create a new report using
the XML pluggable data source and a SQL query.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-33
Appendix A: Solutions
.....................................................................................................................................................
1 Open p8q1_a.jsp.
a In the Data Model, create the following query:
QUERY: Q_ORDERS
select customer_id, order_id, to_char(order_date,
'dd-Mon-yyyy') order_date,
order_total
from orders
Open p8q1_a.jsp from the file system. Display the Data Model view of the
Report Editor by double-clicking the Data Model icon in the Object
Navigator.
Select the SQL Query tool and click in the Data Model painter area. Enter
the query as above and click OK.
b Change the name of the group to G_ORDERS.
Double-click the group bar to display the Property Inspector for new
group. Enter G_ORDERS in the Name property field.
c Open the Report Wizard, create both a Web and paper layout, and select a
Tabular style.
Invoke the Report Wizard. Make the appropriate selections on the Report
Type and Style pages.
d Copy group G_ORDERS to the Displayed Groups area.
On the Groups page, select G_ORDERS from the Available Groups area
and copy to the Displayed Groups area.
e Copy all remaining fields to the Displayed Fields area.
On the Fields page, select all the remainig fields from the Available Fields
area and copy to the Displayed Fields area.
f Select a template and click Finish.
g Note how the data appears in the Paper Design view. The G_CUSTOMER_ID
data appears before the G_ORDERS data. Remember that you can alter the
order in which the data isdisplayed by modifying the query order in the Data
Model. You may want to try that.
Note: If you do adjust the order of the queries, put them back inthe original
order and save before the next question.
h Save the report as p9q1.jsp.
......................................................................................................................................................
A-34 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 9
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-35
Appendix A: Solutions
.....................................................................................................................................................
h Now you need to show not only which products the sales representatives have
sold but also who are the customers they have done business with.
Go to the Data Model and add a new query, importing the file p9q3_b.sql.
This query returns the customer names, their IDs, and the total sales per
customer for each sales representative.
Display the Data Model view. Select the SQL Query tool and click in the
painter area. Select Import SQL Query and locate the file p9q3_b.sql.
i Ensure that the group is named G_CUSTOMER.
j Link the second query to the correct group.
Select the Data Link tool. Click and drag EMPLOYEE_ID in G_NAME to
SALES_REP_ID in G_CUSTOMER.
k Use the Report Wizard to display the new group. Do not display
SALES_REP_ID or EMPLOYEE_ID.
Reenter the Wizard and make the requested changes.
l Change the following field attributes:
Column Label Width
customer Customer 20
customer_id ID 2
cust_total Total 9
......................................................................................................................................................
A-36 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 9
.....................................................................................................................................................
c Create an XML Query. For the Data Definition, locate the file
warehouse_inventory.xsd. For the Data Source, locate the file
warehouse_inventory.xml.
Select the XML Query tool. Click in the painter area of the Data Model
view. Specify the Data Defintion by clicking the Browse button and
locating the file warehouse_inventory.xsd. Make sure the file type
selected in the Open dialog box is XSD.
Specify the Data Source by clicking the Browse button and locating the file
warehouse_inventory.xml
d Link the two data sources together so that your report will provide a general
description of each warehouse along with the specific inventory for each
location.
Select the Data Link tool. Click and drag from WAREHOUSE_ID in the
SQL query group to WAREHOUSE_ID1 in the XML query group.
e Create both a Web and paper layout for this report. Select the Group Above
style. Ensure that both groups are selected and display all fields. Use the Blue
template for this report.
Invoke the Report Wizard. Work through the pages of the Wizard making
the selections as indicated. Click Finish to run the paper layout.
f Save the report as p9q4.jsp.
g Run the Web layout.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-37
Appendix A: Solutions
.....................................................................................................................................................
Create a new report manually. Select the Program Units node in the
Object Navigator and click the Create icon.
In the New Program Unit dialog box, enter RefCur as the name for the
package and choose Package Spec.
Enter the code for the package specification. This code is available in
p9q5a.txt.
PACKAGE RefCur IS
TYPE EmpRec IS RECORD (
last_name employees.last_name%TYPE,
first_name employees.first_name%TYPE,
salary employees.salary%TYPE);
Type EmpCur IS REF CURSOR RETURN EmpRec;
END;
b In the Data Model, create a REF Cursor Query. The function opens the cursor
for the following SELECT statement:
SELECT last_name, first_name, salary
FROM employees
Select the Ref Cursor Query tool and click in the painter area. Define the
following function or copy the code from the text file p9a5b.txt.
function QR_1RefCurDS return RefCur.EmpCur is
V_EmpCur RefCur.EmpCur;
begin
OPEN V_EmpCur
FOR
SELECT last_name, first_name, salary
FROM employees;
RETURN V_EmpCur;
end;
......................................................................................................................................................
A-38 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 9
.....................................................................................................................................................
c Open the Report Wizard to create the layout for the tabular report. Select all
the fields and choose a template. Click Finish to run the paper layout.
d Save the report as p9q5.jsp and close it.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-39
Appendix A: Solutions
.....................................................................................................................................................
Introduction
In your reports, you may need to include additional columns with summary
functions—or even add summaries, such as break totals and report totals. This practice
gives you the opportunity to create summaries and additional columns with
functionality that cannot be achieved using SQL alone.
......................................................................................................................................................
A-40 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 10
.....................................................................................................................................................
Hint: Read through all the steps of this exercise before creating your report.
You can use Query Builder to define the initial query for this report. You can
then manually edit the query to modify the display of order_date using the
TO_CHAR function: TO_CHAR(order_date, ‘dd-Mon-yyyy’).
b Do you need a formula column to calculate the line_total?
No, it is a much better solution to do the calculation directly in the query.
Enter the formula unit_price*quantity into the query text and give
it an alias name of line_total.
You can also use the Query Builder to create expressions in the query.
Select the table ORDER_ITEMS.
Select Define Column.
Click inside the Defined Columns box.
Enter Line_Total.
Click inside the Defined As box.
Enter the expression unit_price*quantity.
Click OK.
c Create the following summaries. Can you use the Report Wizard to create the
summaries?
Because this is a single query report, you can use the Report Wizard.
Column Summary
line_total sum
line_total % Total
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-41
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-42 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 10
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-43
Appendix A: Solutions
.....................................................................................................................................................
Hint: You need one formula column and two summaries and two placeholders.
You can import the code for the formula column from the file p10q4.txt .
At report level create two summary columns:
Name Function Source Reset At
CS_Max Maximum SumLineTotalPerORDER_ID Report
CS_Min Minimum SumLineTotalPerORDER_ID Report
b Use the Report Wizard to add the new columns to the layout. Display the
maximum order total, the maximum ORDER_ID, the minimum order total,
and the minimum ORDER_ID.
Display columns CS_Max, CS_Min, CP_Maxid , and CP_Minid. Give
them more meaningful labels.
c Run the paper layout to test. Scroll down to the last page to see the new
columns.
d Save the report as p10q4.rdf and close it.
......................................................................................................................................................
A-44 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 11
.....................................................................................................................................................
Introduction
In this practice session, you use reports created in earlier practice sessions.The aim is
to familiarize you with the different layout sections and regions of a report, and to use
report bursting. You also add flexible lines to a frame.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-45
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-46 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 11
.....................................................................................................................................................
c Add a trailer section that displays today’s date with the text “End of Report” on
one line, and “Report run on: ” on the second line in the body region. Select a
larger font.
Hint: Copy and paste the date from the Margin Area of the of the header
section of the report.
Select Trailer Section from the horizontal toolbar, or Select View > Layout
Section > Trailer from the menu. Make sure that you are editing the Body
region.
Click the text tool from the vertical toolbar and click in the layout area.
Enter the text and click outside the text object.
While the text object is selected, select font and size from the stylebar.
Select Edit Margin from the horizontal toolbar. Now select Header
Section.
Select the f_date1 field and then select Edit > Copy from the menu.
Select Trailer Section from the horizontal toolbar. Deselect Edit Margin.
Select Edit > Paste from the menu and move the field to the desired place.
d Save the report as p11q1.rdf.
e Run the Paper Layout. Run the Web layout. What is different?
The paper layout has the header and trailer sections, the Web layout does
not.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-47
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-48 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 11
.....................................................................................................................................................
3 Open report p11q3.rdf. Modify the report to burst on repeating data, based on
warehouse ID, and distibute a PDF report for each warehouse.
a In the Paper Layout view of the Report Editor, select the outermost repeating
frame and delete it.
Invoke the Paper Layout view of the Report Editor. Locate the repeating
frame R_G_WAREHOUSE_ID in the Object Navigator. The repeating
frame is now selected in the Paper Layout. With focus on the Paper
Layout, delete the repeating frame. Be sure you do not delete the frame
from the Object Navigator as this will delete all the objects within the
frame as well.
b Set the property for the main section of the report to burst on each warehouse
ID.
Select the Main Section node in the Object Navigator. Double-click the
object icon to display the Property Inspector or select Tools > Property
Inspector from the menu.
Locate the Repeat On property and select G_WAREHOUSE_ID from the
drop-down list.
c Define the distribution for the report. Generate a PDF file for each warehouse,
using the warehouse name as a unique identifier for each PDF file, such as
rptBejiing.pdf.
Select the Distribution property. In the Distribution Dialog box set the
distribution ID, desname, and desformat fields. Use warehouse_name in
the desname field, for example: rpt&<warehouse_name>.pdf. Make
sure the output format is PDF.
d Activate the distribution.
Select File > Distibute from the menu.
e Save the report as p11q3.rdf.
f Look at the output generated for several of the warehouses.
Locate the files in your file system and double-click several of them to look
at the output.
4 Open report p11q4.rdf.
a Use the Report Wizard to increase the width of PRODUCT_DESCRIPTION to
30.
b Add a flexible line vertically between the PRODUCT_NAME and
PRODUCT_DESCRIPTION fields.
Select the line tool from the vertical toolbar. Create a line between the
fields. If you want to ensure that the line is vertical, press the [Shift] key
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-49
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-50 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 11
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-51
Appendix A: Solutions
.....................................................................................................................................................
Introduction
Sometimes detail records get separated from their master header. You ensure that this
does not happen.
All paper layout objects support Web features. You will create a report that takes you
to a PDF document with a simple click using a hyperlink.
......................................................................................................................................................
A-52 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 12
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-53
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-54 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 13
.....................................................................................................................................................
Introduction
Modify a mailing label report to ensure you fill the printed page with label records.
You then restrict the number of labels that are printed on each page.
You add a link file to display a company logo by dynamically referencing a file at run
time.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-55
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-56 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 13
.....................................................................................................................................................
create an external boilerplate object in the margin region where the logo
was. Set the following properties:
Note: Do not include a file pathname.
Property Value
Name B_logo
Source File Format Image
Source Filename logo.tif
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-57
Appendix A: Solutions
.....................................................................................................................................................
Introduction
In this practice, you will create a Web report by adding dynamic report data to an
existing HTML page. You will also customize the Web report by using JSP tag
attributes.
......................................................................................................................................................
A-58 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 14
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-59
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-60 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 15
.....................................................................................................................................................
Introduction
Using XML you can build fully functional reports or partial reports that can serve as a
customization file.
You will run an XML file and apply an XML definition to an existing report.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-61
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-62 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 16
.....................................................................................................................................................
Introduction
In this practice session, you create bind and lexical parameters to restrict records in the
report. You add lists of values to select valid values at run time.
You then create your own default parameter form and customize it to include extra text
and graphics.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-63
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-64 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 16
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-65
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-66 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 17
.....................................................................................................................................................
Introduction
In this practice session you open existing reports to add graphs using the Graph
Wizard. You reenter the Graph Wizard to change the characteristics of a graph. You
will also add and customize a graph in a Web report.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-67
Appendix A: Solutions
.....................................................................................................................................................
dRun the paper layout to test. Resize the graph in the Paper Layout, if necessary.
e Save report as p17q1.jsp.
2 Reenter the Graph Wizard to change the characteristics of the graph created in the
previous exercise.
Make sure that the graph is selected; otherwise you will create a new graph.
Select Graph Wizard from the right-mouse menu.
a Give the graph the following characteristics:
Enter the following properties in the Wizard pages:
Title Order Total per Sales Rep
Graph Type Horizontal Bar
Graph Subtype Bar
......................................................................................................................................................
A-68 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 17
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-69
Appendix A: Solutions
.....................................................................................................................................................
On the layout page of the Graph Wizard, be sure to drag product_id from
the Groups field to the Slices field.
b In the Paper Layout, ensure that the graph is postitioned beneath the product
group.
If necessary, select the chart and drag it below the product group frame.
You must enable Flex Mode. Do not forget to turn it off again when you
have finished.
c Run the paper layout and test the report.
d Save the report as p17q4.jsp.
5 Continue with report p17q4.jsp.
a Add a bar graph to the Web source for the data group G_PRODUCT. Use the
same data group, category, and value settings as in the previous exercise.
Hint: You want to insert the graph just before the termination of the rw:foreach
tag for the group G_NAME.
Display the Web Source view. Locate the <rw:foreach...> tag for the
G_NAME group. You can use Edit > Find and Replace from the menu to
help you locate G_NAME. Scroll down in the code until you come to the
corresponding termination tag </rw:foreach>. The indented nature of the
code will help you identify the correct tag.
With you cursor just before the tag, select Insert > Graph from the menu.
Select a chart type of Bar. Use the table from the previous exercise to set
the other values in the Wizard.
b Run the Web layout to test. Ensure that a graph displays for each sales
respresentative.
......................................................................................................................................................
A-70 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 17
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-71
Appendix A: Solutions
.....................................................................................................................................................
Introduction
In this practice session, you use an existing matrix report to investigate the different
methods of displaying the cell values and the implications. You use an existing SQL
query to create a nested matrix report. You then add row- and column-level summaries
to the report and display zeros for null values.
If you have time, include the product names instead of the product IDs and rotate the
names.
......................................................................................................................................................
A-72 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 18
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-73
Appendix A: Solutions
.....................................................................................................................................................
Property Value
Name SumMonthProduct
Product Order G_MONTH G_PRODUCT_ID
Function Sum
Source SumTOTAL_VALUE
Reset At G_PRODUCT_ID
......................................................................................................................................................
A-74 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 18
.....................................................................................................................................................
g Use the Paper Layout view to create the fields. You must expand the
appropriate repeating frame.
Select and expand R_G_MONTH. You must enable Flex Mode. Do not
forget to disable it again when you have finished.
Select the Field tool from the vertical toolbar.
Create a field below F_SumTOTAL_VALUE. Position the field in the
R_G_MONTH and the R_G_PRODUCT_ID repeating frames.
Set the following properties:
Property Value
Name F_SumMonthProduct
Source SumMonthProduct
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-75
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-76 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 19
.....................................................................................................................................................
Introduction
In this practice session, you create a format trigger to conditionally flag one of two
paper layouts for the same data. You also conditionally flag some records in a report
by creating and referencing a report-level (local) PL/SQL function. You then move the
code into a new PL/SQL library and alter the reference to use the library function
instead.
If you have time, restrict the number of records processed in a report by creating your
own group filter.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-77
Appendix A: Solutions
.....................................................................................................................................................
c Create a Tabular layout using the following columns from the query:
In the Paper Layout view, select the Report Block tool from the vertical
toolbar.
Display the following fields. Select Labels and other properties as you
wish.
Column
order_id
order_date
order_total
d Create a user parameter, user_type, that has two possible values: Sales
Representative and Sales Clerk.
In the Object Navigator, select the User Parameters node and click the
Create icon.
Open the Property Inspector for the parameter. Enter USER_TYPE in the
Name property.
Ensure the Datatype property is set to Character.
Create a static list of values containing Sales Representative and
Sales Clerk.
......................................................................................................................................................
A-78 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 19
.....................................................................................................................................................
e Ensure that only the Group Above layout is displayed when the user type is
Sales Representative, and that only the Tabular layout is displayed when the
user type is Sales Clerk.
Create a format trigger on the M_G_CUSTOMER_ID_GRPFR group
frame in the first layout or use conditional formatting.
function M_G_CUSTOMER_ID_GRPFRFormatTrigger return
BOOLEAN is
begin
if:user_type = 'Sales Representative' then
return(true);
else
return(false);
end if;
end;
Create a format trigger on the M_G_ORDER_ID_GRPFR1 group frame
in the second layout with the reverse logic or use conditional formatting:
function M_G_ID_GRPFR1FormatTrigger return BOOLEAN is
begin
if :user_type = 'Sales Clerk' then
return(true);
else
return(false);
end if;
end;
To test the result, display the USER_TYPE parameter in the margin of the
report.
Display the Paper Layout view and select Edit Margin. Create a field to
display the user parameter USER_TYPE.
Make sure that you can enter a parameter value at run time.
Select Tools > Parameter Form Builder from the menu and select
USER_TYPE from the Parameter list. Click OK to create the Paper
Parameter Form.
Test the report by changing the User Type parameter on the Runtime
Parameter Form.
f Save the report as p19q1.rdf.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-79
Appendix A: Solutions
.....................................................................................................................................................
Click PL/SQL Formula to open the PL/SQL editor, and call the
ASTERISK function from the formula.
function CF_asteriskFormula return varchar2 is
begin
return(asterisk(:order_status));
end;
......................................................................................................................................................
A-80 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 19
.....................................................................................................................................................
cMove the function code into a new PL/SQL library named p19lib.pll.
In the Object Navigator, create a new library.
Open the Library node and click and drag the ASTERISK function into
the Program Unit node below the library.
Save the PL/SQL library.
Delete the report-level ASTERISK function. Attach the library to the
report. Recompile the formula column, CF_ASTERISK.
d Call the external function from your report instead of calling the report-level
function.
e Save the report to p19q2.rdf.
3 Continue with the previous report.
a Modify the same layout to display additional spacing between every two
records.
In the Data Model view, create a summary column in the G_ORDER_ID
group to keep a running total of records.
Name Function Source Reset At
COUNT_ORD COUNT order_id Report
In the Paper Layout view, increase the height of the repeating frame for the
second layout. Remember to switch Flex mode on, so that you can increase the
repeating frame and the group frame together.
Open the repeating frame Property Inspector and change the Vertical
Elasticity to Variable.
Select the rectangle tool and click and drag an area inside the repeating
frame, below the fields. Make sure the rectangle is transparent: no fill, no line.
In the Object Navigator, rename the rectangle to B_space and create the
following format trigger:
function B_spaceFormatTrigger return boolean is
begin
if mod(:count_ord,2) = 0 then return(TRUE);
else return(FALSE);
end if;
end;
b Save the report as p19q3.rdf and close it.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-81
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-82 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 20
.....................................................................................................................................................
Introduction
In this practice session, you highlight values based on conditional PL/SQL code.
You build a master report that enables you to call a detail report and generate a
separate PDF file for each detail report.
If you have time, you add report-level triggers to an existing report to write
messages to a temporary table at various stages of report execution.
Write PL/SQL functions as local PL/SQL (report-level), and reference the code in a
condition within the relevant object trigger in the report.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-83
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-84 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 20
.....................................................................................................................................................
b Alter the pattern and color of those records where the customer total is 5,000 or
less.
Hint: Check the Help system for the SRW.SET <attributes> or use conditional
formatting.
Attribute
Suggested Values
Fill pattern Crisscross, sandpaper
Foreground fill color Yellow
Background fill color Green
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-85
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-86 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 20
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-87
Appendix A: Solutions
.....................................................................................................................................................
e Write the code to execute the detail report. For each manager returned,
MGR_MASTER should invoke the detail report, EMP_RPT, pass it the
manager’s employee_id, and produce a report in PDF format containing
information about the employees working for that manager. Use the manager’s
employee_id to create an output filename for each manager:
MGR_<employee_id>.PDF.
Hint: You can write the code in the group filter.
Open the Property Inspector for the group G_MANAGER. Set the Filter
Type property to PL/SQL. Select the PL/SQL Filter property to open the
PL/SQL editor. Create the following function:
......................................................................................................................................................
A-88 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 20
.....................................................................................................................................................
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-89
Appendix A: Solutions
.....................................................................................................................................................
b The same trigger should also insert the current date, userid, and “Starting
Report” into this table.
INSERT INTO RUNREPORT
(DATE_RUN, USER_RUN, COMMENTS)
VALUES (SYSDATE, USER, ' Starting Report')
Hint: Think about how you code the single quotes.
Add the following code:
function BeforeReport return boolean is
begin
srw.do_sql('CREATE TABLE RUNREPORT
(DATE_RUN DATE, USER_RUN VARCHAR2(10),
COMMENTS VARCHAR2(80))');
srw.do_sql('INSERT INTO RUNREPORT
(DATE_RUN, USER_RUN, COMMENTS)
VALUES (SYSDATE, USER,
''Starting Report'')');
srw.do_sql(‘COMMIT’);
return(TRUE);
end;
c Compile the PL/SQL code and close the window.
d Save the report as p20q4.jsp.
e Run the paper layout.
f Using SQL*Plus, verify that your table exists and was populated successfully.
g Log on to SQL*Plus (in Microsoft Windows, select the SQL*Plus icon in the
Oracle group) using the same userid as you used for Reports.
h Display all records in the RUNREPORT table.
SQL> col comments format a40
SQL> SELECT * FROM RUNREPORT;
......................................................................................................................................................
A-90 Oracle9i Reports Developer: Build Reports
Practice Session Solutions: Lesson 20
.....................................................................................................................................................
i Try running the report more than once. When you run the report a second time,
the table already exists and Reports Builder raises an exception. Make the
necessary change to your code so that the report runs even when the table
exists.
You need two PL/SQL blocks so that, if the table already exists, the record
is inserted after the exception has been handled.
Add the following code:
function BeforeReport return boolean is
begin
begin
srw.do_sql('CREATE TABLE RUNREPORT
(DATE_RUN DATE, USER_RUN VARCHAR2(10),
COMMENTS VARCHAR2(80))');
exception
when srw.do_sql_failure then
null;
end;
begin
srw.do_sql('INSERT INTO RUNREPORT
(DATE_RUN, USER_RUN, COMMENTS)
VALUES (SYSDATE, USER, '' Starting Report '')');
srw.do_sql(‘COMMIT’);
return(TRUE);
end;
end;
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-91
Appendix A: Solutions
.....................................................................................................................................................
j Write a trigger that inserts a record with the comment “Printing another page”
whenever it begins a new page.
In the Object Navigator, expand the Report Triggers node, and double-
click the Between Pages PL/SQL icon to open the
PL/SQL editor.
Or, if the editor is already open, change the Name to Between Pages.
Create the following function.
function BetweenPage return boolean is
begin
srw.do_sql('INSERT INTO RUNREPORT
(DATE_RUN, USER_RUN, COMMENTS)
VALUES (SYSDATE, USER,
''Printing another page'' )');
srw.do_sql(‘COMMIT’);
return(TRUE);
end;
k Write a trigger that inserts a record with the comment “Report completed”
when the report finishes.
In the Object Navigator, expand the Report Triggers node and double-
click the After Report PL/SQL icon to open the PL/SQL editor.
Or, if the editor is already open, change the Name to After Report.
Report the following function:
function AfterReport return boolean is
begin
srw.do_sql('INSERT INTO RUNREPORT
(DATE_RUN, USER_RUN, COMMENTS)
VALUES (SYSDATE, USER, ''Report Completed'')');
srw.do_sql(‘COMMIT’);
return(TRUE);
end;
l Save the report as s20q4l.jsp. Generate the output to a PDF file. Verify
the results in SQL*Plus.
......................................................................................................................................................
A-92 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 21
.....................................................................................................................................................
Introduction
You publish your reports using Oracle9iAS Reports Services in the Oracle9i
Application Server. This practice session consists of paper-based questions to test your
understanding of Oracle9iAS Reports Services.
Instructor Note
Because Oracle9iAS is not part of the classroom setup environment, students will not
be able to actually deploy reports on the Web. However, encourage students to work
with the scenario in the practice and become familiar with the structure of the URL for
deploying reports on the Web, as well as creating entries in the key map file to
simplify the command line arguments.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-93
Appendix A: Solutions
.....................................................................................................................................................
The report should be executed by repserver4, and the output should be in HTML
format and go directly to Oracle9iAS Reports cache. Access the data by
connecting to the Sales database using a username of scott, a password of
tiger, and salesdb as the database connect string. Construct the URL to run
the report using the Reports servlet.
http://neptune.world.com:8888/salesdata/
rwservlet?report=salesbydept.jsp&server=repserver4&
desformat=html&destype=cache&userid=scott/tiger@salesdb
2 So that you do not have to enter such a long URL each time you run the
SalesByDept report, create a key entry for the key map file.
a Name the key sales. You can also restrict the data in the report by passing it
a value for the runtime parameter p_deptno. Be sure to include the parameter in
the map file entry.
sales: report=salesbydept.jsp server=repserver4
desformat=html destype=cache userid=scott/
tiger@salesdb p_deptno=%1
b Reconstruct the URL to run the report using the key. Pass in a value of 70 for
p_deptno.
http://neptune.world.com:8888/salesdata/
rwservlet?sales+70
3 In addition to using a URL, what are the other methods for requesting a report?
RWCLIENT command, Oracle9iAS Portal, SRW.RUN_REPORT, and the
Event-Driven Publishing API
4 What is the JSP runtime architecture used for?
The JSP runtime architecture runs the Web layout.
5 Which two facilities can be used to monitor Oracle9iAS Reports Services?
Oracle Enterprise Manager and Reports Queue Manager
......................................................................................................................................................
A-94 Oracle9i Reports Developer: Build Reports
Practice Session Overview: Lesson 22
.....................................................................................................................................................
Introduction
Report performance is always an issue. Reports Builder offers a few tools that allow
you to measure preformance. In this practice you will use them and interpret the
results.
......................................................................................................................................................
Oracle9i Reports Developer: Build Reports A-95
Appendix A: Solutions
.....................................................................................................................................................
......................................................................................................................................................
A-96 Oracle9i Reports Developer: Build Reports
B
Table Descriptions
Table Descriptions
Overall Description
The sample company portrayed by the Oracle9i Sample Schemas operates worldwide to fill
orders for several different products. The company has several divisions:
• The Human Resources division tracks information on the company’s employees and
facilities.
• The Order Entry division tracks product inventories and sales of the company’s products
through various channels.
• The Product Media division maintains descriptions and detailed information on each product
sold by the company.
• The Shipping division manages the shipping of products to customer.
Each of these divisions is represented by a schema. In this course, the user has access to the
objects in all of these schemas.
HR Human Resources
OE Order Entry
QS PM
Queued Product
Shipping Media
The Oracle9i Sample Schemas are a set of interlinked schemas. This set of schemas is aimed at
providing a layered approach to complexity:
• A simple schema (Human Resources, HR) for introducing basic topics.
• A second schema (Order Entry, OE) for dealing with matters of intermediate complexity. A
multitude of data types is available in this schema.
• The Online Catalog (OC) subschema is a collection of object-relational database objects
built inside the OE schema.
• A schema dedicated to multimedia data types (Product Media, PM)
• A set of schemas gathered under the main schema name QS (Queued Shipping) to
demonstrate Oracle Advanced Queuing capabilities.
.....................................................................................................................................................
Glossary-2 Oracle9i Reports Developer: Build Reports
Glossary
.....................................................................................................................................................
H
HTML (Hypertext Markup J
Language) Acronym for Hypertext
Java A computer language that
Markup Language. A tag-based ASCII
supports programming for the Internet in
language used to specify the content and
the form of platform-independent
links to other documents on Web servers
"applets."
on the Internet. End users with Web
browsers view HTML documents and J2EE (Java 2 Platform, Enterprise
follow links to display other documents. Edition) An environment for
developing and deploying enterprise
I applications in Java consisting of a set of
icon A graphic representation of a services, application programming
window or tool. interfaces, and protocols that provide for
developing multitiered, Web-based
IIOP (Internet Inter-ORB Protocol) applications.
A protocol used for communication JDBC (Java Database Connectivity)
between Common Object Request An industry standard for database and
Broker Architecture (CORBA) object Java platform connectivity providing a
request brokers. call-level API for SQL-based database
image A bitmapped object that can be access.
stored and loaded into an application. JSP (JavaServer Page) An extension
The client cannot modify an imported to the servlet functionality that enables a
image. simple programmatic interface to Web
intranet An internal TCP/IP network, pages. JSPs are HTML pages with
access to which is restricted (via a special tags and embedded Java code that
firewall) to individuals inside the is executed on the Web or application
company or organization. An intranet server providing dynamic functionality
provides similar services within an to HTML pages. JSPs are actually
organization to those provided by the compiled into servlets when first
Internet, but is not necessarily connected requested and run in the server's JVM.
to the Internet. A common example of an
intranet is when a company sets up one
.....................................................................................................................................................
Oracle9i Reports Developer: Build Reports Glossary-3
Glossary
.....................................................................................................................................................
.....................................................................................................................................................
Glossary-4 Oracle9i Reports Developer: Build Reports
Glossary
.....................................................................................................................................................
P R
Paper Design view Displays output for RDF file A file that contains a single
paper reports and allows you to make report definition in binary format. RDF
many commonly required, simple files are used to both run and edit reports.
modifications to the layout, such as RTF (Rich Text Format) A Microsoft
spacing, formatting fields,color, and standard for encoding formatted text and
editing text, without having to open the graphics.
Paper Layout view.
Paper Layout view Displays the layout S
objects in a paper report and allows you SELECT statement A SQL statement
to make many modifications to any that specifies which rows and columns to
layout object. All layout objects have fetch from one or more tables or views.
properties that you can modify using the SOAP (Simple Object Access
Property Inspector. The hierarchy of the Protocol) A message-based protocol
layout objects is determined by the data based on XML for accessing services on
model. the Web.
PDF (Portable Document Format) A SQL A standard interface for storing
file format (native for Adobe Acrobat) and retrieving information in a relational
for representing documents in a manner database. SQL is an acronym for
that is independent of the original Structured Query Language.
application software, hardware, and
SQL file A file that contains a query
operating system used to create the
stored in text (e.g., ASCII or EBCDIC)
documents. A PDF file can describe
format.
documents containing any combination
of text, graphics, and images in a device- SQL script A file containing SQL
independent and resolution independent statements that you can run to perform
format. database administration quickly and
easily. Several SQL scripts are shipped
PL/SQL Oracle's proprietary extension
with Oracle products.
to the SQL language. Adds procedural
and other constructs to SQL that make it SQL statement A SQL instruction to
suitable for writing applications. Oracle. A SELECT statement is one type
of SQL statement.
Q style sheet HTML extensions that
query A SQL SELECT statement that provide powerful formatting flexibility
specifies the data you want to retrieve in HTML documents. To view an HTML
from one or more tables or views of a document that takes advantage of style
database. sheets, display it in a browser that
supports style sheets.
.....................................................................................................................................................
Oracle9i Reports Developer: Build Reports Glossary-5
Glossary
.....................................................................................................................................................
W
T
Web browser A program that end users
table A named collection of related utilize to read HTML documents and
information, stored in a relational programs stored on a computer (serviced
database or server, in a two-dimensional by a Web server).
grid that is made up of rows and
Web server A server process (HTTP
columns.
daemon) running at a Web site that sends
tabular A default layout displaying out Web pages in response to HTTP
labels at the top of the page and rows of requests from remote Web browsers.
data underneath the labels.
Web source view Displays the HTML /
template A skeleton definition JSP source for a report. You can use this
containing common style and standards, view to add dynamic content to a Web
and can include graphics. A template page using the Report Block Wizard and
provides a standard format to enable the Graph Wizard. Experienced Java
quick and easy development of developers can edit the Web source
professional standard look-and-feel directly in this view.
reports.
window A rectangular area of the
toolbar A collection of iconic buttons desktop that contains an application.
that perform product commands. Usually Each window has an area where you can
aligned horizontally along the top, or interact with the application. Windows
vertically down the side of a window. can be opened, resized, moved, reduced
tool palette A collection of tools. to an icon, or enlarged to fill the entire
desktop.
U wizards Provide an easy step-by-step
UDDI (Universal Description, interface for commonly performed tasks.
Discovery, and Integration) An The wizards in Reports Builder are:
industry initiative for a universal
business registry (catalog) of Web
services.
.....................................................................................................................................................
Glossary-6 Oracle9i Reports Developer: Build Reports
Glossary
.....................................................................................................................................................
X
XML Extensible Markup Language: A
metalanguage using SGML to define and
structure data. Reports Builder supports
XML output to enable Web publishing as
well as electronic data exchange with
third-party applications. You can also
use XML to build report definitions that
can be merged with other report
definitions at run time or can be run
separately.
.....................................................................................................................................................
Oracle9i Reports Developer: Build Reports Glossary-7
Glossary
.....................................................................................................................................................
.....................................................................................................................................................
Glossary-8 Oracle9i Reports Developer: Build Reports