Sie sind auf Seite 1von 332

Developer/2000: Build Reports

Volume 2 • Student Guide


...........................................................................................

43211GC10
Production 1.0
January 1998
M06140
Author Copyright  Oracle Corporation, 1997. All rights reserved.

This documentation contains proprietary information of Oracle Corporation. It is


Louise Barnfield
provided under a license agreement containing restrictions on use and disclosure
and is also protected by copyright law. Reverse engineering of the software is
prohibited. If this documentation is delivered to a U.S. Government Agency of the
Department of Defense, then it is delivered with Restricted Rights and the
Technical Contributor following legend is applicable:

Ursula Hovy Restricted Rights Legend


Use, duplication or disclosure by the Government is subject to restrictions for
commercial computer software and shall be deemed to be Restricted Rights
software under Federal law, as set forth in subparagraph (c) (1) (ii) of DFARS
Technical Reviewers 252.227-7013, Rights in Technical Data and Computer Software (October 1988).

Gunnar Boehrs This material or any portion of it may not be copied in any form or by any means
without the express prior written permission of the Worldwide Education Services
Jacquelyn Bruce Crispell group of Oracle Corporation. Any other copying is a violation of copyright law and
Laurent Dereac may result in civil and/or criminal penalties.
Gillian Elias If this documentation is delivered to a U.S. Government Agency not within the
Pascal Gibert Department of Defense, then it is delivered with “Restricted Right,” as defined in
FAR 52.227-14, Rights in Data-General, including Alternate III (June 1987).
Steve Gramman
Marti Koppelmans The information in this document is subject to change without notice. If you find
any problems in the documentation, please report them in writing to Education
Steve Lirette Products, Oracle Corporation, 500 Oracle Parkway, Box 659806, Redwood
Jean Loup Lespine Shores, CA 94065. Oracle Corporation does not warrant that this document is
error-free.
Rita Morin
Vittavas Rattanamethawong Developer/2000, Designer/2000, PL/SQL, SQL*Plus, SQL*ReportWriter,
Discoverer 3, Oracle7, and Oracle8 are trademarks or registered trademarks of
Bryan Roberts Oracle Corporation.
Bert Salyga
All other products or company names are used for identification purposes only,
Jason Schiedemeyer and may be trademarks of their respective owners.
Hiroyuki Sugiyama
Kajornsak Sungcharoen
Pal Tarcsay
Bart van de Laar
Jack Walsh
Harry Wong

Publisher
Jade Arrington
Geraldine Freitas
Kelly Lee
Kimberly Lee
Contents
......................................................................................................................................................

Volume 1
Preface
Introduction
Overview I-3
Course Objectives I-5
Course Content I-7
Lesson 1: Introduction to Developer/2000
Overview 1-3
What Is Developer/2000? 1-5
Introducing the Developer/2000 Components 1-11
Common Builder Components 1-15
Getting Started in the Developer/2000 Interface 1-19
Navigating Around the Developer/2000 Main Menu 1-21
Customizing Your Developer/2000 Session 1-23
Developer/2000 Environment Variables 1-27
Invoking Online Help Facilities 1-29
Introducing the Course Application 1-31
Summary 1-33
Practice Session Overview: Lesson 1 1-35
Practice Session: Lesson 1 1-36
Lesson 2: Designing and Running Reports
Overview 2-3
Designing Reports 2-5
Design Considerations 2-7
Retrieving and Sharing Data 2-15
Running a Report 2-17
Viewing the Report Output 2-19
Summary 2-29
Practice Session Overview: Lesson 2 2-31
Practice Session: Lesson 2 2-32

......................................................................................................................................................
Developer/2000: Build Reports iii
Contents
......................................................................................................................................................

Lesson 3: Report Builder Concepts


Overview 3-3
Report Executables 3-5
Report Builder Components 3-9
Object Categories 3-13
Summary 3-23
Practice Session Overview: Lesson 3 3-25
Practice Session: Lesson 3 3-26
Lesson 4: Creating Reports Using the Report Wizard
Overview 4-3
Invoking Report Builder and the Report Wizard 4-5
Creating a Tabular Report Using the Wizard 4-7
Creating Other Report Styles 4-23
Summary 4-33
Practice Session Overview: Lesson 4 4-35
Practice Session: Lesson 4 4-36
Lesson 5: Enhancing Reports in the Live Previewer
Overview 5-3
What Is the Live Previewer? 5-5
Modifying a Report in the Live Previewer 5-7
Summary 5-19
Practice Session Overview: Lesson 5 5-21
Practice Session: Lesson 5 5-22
Lesson 6: Managing Report Templates
Overview 6-3
Using the Report Templates 6-5
Modifying a Template 6-7
Predefining Your Own Templates 6-13
Summary 6-17
Practice Session Overview: Lesson 6 6-19
Practice Session: Lesson 6 6-20

......................................................................................................................................................
iv Developer/2000: Build Reports
Contents
......................................................................................................................................................

Lesson 7: Report Storage Methods


Overview 7-3
Storage Methods and Requirements 7-5
Documenting Your Reports 7-9
File Portability 7-11
Converting Report Definitions 7-15
Migrating Developer/2000 Release 1 Reports 7-17
Summary 7-19
Practice Session Overview: Lesson 7 7-21
Practice Session: Lesson 7 7-22
Lesson 8: Enhancing Reports Using the Data Model—Creating
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-13
The Group Hierarchy 8-15
Ordering Data in a Group Hierarchy 8-17
Filtering Data in a Group 8-21
Adding New Data 8-23
Using Data Links to Structure Data 8-29
Efficiency Issues: Multiple or Single-Query Hierarchy 8-35
Summary 8-37
Practice Session Overview: Lesson 8 8-39
Practice Session: Lesson 8 8-40

......................................................................................................................................................
Developer/2000: Build Reports v
Contents
......................................................................................................................................................

Lesson 9: Enhancing Reports Using the Data Model—Creating


Columns
Overview 9-3
The Data Model Column Types 9-5
Maintaining Database Columns 9-7
Using a Database Column to Output Contents of a File 9-9
Creating a Column 9-11
Creating Summary Columns 9-13
Example Report Displaying Subtotals 9-15
Example Report Displaying Percentages 9-17
Creating Formula Columns 9-21
Creating Placeholder Columns 9-23
Example Report to Populate a Placeholder 9-25
Summary 9-27
Practice Session Overview: Lesson 9 9-29
Practice Session: Lesson 9 9-30
Lesson 10: Enhancing Reports Using the Layout Model
Overview 10-3
Viewing the Layout Model Regions 10-5
Designing Multipanel Reports 10-7
The Layout Model Layers 10-9
Creating Layout Objects 10-15
The Layout Model Tools 10-17
Creating Additional Layouts in a Report 10-19
Creating Variable Length Lines 10-21
Displaying a Multimedia File from a Button 10-23
Creating Explicit Anchors 10-25
Summary 10-29
Practice Session Overview: Lesson 10 10-31
Practice Session: Lesson 10 10-32

......................................................................................................................................................
vi Developer/2000: Build Reports
Contents
......................................................................................................................................................

Lesson 11: Modifying Properties


Overview 11-3
Modifying Layout Object Properties 11-5
Displaying File Contents with a Link File 11-7
Modifying Common Layout Properties 11-13
Sizing Objects 11-15
Layout Object Relationships 11-17
Modifying Properties of a Field 11-29
Modifying Properties of a Repeating Frame 11-37
Summary 11-43
Practice Session Overview: Lesson 11 11-45
Practice Session: Lesson 11 11-46

Volume 2
Lesson 12: Creating and Using Report Parameters
Overview 12-3
Creating User Parameters 12-5
Referencing Parameters in a Report Query 12-7
Hints and Tips for Referencing Parameters 12-13
Creating a List of Values 12-15
Referencing System Parameters 12-19
Building a Parameter Form 12-23
Summary 12-27
Practice Session Overview: Lesson 12 12-29
Practice Session: Lesson 12 12-30
Lesson 13: Embedding a Chart in a Report
Overview 13-3
Creating and Embedding a Graphics Chart in a Report 13-5
Embedding an Existing Chart in a Report 13-9
Summary 13-11
Practice Session Overview: Lesson 13 13-13
Practice Session 13-14

......................................................................................................................................................
Developer/2000: Build Reports vii
Contents
......................................................................................................................................................

Lesson 14: Enhancing Matrix Reports


Overview 14-3
The Matrix Data Model 14-5
Matrix Layout 14-7
Creating Matrix Summaries 14-9
Building a Nested Matrix 14-11
Summary 14-19
Practice Session Overview: Lesson 14 14-21
Practice Session: Lesson 14 14-22
Lesson 15: Coding PL/SQL Triggers in Reports
Overview 15-3
Types of Triggers in Reports 15-5
Using Report Triggers 15-7
Using Data Model Triggers 15-11
Using Layout Model Triggers 15-15
Writing Common Code 15-27
Summary 15-29
Practice Session Overview: Lesson 15 15-31
Practice Session: Lesson 15 15-32
Lesson 16: Using the Report Builder Built-In Package
Overview 16-3
Contents of the Report Builder Built-in Package 16-5
Outputting Messages 16-7
Executing a Nested Report 16-9
Restricting Data 16-15
Initializing Fields 16-17
Performing DDL Statements 16-19
Setting Format Attributes 16-21
Summary 16-25
Practice Session Overview: Lesson 16 16-27
Practice Session: Lesson 16 16-28

......................................................................................................................................................
viii Developer/2000: Build Reports
Contents
......................................................................................................................................................

Lesson 17: Maximizing Performance Using the Reports Server


Overview 17-3
Why Use a Remote Server? 17-5
Reports Server Architecture and Configuration 17-9
Viewing and Scheduling Reports in the Queue Manager 17-23
Summary 17-31
Practice Session Overview: Lesson 17 17-33
Practice Session: Lesson 17 17-34
Lesson 18: Building Reports for Different Environments
Overview 18-3
Different Development and Runtime Environments 18-5
Developing Reports to Run in Different GUIs 18-7
Building Character Mode Reports 18-9
Building Reports to Run in Different Languages 18-13
Summary 18-17

......................................................................................................................................................
Developer/2000: Build Reports ix
Contents
......................................................................................................................................................

Appendix A: Solutions
Practice Session Overview: Lesson 1 A-2
Practice Session Solutions: Lesson 1 A-3
Practice Session Overview: Lesson 2 A-8
Practice Session Solutions: Lesson 2 A-9
Practice Session Overview: Lesson 3 A-15
Practice Session Solutions: Lesson 3 A-16
Practice Session Overview: Lesson 4 A-19
Practice Session Solutions: Lesson 4 A-20
Practice Session Overview: Lesson 5 A-25
Practice Session Solutions: Lesson 5 A-26
Practice Session Overview: Lesson 6 A-30
Practice Session Solutions: Lesson 6 A-31
Practice Session Overview: Lesson 7 A-34
Practice Session Solutions: Lesson 7 A-35
Practice Session Overview: Lesson 8 A-37
Practice Session Solutions: Lesson 8 A-38
Practice Session Overview: Lesson 9 A-43
Practice Session Solutions: Lesson 9 A-44
Practice Session Overview: Lesson 10 A-50
Practice Session Solutions: Lesson 10 A-51
Practice Session Overview: Lesson 11 A-56
Practice Session Solutions: Lesson 11 A-57
Practice Session Overview: Lesson 12 A-60
Practice Session Solutions: Lesson 12 A-61
Practice Session Overview: Lesson 13 A-65
Practice Session Solutions: Lesson 13 A-66
Practice Session Overview: Lesson 14 A-69
Practice Session Solutions: Lesson 14 A-70
Practice Session Overview: Lesson 15 A-75
Practice Session Solutions: Lesson 15 A-76
Practice Session Overview: Lesson 16 A-81
Practice Session Solutions: Lesson 16 A-82
Practice Session Overview: Lesson 17 A-91
Practice Session Solutions: Lesson 17 A-92

......................................................................................................................................................
x Developer/2000: Build Reports
Contents
......................................................................................................................................................

Appendix B: Table Descriptions and Data


Summit Sporting Goods Database Diagram B-2
S_CUSTOMER Description B-3
S_CUSTOMER Data B-4
S_CUSTOMER Data (continued) B-5
S_CUSTOMER Data (continued) B-6
S_CUSTOMER Data (continued) B-7
S_DEPT Description and Data B-8
S_EMP Description B-9
S_EMP Data B-10
S_EMP Data (continued) B-11
S_EMP Data (continued) B-12
S_ITEM Description B-13
S_ITEM Data B-14
S_ITEM Data (continued) B-15
S_ORD Description and Data B-16
S_PRODUCT Description B-17
S_PRODUCT Data B-18
S_PRODUCT Data (continued) B-19
S_PRODUCT Data (continued) B-20
S_PRODUCT Data (continued) B-21
S_REGION Description and Data B-22
S_TITLE Description and Data B-23
Appendix C: Frequently Asked Questions
Frequently Asked Questions C-2
Frequently Asked Questions and Answers C-3
Appendix D: Oracle Rdb Overview
What Is Oracle Rdb? D-2
Oracle Rdb Features D-3
Standard User Interfaces D-4
Other Information D-5

......................................................................................................................................................
Developer/2000: Build Reports xi
......................................................................................................................................................
xii Developer/2000: Build Reports
12
................................

Creating and Using


Report Parameters
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

Objectives

At the end of this lesson, you should be


able to
• Create and reference a parameter.
• Create a list of values for parameter
input.
• Use and modify a system parameter.
• Build a parameter form layout.
• Customize a parameter form layout.

12-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
12-2
Overview
......................................................................................................................................................

Overview
Introduction
Parameters allow 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 how to create and reference user and system parameters and how to
customize a parameter form to display parameters at run time.

Objectives
At the end of this lesson, you should be able to:
• 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 parameter form.
• Customize a parameter form layout.

......................................................................................................................................................
12-3
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

User Parameters
Can be used to:
• Restrict values in a WHERE clause
SELECT NAME, SALES_REP_ID
FROM S_CUSTOMER
WHERE ID = <a value>
• Substitute any part of select statement
SELECT NAME, SALES_REP_ID
FROM S_CUSTOMER
<a where clause>
• Substitute a single column or expression
SELECT <a column/expression>
FROM S_CUSTOMER
12-3 Copyright  Oracle Corporation, 1998. All rights reserved.

Creating a User Parameter

12-4 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
12-4
Creating User Parameters
......................................................................................................................................................

Creating User Parameters


Introduction
You can create your own parameters and use them to change the SELECT statement
of your query at run time.

What Is a User Parameter?


A user parameter is a Data Model object that you create to hold a value that users
can change at run time.
You can reference a parameter anywhere in a query. For example, to
• Restrict values in the WHERE clause of the SELECT statement.
• Substitute any part of the SELECT statement, including the entire statement.
• Substitute a single column or expression in the SELECT list.
You can display the contents of a parameter in your report, by creating a layout field
and entering the parameter name in the field source property.

Steps to Create a User Parameter In the Object Navigator


1 In the Object Navigator choose the User Parameter node, then choose the Create
tool.
Note: If this is the first parameter, you can create it by double-clicking the User
Parameter node.
2 Rename the parameter and open the property palette.
3 Verify the datatype and width. Enter an initial value if required.

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
64KB.
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

......................................................................................................................................................
12-5
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

Referencing Parameters in a
Report Query
Bind reference replaces a value
• :parameter_name
parameter object may be created by
default
Lexical reference replaces a clause
• &parameter_name
parameter object is never created by
default
12-5 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
12-6
Referencing Parameters in a Report Query
......................................................................................................................................................

Referencing Parameters in a Report Query


Introduction
There are two ways to reference parameters in a query:
• Use a bind reference.
• Use a lexical reference.

What Is a Bind Reference?


A bind reference replaces a single value or expression.
To create a bind reference in a query, prefix the parameter name with a colon (:).
If the parameter object does not exist, Report Builder automatically creates it for
you and displays a message. In this case, the parameter default datatype is
Character, not Number.

What Is a Lexical Reference?


A lexical reference replaces any part of a SELECT statement, such as column
names, the FROM clause, the WHERE clause, the ORDER BY clause.
To create a lexical reference in a query, prefix the parameter name with an
ampersand (&).
If the parameter object does not exist, Report Builder does not create. You must
always create the parameter for a lexical reference in the Object Navigator.

Comparing Bind and Lexical Reference Types


Type Prefix Use to Replace Parameter Created by Default?
Bind : Single value or expression in Yes, if it does not already exist.
following clauses: WHERE, Report Builder displays a warning
GROUP BY, ORDER BY, message and adds the parameter to User
HAVING, CONNECT BY, Parameters in the Object Navigator.
START WITH.
Lexical & Any part of a SELECT No. You must always create the parameter
statement. in the Object Navigator yourself.
Datatype must always be Character.

......................................................................................................................................................
12-7
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

Using Bind References


• Restrict values in a WHERE clause
SELECT NAME, SALES_REP_ID
FROM S_CUSTOMER
WHERE ID > :P_CUST

• Substitute a single value or expression


in the select statement
SELECT NAME, SALES_REP_ID
FROM S_CUSTOMER
ORDER BY DECODE(:SORT , 1, NAME,
2, STATE, COUNTRY)

12-6 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
12-8
Referencing Parameters in a Report Query
......................................................................................................................................................

Using Bind References


Use a bind reference anywhere in a query where you can use a single literal value,
such as a character string, number or date.

Example
SELECT NAME, SALES_REP_ID
FROM S_CUSTOMER
WHERE ID = :P_CUST

The previous statement allows you to enter a specific customer number at run time.
So, if you enter 102, the WHERE clause uses the value 102 to restrict data fetched,
and fetch the one customer that has ID 102.

Example
SELECT NAME, SALES_REP_ID
FROM S_CUSTOMER
ORDER BY DECODE(:SORT, 1, NAME, 2, STATE, COUNTRY)

The previous statement allows 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 sales representative ID.

Where Can You Not Use Bind References?


You cannot use a bind reference to:
• Replace a column name in the SELECT clause, although you can reference a
value, such as the contents of a parameter:
SELECT LAST_NAME, SALARY * :P_RATE
FROM S_EMP

• Replace any part of a FROM clause.


• Replace reserved words or clauses.

......................................................................................................................................................
12-9
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

Using Lexical References


• Use to substitute any part of the query.
SELECT NAME, SALES_REP_ID
FROM S_CUSTOMER
&P_WHERE_CLAUSE
&P_ORD_CLAUSE

SELECT NAME, SALES_REP_ID


FROM S_CUSTOMER
&P_WHERE_ORD_CLAUSE

SELECT &P_CUST CUST, &P_SALESREP REP


FROM &P_TABLE

• Ensure that the number of values and


datatypes match at run time!
12-7 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
12-10
Referencing Parameters in a Report Query
......................................................................................................................................................

, Using Lexical References


Use a lexical reference to replace any clause in a SELECT statement, or even
replace the entire statement.

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 NAME, SALES_REP_ID
FROM S_CUSTOMER
&P_WHERE_CLAUSE
&P_ORD_CLAUSE

• To specify a WHERE clause, ORDER BY, or both clause at run time (as one
parameter).
SELECT NAME, SALES_REP_ID
FROM S_CUSTOMER
&P_WHERE_ORD_CLAUSE

• To specify two column names and the table name(s) at run time:
SELECT &P_CUSTNAME CUST, &P_SALESREP REP
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 datatype, as defined in the Data
Model.

......................................................................................................................................................
12-11
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

Hints and Tips When


Referencing Parameters
Always do the following:
• Specify column aliases when
substituting column names.
• Create lexical parameters explicitly in
the Object Navigator (Report Builder
creates bind parameters if necessary).
• Enter an initial value for parameters that
affect query validation when NULL.

12-8 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
12-12
Hints and Tips for Referencing Parameters
......................................................................................................................................................

Hints and Tips for Referencing Parameters


Specifying Column Aliases
If you substitute the name of a column or expression in the SELECT list with a
lexical reference in the SELECT list, always add a column alias after the reference.
Otherwise, when the parameter value changes at run time, the column name in the
SELECT list does not match the report column object and the report does not run.

Referencing Nonexistent and Null Parameters


Remember that Report Builder automatically creates a parameter when you make a
bind reference to a nonexistent parameter. However, Report Builder does not create
a parameter when you make a lexical reference to a nonexistent parameter.
When you create a lexical parameter, you might need to include an initial value
before referencing the parameter in the query, since, depending on your use of the
parameter, a NULL value can cause a syntax failure.

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 validity of the
statement, and to validate those that you allow a user to enter at run time.
Note: Always use column aliases when substituting column names with lexical
references.

......................................................................................................................................................
12-13
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

Static List of Values

2
3

4
5

12-9 Copyright  Oracle Corporation, 1998. All rights reserved.

1 Choose Static Values. 4 To remove a value: select a


value and choose Remove.
2 Enter a value and choose 5 Choose Ok to accept the list
Add. and exit.
3 Repeat for each value to
build the list of values.

......................................................................................................................................................
12-14
Creating a List of Values
......................................................................................................................................................

Creating a List of Values


Introduction
You can create a list of values from which users select a valid value at run time. You
can restrict users to only those values in the list, or allow them to enter a different
value.
For bind parameters, the list can be a static list of values or a dynamic list that
selects values from the database at run time.
For lexical parameters, you can enter a static list of values.

Steps to Create a Static List of Values


1 In the Parameter property palette, choose the List of Values property. The Static
Values radio button is selected by default.
2 Enter a value in the value field and choose Add.
3 Repeat for each value you want in the list.
Note: To remove a value, select the value in the list and choose Remove.

Restricting Users to Values in the List


Set the Restrict List to Predetermined Values property to determine whether to
prevent users from entering any value not included in your list. By default, this
property is Yes. If you set the property to No, users can still select a value from the
list, but can also enter other values, or leave the value blank.

......................................................................................................................................................
12-15
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

Dynamic List of Values

1 3
4
2

12-10 Copyright  Oracle Corporation, 1998. All rights reserved.

1 Choose SELECT State- 4 Hide the first column from the


ment. list.
2 Enter a valid query. 5 Choose OK to accept the
query and exit.
3 Select or clear the
Restricted List check box.

......................................................................................................................................................
12-16
Creating a List of Values
......................................................................................................................................................

Steps to Create a Dynamic List of Values


1 In the Parameter property palette, choose the List of Values property.
2 Choose SELECT Statement.
The SQL Query Statement area displays.
3 Enter a query to populate the list of values. You can include more than one
column; the parameter takes its value from the first column in the list; the
column values appear concatenated in the list at run time.
4 Set the Restrict List to Predetermined Values property, as required.

Displaying Meaningful Values Instead of Codes


To see a more meaningful list of descriptive values, instead of the primary or foreign
key column that you reference in the query, set Hide First Column to yes.
Ensure that the primary or foreign key column is first in the SQL query statement,
since this is still the value that the parameter object contains at run time.

......................................................................................................................................................
12-17
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

System Parameters

12-11 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
12-18
Referencing System Parameters
......................................................................................................................................................

Referencing System Parameters


Introduction
Report Builder provides system parameters to allow you to modify standard runtime
settings for each report definition.
There are currently eleven system parameters. You cannot delete them.
Each parameter has a default value that you can modify.
Parameter Use to specify Values Default
BACKGROUND If report is to run in background (In Yes, No No
Microsoft Windows, setting this
parameter to Yes invokes the Background
Server if not already running)
COPIES Number of copies if destype=printer any integer 1
CURRENCY Symbol for currency indicator max. 4 characters
DECIMAL Symbol for decimal indicator any single char
DESFORMAT Output device definition, ignored if examples: dflt, dflt
type=screen/preview pslan80, pdf
DESNAME Destination name, such as file name, <report>.lis
printer name, mail userid; ignored if
type=screen/preview
DESTYPE Destination type for output file, printer, mail, screen
screen, preview
MODE Whether report executes in bitmapped or bitmap, character default
character mode
ORIENTATION The print direction of printer output portrait, landscape portrait
PRINTJOB Whether print job dialog box displays at Yes, No Yes
run time, if destype=file or printer
THOUSANDS Symbol for thousands indicator any single
character

......................................................................................................................................................
12-19
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

Displaying a Currency Symbol


for Monetary Values
Build:
report:Parameter - CURRENCY

Initial Value £

report:Layout Field - F_Money £1000


£6000
£5000
Format Mask $NNN0
FF1000
FF6000
Runtime: FF5000
R30RUN report=fred.rep...currency=FF
12-12 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
12-20
Referencing System Parameters
......................................................................................................................................................

Displaying a Currency Symbol for Monetary Values


A common requirement is to format currency values preceded by a currency
symbol. You may require the symbol to be £ for pounds sterling, $ for U.S. dollars,
FF for french francs, and so on. You can set a different initial value in different
reports.

Steps to Display a Different Currency Symbol


To ensure your report output displays a £ sign:
1 Enter the currency symbol ($) in the format mask of one or more layout fields.
2 From the Object Navigator, open the property palette for the Currency system
parameter, and enter a maximum of four characters in the initial value.
Note: Currency, thousands and decimal symbols only appear in the report output if
you use them in the format mask of a layout field.

Altering the Parameter Value at Run Time


You can modify the parameter value at run time in one of two ways:
• Include the currency parameter on the runtime command line.
• Enable users to alter the parameter value on the runtime parameter form.
If the currency symbol you choose is several characters in length, remember to
make the relevant fields wide enough to include it.

Priority of Parameter Values


R30RUN: Runtime Parameter Form overrides Command Line. Command Line
overrides Initial Value.
R30DES: Runtime Parameter Form overrides Initial Value. Initial Value overrides
Command Line.
Note: When running a report in Report Builder, an initial value for the current
report takes priority over a default that you specify in the R30DES command line.
Use Tools—>Preferences—>Runtime Values and Runtime Settings for testing.

......................................................................................................................................................
12-21
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

Building a Parameter Form

+ Report properties:
Width
Height
Number of Pages
12-13 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
12-22
Building a Parameter Form
......................................................................................................................................................

Building a Parameter Form


Introduction
The reports that you created in previous lessons ran successfully without a
parameter form. However, when we created parameters, a default runtime parameter
form appeared, to enable us to change the values at run time.
You can build your own parameter form, select the parameters that you want to
display, and then customize the appearance of the parameter form in the Report
editor.

Steps to Build a Parameter Form


1 Select menu item Tools—>Parameter Form Builder.
The Parameter Form Builder dialog box appears.
2 If desired, modify the title, hint and status line text. These lines display at the top
of the parameter form at run time.
3 Select or deselect parameters in the parameter section as necessary.
Note: Selected parameters display in the dialog box as highlighted on a black
background. Deselected parameters do not appear in the parameter form.
4 Modify label text of the selected parameters, if you wish.
5 Choose OK to create the parameter form.
If you create many parameters in your report, the runtime parameter form can
spread over more than one page. You can view subsequent pages at run time by
choosing Next.

Setting Report Properties for the Parameter Form


There are three properties in the Report property palette, under the Parameter Form
Window node, that specifically apply to the parameter form.
Report Property Use to
Form Width Define the width of the parameter form that
the user sees at run time.
Form Height Define the height of the parameter form that
the user sees at run time.
Number of pages Define the number of physical pages that
make up the parameter form.

......................................................................................................................................................
12-23
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

Customizing a Parameter Form

PF_P_PAY_TYPE

P_PAY_TYPE

12-14 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
12-24
Building a Parameter Form
......................................................................................................................................................

Customizing the Parameter Form Layout


You can customize the parameter form layout in a similar way to customizing the
report layout. You can modify colors and fill patterns (except in fields), move or
delete existing objects, create additional objects, import file contents such as a
company logo, and so on.

Creating Parameter Fields


A parameter field is a placeholder for a parameter value on the runtime parameter
form, in the same way that a field is a placeholder for a column value in the layout.
You cannot modify the color or fill patterns of a parameter field. However, the
property palette allows you to modify all parameter properties.
Report Builder creates one field for each parameter that you select in the Parameter
Form Builder. If a parameter in your Data Model does not have an associated field,
it does not appear in the runtime parameter form because it does not have any
display attributes.
You can create additional fields by using the field tool in the parameter form toolbar,
and sourcing the field to an existing parameter.

Creating Parameter Boilerplate Objects


Parameter boilerplate is text or graphics that either you create or the Parameter
Form Builder creates by default.
The Parameter Form Builder creates parameter boilerplate objects for the labels of
each parameter field as well as for the title, hint, and status lines.
You can create additional boilerplate objects to customize your parameter form; for
example, create report heading pages, modify default labeling, import images, and
so on.
Note: You cannot create a link file in the parameter form; however, you can import
file contents, as you can in the layout.

......................................................................................................................................................
12-25
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

Summary
• Parameter types
– User parameters: bind/lexical, LOVs
– System parameters
• Modifying values at runtime
– Command line arguments
– Runtime parameter form
• Creating a runtime parameter form
– Build: Parameter Form Builder
– Customize: Report Editor
12-15 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
12-26
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 R30RUN command line.
- Allow users to change values in the runtime parameter form.
• Creating a runtime parameter form:
a Build a parameter form with the Parameter Form Builder.
b Customize the parameter form layout in the Report editor.

......................................................................................................................................................
12-27
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

Practice 12 Overview

• Modifying an existing report to use a


bind parameter
• Adding a dynamic list of values
• Adding a lexical parameter
• Adding a static list of values
• Creating a customized parameter form

12-16 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
12-28
Practice Session Overview: Lesson 12
......................................................................................................................................................

Practice Session Overview: Lesson 12


This practice session contains:
• Modifying an existing report to use a bind parameter
• Adding a dynamic list of values
• Adding a lexical parameter
• Adding a static list of values
• Creating a customized parameter form

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.

......................................................................................................................................................
12-29
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

Practice Session: Lesson 12


1 Open report p11q3.rdf.
a In the Report wizard add the following columns from the
S_CUSTOMER table. Create a new group for the customer
information above the order group.

Column Label Width


name 30
address 30
city 30

Create a reference to a bind parameter P_CUSTOMER in the query


b
to restrict orders to the parameter value you input at run time.
Note how Reports creates the parameter automatically.
c Run and test the report with valid customer ids.
d Save the report as p12q1.rdf. Do not close it.
2 Continue with report p12q1.rdf.
a Add a list of values to select any valid customer id in the
S_CUSTOMER table. Do not allow users to enter any other value.
The list should display customer names, not id numbers.
b Run and test the report with different values.
c Save the report as p12q2.rdf. Do not close it for the moment.
3 Open report p5q3.rdf.
a Create a lexical parameter to enable users to order the data by
different columns (or not at all) at run time. Replace the ORDER BY
clause in the query with a lexical reference to the parameter. Type in
an initial value for the parameter, to order by the employee’s last
name.
b Add a static list of values. Code two or three alternative ORDER BY
clauses. Allow any clause to be entered at run time.
c Run the report to test.
Select an order by clause from the list.
Enter your own order by clause.
Delete the default parameter value.
d Save the report as p12q3.rdf and close it.

......................................................................................................................................................
12-30
Practice Session: Lesson 12
......................................................................................................................................................

4 Continue with report p12q2.rdf.


a Create a default parameter form.
Include a Title message, but not a Hint message.
Display the parameters DESNAME and P_CUSTOMER.
b Use your imagination to customize the form in the Parameter Form
editor.
Ensure that the parameter P_CUSTOMER is placed in a prominent
position for user entry.
Add some graphics; modify colors and fill patterns.
c Run the report to test.
d Save the report as p12q4.rdf and close it.

......................................................................................................................................................
12-31
Lesson 12: Creating and Using Report Parameters
......................................................................................................................................................

......................................................................................................................................................
12-32
13
................................

Embedding a Chart in a
Report
Lesson 13: Embedding a Chart in a Report
......................................................................................................................................................

Objectives

At the end of this lesson, you should be


able to
• Create and display a simple chart.
• Display an existing chart.
• Modify chart data dynamically.

13-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
13-2
Overview
......................................................................................................................................................

Overview
Introduction
In this lesson you learn to display a Developer/2000 graphical chart in a report at
run time.

Objectives
At the end of this lesson, you should be able to:
• Create and display a simple Graphics chart in a report, using the Chart wizard.
• Display an existing Graphics chart in a report.
• Explain how to modify data dynamically in an existing chart.

......................................................................................................................................................
13-3
Lesson 13: Embedding a Chart in a Report
......................................................................................................................................................

Creating a Chart

• Image shows chart type


• Subtypes depend on type
13-3 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
13-4
Creating and Embedding a Graphics Chart in a Report
......................................................................................................................................................

Creating and Embedding a Graphics Chart in a Report


Introduction
Developer/2000 Release 2 provides an easy-to-use Chart wizard in Report Builder
(and Form Builder) to allow you easily to produce a chart that appears in your report
at run time.

Invoking the Chart Wizard


In Report Builder, invoke the Chart wizard in one of the following ways:
• Choose the Chart wizard tool in the Live Previewer.
• Choose the Chart wizard tool in the Layout Model.
• Choose Tools—>Chart Wizard from the menu.

Choosing the Chart Style


Choose the style of chart that you require. The picture on the left of the wizard
displays the relevant chart style.
Choose the chart subtype that you require, and then choose Next to continue to the
next wizard page.

......................................................................................................................................................
13-5
Lesson 13: Embedding a Chart in a Report
......................................................................................................................................................

Choosing the Chart Data

13-4 Copyright  Oracle Corporation, 1998. All rights reserved.

Positioning the Chart

13-5 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
13-6
Creating and Embedding a Graphics Chart in a Report
......................................................................................................................................................

Choosing the Chart Data


The next two wizard pages allow you to define the data in the chart:
1 Select the field that you want to appear as the categories of your chart.
- Column, Line, Mixed chart: Categories appear along the x-axis.
- bar chart: Categories appear down the y-axis.
- Pie chart: Each category represents one segment of the pie.
2 Select the field that you want to appear as the values of your chart.
- Column, Line, Mixed chart: Values are the height of the columns against the
y-axis.
- Bar chart: Values are the length of the columns against the x-axis.
- Pie chart: Values are the size of each segment of the pie.

Positioning the Chart in the Report Output


The final page of the Chart wizard allows you to position the chart at the beginning
or end of the report output, or to display the chart once for each occurrence of a
group.

......................................................................................................................................................
13-7
Lesson 13: Embedding a Chart in a Report
......................................................................................................................................................

Embedding an Existing Chart

1
2 D_empchart

3 disp1.ogd

13-6 Copyright  Oracle Corporation, 1998. All rights reserved.

1 Create the display object.


2 Rename the display object.
3 Enter the chart filename (created in Graphics Builder).

......................................................................................................................................................
13-8
Embedding an Existing Chart in a Report
......................................................................................................................................................

Embedding an Existing Chart in a Report


Introduction
If you already have a chart that you created or modified in Developer/2000 Graphics
Builder and that you want to embed in your report definition, you can create a
display object in the report layout and associate it with your chart (.ogd file).

Creating a Display Object


1 In the Layout Model, choose the Chart tool in the vertical toolbar.
2 Click and drag an area in the layout where you want the chart to occur.
Note: If you want to repeat the chart for each occurrence of a group, such as for
each department, you must expand the repeating frame so that it encloses the
display object.
3 Rename the display object in the Object Navigator, or in the display object
property palette.
4 In the property palette, enter the chart filename or choose the file from the
browser, using the button on the right side of the property palette.
Note: If you use the browse, remove the directory path, so that only the
filename remains. Ensure that the REPORTS30_PATH variable includes the
directory that contains your chart file.

Passing Parameters or Data Records to an Existing Chart


In an existing chart (built using the Graphics Builder), you might have parameters
that modify the chart depending on the value entered at run time.
You can pass a parameter from your report to the chart at run time, so that your chart
parameter value changes each time Graphics Builder executes the chart.
Alternatively, you can pass entire records from your report to the chart, so that the
chart does not requery the data from the database.
To map report objects to graphics parameters or columns, in the chart object
property palette, choose Parameters and Columns under the Chart node. You must
know the names of the graphics parameters and columns that exist in the graphics
.ogd file.
For further details see the online help.

......................................................................................................................................................
13-9
Lesson 13: Embedding a Chart in a Report
......................................................................................................................................................

Summary
• Build new chart:
– Invoke Chart wizard to build and
embed a chart.
– Enhance chart in Graphics Builder.
• Embed existing chart:
– Create display object.
– Link to chart filename.
– Pass parameters or column values.

13-7 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
13-10
Summary
......................................................................................................................................................

Summary
• Use the Chart wizard to create and embed a simple chart in your report.
• Reenter the Chart wizard to make changes to the chart object, such as its
position in the report.
• Use Developer/2000 Graphics Builder to enhance and modify the chart
definition.
• Create a display object in the Layout Model, to embed a chart that already exists
in an .ogd file. Enter the chart (.ogd) filename.
• Pass parameters or column values from a report to a chart to restrict values or
data records, if the chart contains a separate SQL query.

......................................................................................................................................................
13-11
Lesson 13: Embedding a Chart in a Report
......................................................................................................................................................

Practice 13 Overview

• Using the Chart wizard to create a chart


• Altering the chart in the Chart wizard
• Creating charts that print once for each
record of a group

13-8 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
13-12
Practice Session Overview: Lesson 13
......................................................................................................................................................

Practice Session Overview: Lesson 13


This practice session contains:
• Using the Chart wizard to create a chart in an existing report
• Altering the chart in the reenterable Chart wizard
• Creating charts in an existing report that will print once for each record of a
group

Introduction
In this practice session you open existing reports to add charts using the chart
wizard. You also reenter the chart wizard to change the characteristics for a chart.

......................................................................................................................................................
13-13
Lesson 13: Embedding a Chart in a Report
......................................................................................................................................................

Practice Session
1 Open report p12q1.rdf.
a Remove all reference to the parameter P_CUSTOMER from the
query.
b Rename SumLine_totalPerNAME to Total. (A shorter name looks
better in a chart.)
c Use the Chart wizard to create a line chart.

Chart Type Line


Chart Subtype Plain
Category NAME
Value TOTAL
Position At the beginning of the report
Filename p13q1.ogd

Run report to test. Resize the chart if necessary.


d
e Close the Graphics Batch.
f Save report to p13q1.rdf.
2 Reenter the Chart wizard to change characteristics of the chart created in the
previous exercise.
a Give the chart the following characteristics:

Title Order Total per Customer


Chart Type Column
Chart Subtype Depth

b Run the report to test.


c Close the Graphics Batch.
d Save report to p13q2.rdf and close it.

......................................................................................................................................................
13-14
Practice Session
......................................................................................................................................................

3 Open report p8q5.rdf.


a Use the Chart wizard to create a pie chart for the data group
G_PRODUCT.
Chart Type Pie
Chart Subtype Plain
Data Group G_product
Category PRODUCT_ID
Value PROD_TOTAL
Chart Frequency Once per Name
File Name p13q3a.ogd

b In the Layout editor move the chart beneath the product group and
resize it to the same width as the product group.
c Run and test the report.
d Close the Graphics Batch.
e Create a second chart for the customer group
Chart Type Pie
Chart Subtype Plain
Data Group G_customer
Category CUSTOMER_ID
Value CUST_TOTAL
Chart Frequency Once per Name
File Name p13q3e.ogd

f In the Layout editor move the chart beneath the customer group.
Hint: Create a frame around both charts, so that they always display side by
side.
g Run and test the report.
h Close the Graphics Batch.
i Save the report to p13q3.rdf and close it.

......................................................................................................................................................
13-15
Lesson 13: Embedding a Chart in a Report
......................................................................................................................................................

......................................................................................................................................................
13-16
14
................................

Enhancing Matrix Reports


Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................

Objectives

At the end of this lesson, you should be


able to
• Describe the matrix Data Model objects.
• Describe the matrix Layout objects.
• Create and modify matrix summaries.
• Display zeros in cells with no value.

14-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
14-2
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 and matrix with group report using
the Report wizard.
In this lesson, you modify the data model and layout objects to enhance your matrix
reports.

Objectives
At the end of this lesson, you should be able to:
• Design a matrix Data Model.
• Design a matrix Layout Model.
• Modify a matrix structure.
• Create additional matrix summaries.
• Display zeros in cells with no value.

......................................................................................................................................................
14-3
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................

The Matrix Data Model

1 4
5

3
14-3 Copyright  Oracle Corporation, 1998. All rights reserved.

1 Cross product group 4 Cell column is the source of a


cross product summary that
becomes the cell content
2 Row and Column groups 5 Row and Column summaries
3 Cell group

......................................................................................................................................................
14-4
The Matrix Data Model
......................................................................................................................................................

The Matrix Data Model


Introduction
To maintain and enhance the structure of a matrix report, you must understand the
Data Model objects and their interdependency.

What Does the Wizard Create?


The Data Model opposite is the matrix report that we created in an earlier lesson. It
demonstrates the structure of the Matrix and Matrix with Group styles.

Simple Matrix Style


The wizard creates three data groups:
• Department records (the rows)
• Job Title records (the columns)
• Salary records (the values used to calculate the matrix cells)
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.
To create a cross product group, use the Cross Product tool in the vertical toolbar.

Matrix with Group


The data model is identical, except for the addition of a break group, similar to a
master/detail hierarchy.
The break group exists one level above, and outside, the matrix group. The entire
cross product group, with its contents, repeats for each record in the break group.

......................................................................................................................................................
14-5
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................

The Matrix Layout

1 2 3 4
14-4 Copyright  Oracle Corporation, 1998. All rights reserved.

1 Repeating frame for rows 3 Matrix object, the


(Down Direction) intersection of the two repeat-
ing frames
2 Repeating frame for 4 Matrix with Group style: outer
columns (Across) repeating frame for break
group

......................................................................................................................................................
14-6
Matrix Layout
......................................................................................................................................................

Matrix Layout
Introduction
Although the supplied templates create good looking, professional report output,
they do not help to explain the layout objects in a classroom environment. The
number of objects and their interdependency are more complex in matrix reports
than in the other styles we have seen so far.
This section explains the objects by showing an ‘expanded’ layout where each outer
object is slightly larger than its contents.

What Does the Wizard Create?


The layout for a matrix report is more complex than other styles because of the
special relationship between the row and column groups, and the cell values.

Simple Matrix Style


The wizard creates the following objects:
• One repeating frame with Print Direction of Down to hold the row values
• One repeating framewith 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

Matrix with Group


The matrix with group style is identical except for the addition of a repeating frame
that surrounds the entire matrix layout and corresponds to the break group in the
Data Model.

......................................................................................................................................................
14-7
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................

Creating Matrix Summaries


1 2

3
14-5 Copyright  Oracle Corporation, 1998. All rights reserved.

1 Product Order = G_DEPT 3 Product Order =


G_DEPT G_TITLE
2 Product Order = G_TITLE

......................................................................................................................................................
14-8
Creating Matrix Summaries
......................................................................................................................................................

Creating Matrix Summaries


Introduction
When creating row or column summaries, or the summary for the cell values, use
the summary tool in the vertical toolbar, but ensure that you create the summaries
inside the cross product group (but outside the row and column groups).
This section discusses a extra property that applies only to cross product summaries,
the Product Order property.
Setting the Product Order
The wizard sets a sensible default for this property. You do not need to alter the
setting, but you need to understand this property if you create complex matrix
reports, or add columns to an existing matrix report.
The product order defines the order in which Report Builder evaluates the groups in
the cross product for a summary.
Product Order also defines the frequency of a summary, formula or placeholder
column in a cross product group. That is, the column has one value for each
combination of values in its Product Order groups.
The Product Order list of values provides all possible group combinations.
In our matrix report:
• F_SumSalPerDEPT has one value for each department (G_DEPT).
• F_SumSalPerTITLE has one value for each job title (G_TITLE).
• F_SumSALARY, the matrix cell, has one value for each combination of
G_DEPT and G_TITLE, so the Product Order is G_DEPT G_TITLE.

Source Column Reset At Product Order


F_SumSALPerDEPT_NAME G_DEPT G_DEPT
F_Sum_SALPerTITLE G_TITLE G_TITLE
F_SumSALARY G_TITLE G_DEPT G_TITLE

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.

......................................................................................................................................................
14-9
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................

Building a Nested Matrix

14-6 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
14-10
Building a Nested Matrix
......................................................................................................................................................

Building a Nested Matrix


Introduction
The nested matrix style, which we created with the wizard by adding an extra level
in the Rows tab, has some specific features. This section briefly describes the Data
Model and Layout Model, pointing out the differences from the Matrix with Group
style. We also explain how summaries evaluate the extra group level of a nested
matrix.

What Is in the Nested Matrix Data Model?


The wizard creates the same objects as for a simple matrix structure. In addition, it
creates an additional break group for each level of nesting.
The cross product group encloses the additional break group(s) as well as the two
original dimension groups of the rows and columns.

Creating the Cross Product Group


If you enhance the existing Data Model to include an additional level of nesting, the
existing cross product group does not recognize any newly created group. You must
create the cross product group after you create all the groups that you want in the
nested matrix.
Steps to Recreate the Cross Product group.
1 Delete the existing cross product group.
Note: the cross-product summaries are automatically deleted.
2 Create the new group(s) that you need.
3 Recreate the cross product group. Use the cross product tool (AxB) to click and
drag a region surrounding the break group(s) and the two dimension groups
(rows and columns).
4 Use the reenterable wizard to recreate the summaries.

What Is the Difference Between a Nested Matrix and a Matrix with Group?
• Matrix with Group Data Model: The cross product group is the child of a parent
break group at a level above and outside the cross product.
• Nested Matrix Data Model: The cross product contains three or more groups:
one or more levels of break group, and two dimensional groups to form rows
and columns.
Note: You can mix these styles. That is, you can create a Matrix with Group report,
where the matrix has several nested levels within it.

......................................................................................................................................................
14-11
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................

Nested Matrix Layout

14-7 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
14-12
Building a Nested Matrix
......................................................................................................................................................

What Is in the Nested Matrix Layout Model?


The wizard creates the same objects as for a simple matrix structure. It also creates
the following objects:
• One repeating frame for each additional break group, nested within the same
overall matrix structure.
• One matrix object for each additional break group.
The exact appearance depends on whether the extra level is in the Row or in the
Column tab. The diagram opposite shows nested rows.
In the Object Navigator, you can see the matrix structure in the Dimension and
Frequency nodes. These nodes only exist if there is a matrix. You do not see a node
for the matrix object name, but it does have properties. You can open the property
palette in the Layout Model only.

Creating a Matrix Object


When possible, use the wizard to create your matrix reports, since the layout
consists of many layers and interdependent objects.
If you resize the repeating frames, take care to maintain the intersection between
them, otherwise you might destroy the matrix object. Report Builder gives you a
warning message if this is likely to happen.
If you destroy the matrix object, or want to create the matrix structure yourself, you
must recreate the matrix object. Each matrix object intersects and determines the
relationship between two and only two repeating frames.

Steps to Create the Matrix Object


1 Ensure that the two related repeating frames do intersect each other correctly.
2 Select both repeating frames (Shift-Select).
Note: if you do not select both frames you receive an error message:
REP-3100: Matrix must include at least 1 Down and 1 Across repeating frame.

3 Choose Insert—>Layout Matrix.


4 Move the matrix object back through the layout layers until it is behind the cell
field (Arrange—>Move Backward). This step is not necessary to make the
report run, but it is useful to see the cell field if the matrix has a solid fill.

......................................................................................................................................................
14-13
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................

Creating Matrix Summaries

F_SumSALARY F_SumSALPerDEPT

F_Sum_REG_NAME

F_SumSALPerTITLE

14-8 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
14-14
Building a Nested Matrix
......................................................................................................................................................

Creating Nested Matrix Summaries


The wizard creates nested summaries in the cross product group.
If you create or alter a nested summary, you must set the Product Order correctly.
Always test the report output very carefully to ensure that the summaries are
displaying exactly the value you expect.

Setting the Product Order


Remember, the Product Order indicates the way in which Report Builder evaluates a
summary. Product Order also determines the position (frequency) of the summary if
you use the reenterable wizard.
The diagram opposite shows three summary fields created by the wizard:
• F_SumSALperTITLE—total salary for each column of job title—displays once
for each title.
• F_SumSALperDEPT—total salary for each department row nested within a
specific region row—displays once for each combination of region/department.
• F_SumSALARY—the cell value—displays once for each combination of
region/department/title.

Field Name Reset At Product Order


F_SumSALPerTITLE G_TITLE G_TITLE
F_SumSALPerDEPT G_DEPT_NAME G_DEPT_NAME
F_SumSALARY G_DEPT_NAME G_REG_NAME G_TITLE
G_DEPT_NAME

The diagram also shows a fourth summary, F_Sum_REG_NAME, 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_REG_NAME repeating frame (use the Object Navigator to identify it).
The table below shows the property settings.

Field Name Reset At Product Order


F_Sum_REG_NAME G_REG_NAME G_REG_NAME

......................................................................................................................................................
14-15
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................

Displaying Zeros

14-10 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
14-16
Building a Nested Matrix
......................................................................................................................................................

Displaying Zeros in Cells with No Value


The field that displays each cell of the matrix is sourced to a summary column, such
as SumSalary.
If there is no value for a particular row/column combination, the summary column
is null and therefore the cell displays as a blank field.
You can very simply change the blank to zero or any default value you choose.
To display zeros, open the property palette for either the cell field or the SumSalary
summary column and set the property Value if Null to zero.

......................................................................................................................................................
14-17
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................

Summary
• Create matrix with the wizard.
• Consider creating or modifying a
template with extra spacing.
• Data and layout reflect cross product
structure.
• Matrix-specific:
– Cross Product group
– Product Order property
– Matrix layout object
14-11 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
14-18
Summary
......................................................................................................................................................

Summary
Let the Wizard and Template Work for You!
Use the wizard to create your matrix, even if you need to modify it later. Allowing
the wizard to create the initial layout model 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
Layout Model.
Note: Remember, 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 Layout Model of a matrix report contain special features, and
relationships between objects, to reflect the cross product structure of the report.

Matrix-Specific Objects and Properties


Matrix reports include special objects, and properties:
• Data Model—Cross Product group; Product Order property
• Layout Model—Matrix Object

......................................................................................................................................................
14-19
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................

Practice 14 Overview
• Opening and changing an existing
matrix report
• Building a nested matrix report
• Adding summaries to the nested matrix
report
• Displaying zeros for summary values
and restricting columns per page
• Displaying more meaningful column
information and rotating the text

14-12 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
14-20
Practice Session Overview: Lesson 14
......................................................................................................................................................

Practice Session Overview: Lesson 14


This practice session contains:
• Opening and changing an existing matrix report
• Building a nested matrix report
• Adding summaries to the nested matrix report
• Displaying zeros for summary values and restricting the number of columns per
page
• Displaying more meaningful column information and rotating the text

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

......................................................................................................................................................
14-21
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................

Practice Session: Lesson 14


1 Open report p4q6.rdf.
aUse the Report wizard to apply a template file to the report. The file
corpmat.tdf should be located in your working directory. The new
template gives you spaces between the layout objects to make it
easier to see the different objects in the Layout editor.
b How many repeating frames do you have?
c Change the properties of the cell object to display zero for a null
value.
d Run and test the report.
e Close the report without saving it.
2 Create a new report, importing the external query p4q6.sql from your working
directory.
a Choose the following settings:
Report Style Matrix
Query (import file p4q6.sql)
Matrix Row Fields - Level 1 - Month
- Level 2 - Name
Matrix Column Fields Product_id
Matrix Cell Fields Sum of total_value
Matrix Totals Sum of the cell field

......................................................................................................................................................
14-22
Practice Session: Lesson 14
......................................................................................................................................................

b Change the labels and widths for the following fields:

Field Label Width


NAME Customer 10
PRODUCT_ID Product 5
MONTH Month 4
SUMTOTALVALUE Total 5
All Summaries Total: 5

Run the report.


c
d Which summaries were created?
e Use the Data Model editor to create summaries for each month and
for the level month and product.
f Use the Layout editor to create the fields. You will have to expand
the appropriate repeating frame.
g Run and test the report.
h Save the report as p14q2.rdf. 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 comas and two decimal places where appropriate.
e Run and test the report.
f Save the report as p14q3.rdf, and close it.

......................................................................................................................................................
14-23
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................

If You Have Time


4 Open the report as p14q3.rdf.
a Make the necessary changes in the Data Model editor to include the
product name.
b In the Layout Model editor delete the product_id field and insert a
boilerplate object to display the product name. Rotate this object by
90 degrees.
c Run and test the report.
d Save the report as p14q4.rdf, and close it.

......................................................................................................................................................
14-24
15
................................

Coding PL/SQL Triggers


in Reports
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Objectives

At the end of this lesson, you should be


able to
• Describe the different types of trigger.
• Describe sample uses of triggers.
• Write and reference common code.
• Create a PL/SQL library.

15-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
15-2
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.

Objectives
At the end of this lesson, you should be able to:
• Describe the different types of trigger.
• Describe sample uses of the different types of trigger.
• Write and reference common code.
• Create and reference a PL/SQL library.

......................................................................................................................................................
15-3
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Types of Triggers in Reports


Report:
• Five triggers
• Report Trigger node in Object Navigator
Data Model:
• formula (column)
• filter (group)
• parameter validation
Layout:
• format trigger on most objects
15-3 Copyright  Oracle Corporation, 1998. All rights reserved.

Trigger Code
Parameter

boolean
Boolean:
true
false

Column

Number Character
Number
Date

15-4 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
15-4
Types of Triggers in Reports
......................................................................................................................................................

Types of Triggers in Reports


Introduction
You can code PL/SQL in a variety of triggers in a report to provide conditional or
additional processing at run time. This session discusses examples of each type of
PL/SQL trigger.

The Three Trigger Types


• Report:
- A set of five report-level triggers. Each trigger fires at a different stage of the
report execution.
- Access report triggers from the Report Triggers node in the Object
Navigator.
• Data Model:
- Column formula fires each time the column is processed.
- Group filter fires for each record in the group.
- Parameter validation fires when the runtime parameter form displays and
when the user leaves the parameter field.
- Access data model triggers in the property palette of a data model object—
column, group, or parameter—or the corresponding layout object—field,
repeating frame, or parameter field.
• Layout:
- Format triggers on most layout objects (excluding anchors). Each trigger
fires as the layout object is processed.
- Access format triggers in the property palette of a layout object.
Note: Report Builder does not allow data manipulation language (DML)
commands—INSERT, DELETE, UPDATE—in layout format triggers.

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 datatype in the function declaration.

......................................................................................................................................................
15-5
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Using Report Triggers


Before
Parameter F
Form

1 2 if readonly=yes 3

F
if > 1 page
After Between After
Before page1 page2
Parameter Pages Report
Report
Form
F F

15-5 Copyright  Oracle Corporation, 1998. All rights reserved.

1 If After Parameter Form returns FALSE, the cursor returns to the


runtime parameter form. If the runtime parameter form is not
displayed, control returns to the calling program.
2 If READONLY=Yes, Report Builder implicitly sets the read-only
transaction (SET TRANSACTION READONLY) after the Before
Report Trigger fires.
3 If READONLY=Yes, Report Builder implicitly ends the
read-only transaction (COMMIT) after the final page and before
the After Report Trigger fires.

......................................................................................................................................................
15-6
Using Report Triggers
......................................................................................................................................................

Using Report Triggers


Introduction
Report triggers enable you to execute PL/SQL functions at specific times during the
execution and formatting of your report. These triggers enable you to:
• Customize the formatting of your report
• Perform initialization tasks
• Access the database
Report triggers must return a boolean value—true or false.

Accessing the Report Triggers


You can access the report triggers from the Object Navigator. Open the Report
Triggers node and double-click on the object icon of the required trigger to open the
program unit.
Trigger Fires Use to
Before Parameter Before runtime parameter form dis- Access and change parameter
Form plays; fires even if parameter form values (initial or command line),
is suppressed global variables; create temporary
tables; insert into tables to be
queried
After Parameter After runtime parameter form Access and change parameter
Form displays; fires even if parameter values (initial, command line, or
form is suppressed user-entered); create temporary
tables; insert into tables to be
queried
Before Report Before a report executes: after que- Carry out initialization procedures
ries are parsed, but before records
are fetched
Between Pages Before each page is formatted, Carry out customized page
except the first page; in Previewer, formatting. Insert or update values
fires only once for each page, even in tables
if you revisit the page
After Report After you exit the Previewer, or Clean up initial processing, such as
after report output is sent to its deleting temporary tables
destination; fires on success only

......................................................................................................................................................
15-7
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Using Report Triggers


After Parameter Form
• Example: build dynamic WHERE clause
FUNCTION AfterPForm RETURN BOOLEAN IS
BEGIN
IF :p_customer IS NULL THEN
:p_where_clause := '';
ELSE
:p_where_clause := 'where id >= :p_customer';
END IF;
RETURN(TRUE);
END;

• Query syntax:
SELECT ID, NAME
FROM CUSTOMER
&p_where_clause
ORDER BY NAME

15-6 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
15-8
Using Report Triggers
......................................................................................................................................................

Creating a Dynamic Where Clause


Use the After Parameter Form report trigger to build a dynamic where clause
depending on the value of a bind parameter that the user enters at run time.
There are two possibilities at run time:
• The bind parameter is NOT NULL:
- The WHERE clause restricts the query; therefore, the Oracle server makes
use of an existing index when retrieving data.
• The bind parameter is NULL:
- The WHERE clause is also NULL; therefore, the Oracle server uses a full
table scan to retrieve all records.

......................................................................................................................................................
15-9
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Using Data Model Triggers


Group Filter
• Restrict records in a group.
• Perform PL/SQL for each record.
FUNCTION G_empGroupFilter RETURN BOOLEAN IS
BEGIN
IF :name = 'Operations' AND :salary > 3000 THEN
RETURN(my_function);
ELSE
RETURN(TRUE);
END IF;
END;

• PL/SQL filters result in ALL records


being fetched.
15-7 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
15-10
Using Data Model Triggers
......................................................................................................................................................

Using Data Model Triggers


Introduction
This section gives examples of:
• Using a PL/SQL group filter
• Validating a parameter value

Using a PL/SQL Group Filter


Use a group filter when you want to do the following:
• Restrict records in a specific group, depending on other processing in the report;
that is, when a WHERE clause in a query is not applicable
• Perform some PL/SQL processing for each record in a group
A group filter is useful when you want to restrict group values of a lower group in
the group hierarchy.
The function must return a boolean value:
• True: the record is included
• False: the record is excluded
Report Builder fetches all records and applies the group filter to each record.
Therefore, avoid group filters as a method of restricting many records in a group.
Note: You cannot add a filter to a matrix cross-product group.

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 palette for the G_emp group.
2 Change Group Filter to PL/SQL.
The PL/SQL Filter property appears.
3 Press the button for the PL/SQL Filter property to open the PL/SQL editor.
4 Enter the code. This filter code must return a boolean value, true or false.
Note: It is more efficient to use a WHERE clause in a query when possible. We
cannot use a WHERE clause in this case, because we want to process all records,
and call the function for some.

......................................................................................................................................................
15-11
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Using Data Model 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;

• You cannot reassign values to


parameters or columns in this trigger.
15-8 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
15-12
Using Data Model Triggers
......................................................................................................................................................

Validating a Parameter Value


Both system parameters and user parameters have a Validation Trigger property, in
which you can write a PL/SQL function to validate the value of the parameter.
The trigger code must return a boolean value—true or false—depending on whether
the validation is successful or not.
If the returned value is false, the cursor remains in the parameter and the user has
the following two options:
• Enter a different value
• Cancel the report
You can test the value of a parameter, but you cannot change the value. If you want
to assign a new value to the parameter, use the After Parameter Form report trigger.

Example
To prevent report output being sent directly to a printer, test the value of the
DESTYPE system parameter.
1 Open the property palette for the DESTYPE parameter.
2 Choose Validation Trigger to open the PL/SQL editor.
3 Enter the code; ensure the value Printer has an initial capital.

......................................................................................................................................................
15-13
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Using Layout 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

15-9 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
15-14
Using Layout Model Triggers
......................................................................................................................................................

Using Layout Model Triggers


Introduction
Most layout objects contain a format trigger; it is one of the common properties of a
layout object.
Format triggers enable you to modify the display of objects dynamically at run time
or to suppress display altogether.
The trigger must return a boolean value—true or false.
The following pages discuss some examples of format triggers.

Suppressing the Entire Layout for a Query


Since Report Builder is driven by the layout, you can use a format trigger on a group
frame to suppress conditionally the entire layout associated with a query. In this
case, the query does not retrieve any data.

Suppressing Individual Records


Do not use format triggers to suppress individual records that you can restrict on the
Data Model. For example, a format trigger on a repeating frame does not prevent
data from being retrieved, it simply determines whether or not you see it in the
output.
Therefore, it is more efficient to restrict individual records using the Maximum
Records property in a query or a First type of group filter when possible.
Note: Summaries compute against all data fetched by the Data Model. If you
suppress records in the layout only, summaries give misleading results.

......................................................................................................................................................
15-15
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Displaying a Text String in Place


of Column Headings
Dept: 10
Dept: f_deptno
Name Salary
Name Salary
No employees in
1 this department
Dept: 40
No employees in
this department

15-10 Copyright  Oracle Corporation, 1998. All rights reserved.

1 Boilerplate text: position behind column heading frame, or posi-


tion below and create collapsible anchor to column heading
2 Column heading frame does not display: suppressed by format
trigger

......................................................................................................................................................
15-16
Using Layout Model Triggers
......................................................................................................................................................

Coding a Format Trigger on a Frame

Requirement: Display a Text String In Place of Column Headings


Display a master-detail report for departments and employees. If a department has
no employees, suppress the detail column heading frame and display a piece of text
instead.

Steps
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;

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: Code format triggers at the highest possible level of the 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.

......................................................................................................................................................
15-17
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Dynamically Altering the Display


of Records
Employee Details
Employee Details
Ngao 08-MAR-90 2500
f_name f_date f_salary Biri 07-APR-91 1100
Employee 1000
Magee 14-MAY-90 Details
f_name f_date
Ngao 08-MAR-90
Biri 07-APR-91
2 Magee 14-MAY-90

1 3
15-11 Copyright  Oracle Corporation, 1998. All rights reserved.

1 One repeating frame is positioned behind the other or positioned


below with collapsing anchor
2 Report output run by payment clerks
3 Report output run by other employees

......................................................................................................................................................
15-18
Using Layout Model Triggers
......................................................................................................................................................

Coding a Format Trigger on a Repeating Frame

Requirement: Dynamically Alter the Display of Records Dynamically


In a report of employee details, display salaries if the user is a payment clerk, but
hide salaries and alter the appearance of remaining fields when any other employee
runs the report.

Steps
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):
function pay_clerks_see_this return boolean is
begin
if :user_type = ’PAY_CLERK’ then
return(true);
else
return(false);
end if;

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 the top
repeating frame (containing salary) has a solid fill.

......................................................................................................................................................
15-19
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Dynamically Hiding Fields

Employee Details
Employee Details

f_name f_date f_salary


Ngao 08-MAR-90 2500 1
Biri 07-APR-91 1100
Employee 1000
Magee 14-MAY-90 Details

Ngao 08-MAR-90
Biri 07-APR-91
Magee14-MAY-90

2
15-12 Copyright  Oracle Corporation, 1998. All rights reserved.

1 Report for payment clerks shows all fields


2 Report for other employees shows gap where salary is hidden

......................................................................................................................................................
15-20
Using Layout Model Triggers
......................................................................................................................................................

Format Trigger on a Field

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 does not display.

Steps
1 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;

In this example you do not need to create any additional layout object or code.

......................................................................................................................................................
15-21
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Suppressing Null Fields in a


Letter Heading
f_name
f_address1
f_address2 1
f_address3
f_address4
2
FUNCTION label_field RETURN BOOLEAN IS
Dear Sir, BEGIN
We are writing IF :address2
to advise .... IS NULL THEN
...... RETURN(FALSE);
...... ELSE
RETURN(TRUE);
END IF;
END;
15-13 Copyright  Oracle Corporation, 1998. All rights reserved.

1 Format Trigger on F_Address2 field references the column


ADDRESS2
2 Create anchors, with “Collapse Vertically”=Yes, on fields below
the suppressed field

......................................................................................................................................................
15-22
Using Layout Model Triggers
......................................................................................................................................................

Coding a Format Trigger on a Field

Requirement: Suppress Null Fields in an Address


The letter opposite includes a customer address. Address lines in a database
often have optional fields to provide for a variable number of lines in an address.
We want to suppress fields that are NULL, so that the address does not contain
large spaces between existing lines.

Steps
1 Code a format trigger on the optional field to suppress the field when the value is
NULL.
2 Create an anchor from the field below, up to the optional field. Set the “Collapse
Vertically” property to Yes. Repeat for all fields below the optional field to avoid
any unwanted space in the label.

......................................................................................................................................................
15-23
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Inserting Spacing Between


Groups of Records
f_1 f_2 f_3

1 2

3 4
FUNCTION spacing RETURN BOOLEAN IS
BEGIN
IF MOD(:count_column, 3) = 0 THEN
RETURN(TRUE);
ELSE
RETURN(FALSE);
END IF;
END;
15-14 Copyright  Oracle Corporation, 1998. All rights reserved.

1 Transparent rectangle 3 Summary column name


(created in Data Model)
2 Repeating frame, vertical 4 Format trigger on
elasticity = variable transparent rectangle

......................................................................................................................................................
15-24
Using Layout Model Triggers
......................................................................................................................................................

Coding a Format Trigger on a Boilerplate Object

Requirement: Insert Spacing Between Groups of Records


Display additional spacing between a defined number of records; for example,
group every three records together.

Steps
1 Create a transparent rectangle inside the repeating frame, to increase spacing
conditionally at run time.
2 In the repeating frame property palette, 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.

......................................................................................................................................................
15-25
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Writing Common Code


At Report level
• Object Navigator, Program Units
• Menu: Tools—>PL/SQL Editor
In a library
• Object Navigator, PL/SQL Library
• File—>New: create new library
• File—>Open: add to existing library
• Attach library to report

15-15 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
15-26
Writing Common Code
......................................................................................................................................................

Writing Common Code


Introduction
If you use the same program unit in several places in a report, or in multiple reports,
consider writing the code once as a report-level program unit, or in a PL/SQL
library, and then call the program unit when you require it in your PL/SQL trigger
code; this enables you to maintain the code in one place.
Even if you do not use the code many times, consider writing anything other than
very simple PL/SQL blocks at report level, to simplify maintenance.
Remember that you can also code stored procedures and functions in the database;
you must decide whether server-side or client-side processing is more efficient in
each case.

Two Ways to Create Report-Level Program Units


• In the Object Navigator, select the Program Units node and create a new
program unit.
• From the menu, select Program—>PL/SQL Editor. Choose New to create a new
program unit.

Writing Code as Report-Level Program Units


You can create a report-level program unit that contains a function, procedure, or
package, and that you call from any object in the same report. You cannot reference
a report-level program unit from a different report.

Three Ways to Create Library Program Units


• In the Object Navigator, select the PL/SQL Libraries node and create a new
library.
• From the menu, select File—>New—>PL/SQL Library.
• From the menu, select File—>Open to open an existing library and create
additional program units.

Referencing Code from a PL/SQL Library


You can reference library code in a report trigger by attaching one or more library to
one or more report definition, which enables you to reference the same code in
multiple reports.
To attach a library to a report, open the report definition, select the Attached
Libraries node in the Object Navigator, and add each library that you need in the
report.

......................................................................................................................................................
15-27
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Summary
Trigger types
• Report, Data Model, Layout
Examples
• Building a dynamic WHERE clause
• Validating a parameter value
• Dynamically altering record display
• Suppressing null fields
Common code
• Report-level program units
• PL/SQL libraries
15-16 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
15-28
Summary
......................................................................................................................................................

Summary
Using PL/SQL Triggers
Choose 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 or how they are
processed.
Layout triggers affect the way in which objects are formatted.

Writing Common Code


Use report-level program units or PL/SQL libraries for common code requirements
to improve productivity and maintenance.

Objects That Must Return a Value


The following table is a reminder of the Report Builder triggers that must always
return a value, and it shows the values that are acceptable.
Trigger Type Valid Values Result if False
Report trigger True, False Abort execution
Group filter True, False Do not process record
Validation trigger True, False Return to parameter form
Format trigger True, False Do not format object
PL/SQL Formula (column) Computation: Character, Not applicable
Number, Date

......................................................................................................................................................
15-29
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Practice 15 Overview

• Creating a format trigger to display


different layouts conditionally
• Creating and using a report-level
PL/SQL function
• Creating and using an external PL/SQL
library
• Creating a PL/SQL group filter

15-18 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
15-30
Practice Session Overview: Lesson 15
......................................................................................................................................................

Practice Session Overview: Lesson 15


This practice session contains:
• Creating a format trigger to display different layouts conditionally
• Creating and using a report-level PL/SQL function
• Creating and using an external PL/SQL library
• Creating a PL/SQL group filter

Introduction
In this practice session, you create a format trigger to display one of two layouts for
the same data, depending on a parameter value at run time. 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.

......................................................................................................................................................
15-31
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

Practice Session: Lesson 15


1 Create a new report, using p15q1.sql.
a Display the records in two different layouts, showing different
columns in each.
b Create a Group Above layout using the following columns from the
query:

Group Column
G_CUSTOMER CUSTOMER_ID
G_ID ID
DATE_ORDERED
DATE_SHIPPED
PAYMENT_TYPE
TOTAL

c Create a Tabular layout using the following columns from the query:

Column
ID
DATE_ORDERED
DATE_SHIPPED
TOTAL

d Ensure that only the Group Above layout displays when you choose
a destination of Screen, and only the Tabular layout displays when
you choose a destination of Preview.
To test the result, display the DESTYPE parameter in the report.
Ensure that you can enter a parameter value at run time.
e Save the report as p15q1.rdf.

......................................................................................................................................................
15-32
Practice Session: Lesson 15
......................................................................................................................................................

2 Continue with the previous report.


Modify the report so that the Tabular (“Preview”) layout displays an
a
extra column that indicates, with an asterisk, those orders that were
shipped more than 15 days after the order date.
b Remember to change destination to Preview during testing!
c Move the function code into a new PL/SQL library, named
p15lib.pll.
d Call the external function from your report, instead of calling the
report-level function.
e Save the report to p15q2.rdf.
3 Continue with the previous report.
a Modify the same layout to display additional spacing between every
two records.
b Save the report as p15q3.rdf and close it.

If You Have Time


4 Open report p15q1.rdf.
a Write your own group filter to restrict the number of customers
displayed depending on the value of a parameter that you enter at run
time.
Hint: You need to create two parameters, to keep track of how many records
have been processed compared to the cutoff number of records required.
b Test the report several times by changing the cutoff parameter at run
time.
c Save the report as p15q4.rdf.

......................................................................................................................................................
15-33
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................

......................................................................................................................................................
15-34
16
................................

Using the Report Builder


Built-In Package
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................

Objectives

At the end of this lesson, you should be


able to
• Describe the package contents.
• Output messages at run time.
• Execute a drill-down report.
• Create and populate temporary tables.
• Modify visual attributes dynamically.

16-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
16-2
Overview
......................................................................................................................................................

Overview
Introduction
This lesson provides examples of the contents and use of the Report Builder built-in
package. The package contains program units that you can reference in your
PL/SQL code.

Objectives
At the end of this lesson, you should be able to:
• Describe the contents of the Report Builder built-in package.
• Output messages at run time.
• Execute a drill-down report.
• Create and populate temporary tables within a report.
• Modify visual attributes dynamically at run time.

......................................................................................................................................................
16-3
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................

Contents of the SRW Package

SRW.BREAK SRW.DO_SQL
SRW.SET_ATTR SRW.RUN_REPORT

SRW.REFERENCE SRW.MESSAGE
SRW.USER_EXIT SRW.TRACE
SRW.SET_MAXROW SRW.PROGRAM_ABORT

16-3 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
16-4
Contents of the Report Builder Built-in Package
......................................................................................................................................................

Contents of the Report Builder Built-in Package


Introduction
The Report Builder built-in package, known as the SRW package, contains
procedures, functions, and exceptions that can help you to do the following:
• Control report execution
• Output messages at run time
• Initialize layout fields
• Perform DDL statements (create or drop temporary tables).
• Call user exits
• Dynamically set format attributes, such as font style and fill patterns

Referencing the Contents of the Package


You can reference any part of the SRW package in a PL/SQL statement within any
PL/SQL area of a report, such as a layout format trigger or a report-level trigger.

Rules
• You can only call the contents of the SRW package from within Report Builder.
Other tools, such as Form 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,
SRW.DO_SQL.

......................................................................................................................................................
16-5
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................

Outputting Messages
Warning
WHEN <exception> THEN
SRW.MESSAGE(999,
'Warning: report continues');

Error
WHEN <exception> THEN
SRW.MESSAGE(999,
'Error: report terminated');
RAISE SRW.PROGRAM_ABORT;

Exceptions
SRW.INTEGER_ERROR
SRW.NULL_ARGUMENTS
16-4 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
16-6
Outputting Messages
......................................................................................................................................................

Outputting Messages
Introduction
The SRW.MESSAGE packaged procedure displays a message with a code and text
string, which you specify. The message displays in the following format:
MSG-code: text

The message displays in a small dialog box. The user must acknowledge the
message before continuing.

Message Code and Text


You can enter a code number from zero up to 10 digits. If you enter a number of less
than five digits, the code displays with leading zeros.
You can enter a text string to a maximum of 190 characters, excluding the code
number. You can embed extra spaces to display your message neatly in the message
dialog box. Reports does not suppress extra spaces in the message text.

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 Report 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 either the code number, or text message,
or both.

......................................................................................................................................................
16-7
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................

Executing a Report
1 BLOGGS.LIS 2
BLOGGS xxx xxxxxxx
xxx xxxxxxx
SMITH
SMITH.LIS

JONES yyy yyyyyyy


yyy yyyyyyy
JONES.LIS
zzz zzzzzzz
SRW.RUN_REPORT zzz zzzzzzz

16-5 Copyright  Oracle Corporation, 1998. All rights reserved.

1 Output from master output


2 Output from detailed report

......................................................................................................................................................
16-8
Executing a Nested Report
......................................................................................................................................................

Executing a Nested Report


Introduction
Use SRW.RUN_REPORT to execute a second report from within a report process.
For example:
• Output parts of a report to different destinations
• Divide a large report into several smaller reports that can be run conditionally

Both Reports Use the Same Process


SRW.RUN_REPORT starts only one runtime process; it does not start a new
process for each report execution.

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.

......................................................................................................................................................
16-9
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................

Executing a Report
Example:
SRW.RUN_REPORT
('Report=EMPS
DESTYPE=FILE
DESNAME='||:LAST_NAME||'.LIS
BATCH=YES
MGRNO='||TO_CHAR(:ID));

Exceptions:
SRW.RUN_REPORT_FAILURE
SRW.RUN_REPORT_BATCHNO

Function:
SRW.GETERR_RUN

16-6 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
16-10
Executing a Nested Report
......................................................................................................................................................

Example Function Code


FUNCTION MGR_REP RETURN BOOLEAN IS
BEGIN
SRW.RUN_REPORT
(’REPORT=EMPS
DESTYPE=FILE
DESNAME=’||:LAST_NAME||’.LIS
BATCH=YES
MGRNO=’||TO_CHAR(:ID));
RETURN(TRUE);
EXCEPTION
WHEN SRW.RUN_REPORT_FAILURE THEN
SRW.MESSAGE(100, ’Error executing EMPS report’);
RAISE SRW.PROGRAM_ABORT;
END;

Note: Use LAST_NAME to create the output filename for each manager; use ID to
restrict the EMPS query.

Causes of Exceptions
Report 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.

Displaying Report Failure Message


If the detail report fails during execution, you can display information about the
cause by using the SRW.GETERR_RUN function.
Assign the function to a local PL/SQL character variable, which you display using
the SRW.MESSAGE procedure.
...
msg char(150);
...
EXCEPTION
WHEN SRW.RUN_REPORT_FAILURE THEN
msg := SRW.GETERR_RUN;
SRW.MESSAGE (100, msg);

......................................................................................................................................................
16-11
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................

Executing a Drill-Down Report


1 2

41 Details 42
xxxxxxxxx
42 Details
SRW.RUN_REPORT xxxxxxxxx
xxxxxxxxx
43 Details
xxxxxxxxx

16-7 Copyright  Oracle Corporation, 1998. All rights reserved.

1 Output from master output


2 Output from detailed report

......................................................................................................................................................
16-12
Executing a Nested Report
......................................................................................................................................................

Calling a Drill-Down Report


You can call the SRW.RUN_REPORT procedure from a button in your master
report and display the detail report in a second previewer window on the screen.

Steps to Create a Drill-Down Report


1 Create a button in the master report within the repeating frame.
2 Display the button property palette. Under the Button Behavior node, change the
Type property to PL/SQL, then select the PL/SQL Trigger property to display
the Program Unit editor.
3 Enter the function as described in the previous example. Do not include the
BATCH parameter, since you want to display the detail report interactively in a
second previewer.
4 Compile and close the Program Unit editor.
5 Run the master report.
For reports that you send to a file, do not include the pathname when coding the
DESNAME parameter. Allow the REPORTS30_PATH variable to search the correct
path for the report.

Testing Drill-Down Reports During Development


To test a drill-down report, use the Reports Runtime. Remember that buttons are not
active in the Report Builder Live Previewer.

......................................................................................................................................................
16-13
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................

Restricting Data
Before Report trigger
SRW.SET_MAXROW('Q_EMP',3);

Q_EMP ID LAST_NAME

G_EMP 1 BLOGGS
2 SMITH
ID 3 JONES
LAST_NAME

16-8 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
16-14
Restricting Data
......................................................................................................................................................

Restricting Data
Introduction
Use SRW.SET_MAXROW to restrict the maximum number of records you want to
retrieve for a specified query. Report 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 Report 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 runtime 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, Report 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.

......................................................................................................................................................
16-15
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................

Initializing Fields
Layout editor Output: logical
page no. = 2

Page: F_NEWPAGE
Page: 5

1
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;
16-9 Copyright  Oracle Corporation, 1998. All rights reserved.

1 Create format trigger on f_newpage field.


2 Set field value to my_page+3.

......................................................................................................................................................
16-16
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-95’)
The first argument is always 0 (zero); you can set the value of the current object.
These procedures are only relevant 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; Report Builder ignores the code and does not raise an error.

Why Use SRW.SET_FIELD?


You might want to retrieve the current logical page number and recalculate the value
before displaying it.

Example
Create a function to display the logical page number + 3 in a field called
F_NEWPAGE.
Because the logical page number variable is only available in the report layout, not
in the Data Model, you cannot calculate the value in a data column. Therefore, you
use a layout field to get the current page number and output a new number by
initializing the same field.
Make use of a packaged function 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.

......................................................................................................................................................
16-17
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................

Performing DDL Statements


Example
SRW.DO_SQL('CREATE TABLE SRW_LOG
(RPT_NAME VARCHAR2(40),
REC_NUM NUMBER,
MSG_TEXT VARCHAR2(80))');

SRW.DO_SQL('INSERT INTO SRW_LOG


(RPT_NAME, REC_NUM, MSG_TEXT)
VALUES
(''PAY_REPORT'', TO_CHAR(:ID),
:LAST_NAME||''PAY REPORT RUN'')');

Exception
SRW.DO_SQL_FAILURE
16-10 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
16-18
Performing DDL Statements
......................................................................................................................................................

Performing DDL Statements


Introduction
The SRW.DO_SQL packaged procedure executes any specified SQL statement
from within Report Builder.

Why Use SRW.DO_SQL?


Use SRW.DO_SQL to perform DDL statements dynamically, during run time. For
example, create a temporary table and insert rows into it during execution.
You can also perform DML statements using this procedure, but DML statements
run faster if you code them directly within a PL/SQL block. Only code DML
statements in the SRW.DO_SQL procedure if necessary. For example:
• To insert records into a permanent table in the database, code DML in a PL/SQL
block.
• To insert records into a temporary table that does not exist until run time, code
DML in SRW.DO_SQL.

Querying from Temporary Tables


If you wish to create a temporary table and reference it in a query in the same report,
the table must exist before the Before Report trigger fires. That is when Report
Builder parses its queries. Therefore, you must create this table in the Before
Parameter Form or After Parameter Form report trigger.

......................................................................................................................................................
16-19
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................

Setting Format Attributes


Attributes
Mask = eyes, nose, mouth

Values
Eyes = glasses
Nose = big
Mouth = mustache

Apply
Wear the mask
16-11 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
16-20
Setting Format Attributes
......................................................................................................................................................

Setting Format Attributes


Introduction
The SRW.SET_ATTR packaged procedure applies specified formatting attributes to
the current layout object: frame, repeating frame, field, or boilerplate object.

Why Use a Format Mask?


• To highlight values over or under a specified limit: for example, stock limits
• To display or hide layout objects conditionally, depending on values in a
repeating frame, or on runtime parameter values

Three Steps to Use a Format Mask


Applying a format mask in a report is analogous to wearing a mask on your face.
1 Specify the attributes you wish to affect.
2 Specify the values you wish these attributes to have.
3 Apply the mask to the object.

Coding a Format Mask


You can code the steps above in a function as a report-level program unit, or in a
PL/SQL library. This is useful if you want a common format mask in more than one
object or more than one report. You can then call the function whenever required,
from the format trigger of a specific object.
You might create a library that consists of several different masks.
As an alternative to a PL/SQL library, in the Object Navigator you can drag and
drop report-level program units between different reports. However, note that this
creates a copy of the program unit in each report, rather than a reference to one
piece of code.

......................................................................................................................................................
16-21
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................

Setting Format Attributes

What attributes?
SRW.ATTR.MASK := SRW.GCOLOR_ATTR +
SRW.WEIGHT_ATTR;

What values?
SRW.GCOLOR_ATTR := 'magenta';
SRW.WEIGHT_ATTR := SRW.BOLD_WEIGHT;

Apply mask
SRW.SET_ATTR(0,SRW.ATTR);

16-12 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
16-22
Setting Format Attributes
......................................................................................................................................................

Example
Conditionally set the following attributes if salary equals 2000:
Attribute Value
Text weight Bold
Text style Underline
Text color Magenta
Text justification Centered

FUNCTION SAL_MASK RETURN BOOLEAN IS


BEGIN
IF :SALARY = 2000 THEN
SRW.ATTR.MASK := SRW.WEIGHT_ATTR +
SRW.STYLE_ATTR +
SRW.GCOLOR_ATTR +
SRW.HJUST_ATTR;
SRW.ATTR.WEIGHT := SRW.BOLD_WEIGHT;
SRW.ATTR.STYLE := SRW.UNDERLINE_STYLE;
SRW.ATTR.GCOLOR := ’MAGENTA’;
SRW.ATTR.HJUST := SRW.CENTER_HJUST;
SRW.SET_ATTR(0,SRW.ATTR);
END IF;
RETURN(TRUE);
END;

Using Format Masks in Character-Mode Reports


Some attributes are applicable to character environments only; some are for
bitmapped environments only.
If you include a bitmapped attribute, then run the report in character mode, or the
reverse, Report Builder ignores the code and does not cause an error. This enables
you to develop a report for use in a different environment.

......................................................................................................................................................
16-23
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................

Summary
Package contents
• Procedures
• Functions
• Exceptions:
– SRW.PROGRAM_ABORT to exit
Examples
• Drill-down report
• Support for DDL statements
• Conditional layout formatting and display
16-13 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
16-24
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:
- Drill-down reports, using SRW.RUN_REPORT in a button
- 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 layout formatting and display using SRW.SET_ATTR and the
many SRW attributes

......................................................................................................................................................
16-25
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................

Practice 16 Overview

• Building a report containing conditional


highlighting
• Building a drill-down report
• Writing to a temporary table from a
report

16-14 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
16-26
Practice Session Overview: Lesson 16
......................................................................................................................................................

Practice Session Overview: Lesson 16


This practice session contains:
• Building a report containing conditional highlighting
• Building a drill-down report
• Writing to a temporary table from a report

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 separate report from a button in
the previewer.
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.

......................................................................................................................................................
16-27
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................

Practice Session: Lesson 16


1 Open report p8q5.rdf.
a Display the column CUST_TOTAL in the customer group as red
bold italics if its value is 10,000 or more.
Hint: use the following mask attributes:
Mask Attribute Suggested Values
SRW.ATTR.GCOLOR red
SRW.ATTR.WEIGHT SRW.BOLD_WEIGHT
SRW.ATTR.STYLE SRW.ITALIC_STYLE

You can import the file p16q1a.txt.


b Alter the pattern and color of those records where the customer total
is 5000 or less.
Hint: use the following attributes:
Mask Attribute Suggested Values
SRW.ATTR.FILLPATT (fill pattern) crisscross, sandpaper
blue, cyan, green, magenta, red,
SRW.ATTR.BFCOLOR (background fill) yellow
SRW.ATTR.FFCOLOR (foreground fill)

You can import the file p16q1b.txt.


c Write the necessary format triggers.
d Save the report as p16q1.rdf.
2 Call a drill-down report, using a button.
a Continue with the previous report.
b Alter query Q_2 to include the customer ID, but do not display it in
the report.
c Add a button to this report, to display a drill-down report when the
button is pressed at run time. The button should display once for
every customer record.
d When the button is pressed, the detail report (p12q1.rdf) is called
with the customer ID as a parameter.
Hint: Have a look at report p12q1.rdf to check the name of the
parameter.
You can import the file p16q2d.txt.

......................................................................................................................................................
16-28
Practice Session: Lesson 16
......................................................................................................................................................

e Save the report as p16q2.rdf.


f Test the report using the runtime executable and the close the
runtime.

If You Have Time


3 Open report p9q1.rdf.
In this report, you use report triggers to create a temporary table at the start of
report execution and insert rows into the table at various stages of the execution.
a Write a trigger that creates a temporary table to hold the date and
userid each time the report is run. The table should contain three
columns: one date column, one character column of width 10, and
one character column of width 80.
CREATE TABLE RUNREPORT
(DATE_RUN DATE, USER_RUN VARCHAR2(10), COMMENTS VARCHAR2(80)

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 Save the report as p16q3.rdf.
d Compile the PL/SQL and run the report. Make sure you view more
than one page.
e Run and test the report.
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;

......................................................................................................................................................
16-29
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................

i Try running the report more than once. When you run the report a
second time, the table already exists and Report 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 and run the report. Verify the results in SQL*Plus.

......................................................................................................................................................
16-30
17
................................

Maximizing Performance
Using the Reports Server
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

Objectives

At the end of this lesson, you should be


able to
• Distinguish between local client and
remote server reporting.
• Describe the three-tiered architecture of
Report Builder.
• View and schedule server-side reports
using the Queue Manager.

17-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-2
Overview
......................................................................................................................................................

Overview
Introduction
In this lesson you learn how to control and monitor a remote Reports Server
installation, and how to view and schedule reports sent from a client to the Reports
Server.

Objectives
At the end of this lesson, you should be able to:
• Distinguish between local client and remote server reporting.
• Describe the three-tiered architecture of Report Builder.
• View and schedule server-side reports using the Queue Manager.

......................................................................................................................................................
17-3
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

Why Use a Remote Server?

Client reporting
• All processing and
formatting is done on the
client.
– Suitable for small and
medium size reports.
DB
• Everyone runs the same
report again and again,
Developer/2000
no sharing.
Release 1
17-3 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-4
Why Use a Remote Server?
......................................................................................................................................................

Why Use a Remote Server?


Introduction
This section compares and contrasts the features of running reports on a local client
and on a remote server.

Formatting Reports on a Local Client


When you run a report on the client, the client machine has to do all the formatting.
For small to medium-sized reports, this processing might not require much time and
effort. However, for large reports the length of time needed by the client can be very
inconvenient.

Rerunning the Same Report


When running reports locally on the client, several users often run the same report
on their own machine; therefore, the report might run many times, which is
unnecessary if the required output already exists.

......................................................................................................................................................
17-5
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

Running Reports on a Remote


Server
Benefits of the Reports
Server (R30MTS)
• Formats, prints
reports on a powerful R30MTS
server
• Eliminates rerunning R30RUN R30RUN R30RUN

reports
DB DB
• Enhances scalability
and performance Developer/2000
Release 2
17-4 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-6
Why Use a Remote Server?
......................................................................................................................................................

Running Reports on a Remote Server


Developer/2000 Release 2 provides a powerful and intelligent Reports Server that
resides on a high performance server machine that is capable of processing and
formatting your reports at high speed and that can return the completed output to the
client machine.
The Reports Server is a single process, and dynamically manages a set of report
runtime engines. Each Reports Runtime engine is responsible for executing a single
report at any given time; each engine can reside in memory to execute additional
report requests over a period of time.

Benefits of the Reports Server


• Reports are formatted on a high-performance NT or UNIX server.
• The Reports Server detects duplicate reports. Users can share output without
rerunning the report.
• The Reports Server caches the output in a central repository on the server
machine.
• You can implement multiple runtime engines for one Reports Server.
• You can implement multiple Reports Servers on one machine.

......................................................................................................................................................
17-7
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

Reports Server Architecture


(Thin) Client
Queue Manager
R30CLI R30RQM

Application server
(Unix/NT) R30MTS

R30RUN ... R30RUN ... R30RUN

DB
server DB DB
17-5 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-8
Reports Server Architecture and Configuration
......................................................................................................................................................

Reports Server Architecture and Configuration


Introduction
This section details the three-tiered architecture of remote server reporting and
discusses the commands to invoke a report on the remote server. You also learn how
to install and connect to the Reports Server.

The Three-Tiered Architecture

Client Tier
The client tier is a front-end machine that sends commands to the remote Reports
Server.
• Invoke the executable R30CLI to schedule a report from the command line.
• Invoke the Queue Manager (R30RQM) to view and schedule reports.
• Start up the Reports Server manually from the Queue Manager, or start it from
the command line.

Application Tier
The middle application tier contains the remote Reports Server, which can consist
of multiple runtime engines.
• You can use multiple Reports Servers to execute reports.
• A Reports Server spawns extra runtime engines as necessary, depending on a
parameter in a server initiation file.
• Each runtime engine dies off when there are no jobs to run and when it has been
idle for a set time.

Database Server Tier


The database server resides on a back-end machine. This can be the same machine
as the application tier.
• The same Reports Server, and the same runtime engine, can connect to different
database aliases for each report run.

......................................................................................................................................................
17-9
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

Parameters for R30CLI


• SERVER = <tnsname>
• REPORT = <report.rdf>
• DESTYPE = FILE, PRINTER, MAIL,
CACHE, LOCALFILE, SYSOUT
• DESNAME = <output directory>
• DESFORMAT = PDF, DFLT, HTML,
HTMLCSS
R30CLI32.EXE SERVER=repserver1
REPORT=my_rep.rdf DESTYPE=FILE
DESNAME=my_rep.pdf DESFORMAT=pdf
17-6 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-10
Reports Server Architecture and Configuration
......................................................................................................................................................

Parameters for Running a Remote Report


• R30CLI sends a request to the Reports Server.
• R30CLI is invoked by a CGI script. There is a CGI version available for Web
servers (R30CGI).
• SERVER=<tnsname>, where <tnsname> is an alias for your Report Server that
you create in <oracle_home>\network\admin\tnsnames.ora. We discuss the
Reports Server name and parameters later in this lesson.
• You cannot set DESTYPE to Screen or Preview when using R30CLI.
• HTMLCSS uses cascading style sheets, available in Netscape 4.0. (Netscape 3.0
does not support HTMLCSS.)
Note: R30CLI also accepts the same parameters as the Reports Runtime, R30RUN.

Running a Remote Report from the Command Line

Example
1 Invoke the command line. In Windows NT, Choose Start—>Run.
2 Enter the command string, for example:
R30CLI32.EXE SERVER=repserver1 REPORT=my_rep.rdf DESTYPE=FILE
DESNAME=my_rep.pdf DESFORMAT=pdf

This command sends the report to the remote server, and the report runs
immediately.

Returning Control to the Client


Include BACKGROUND=yes in your R30CLI command line, and then R30CLI
returns immediately after submitting a job request to the Reports Server.

......................................................................................................................................................
17-11
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

The Schedule Parameter

SCHEDULE = [FREQ from] TIME

R30CLI...
SCHEDULE=hourly_from_09:00am_May_01,_1999

FREQ CLOCK DATE

TIME
17-7 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-12
Reports Server Architecture and Configuration
......................................................................................................................................................

The Schedule Parameter


SCHEDULE is a scheduling parameter that you can include in the R30CLI
command line to control the time and frequency with which your report runs.
The syntax of the SCHEDULE parameter comes primarily from the syntax of a
“cron” job on Unix. To avoid quoting the schedule string use underscores (_) instead
of spaces.
The default is to run the report immediately.

Syntax
The full syntax of the SCHED
ULE parameter is:
where:
TIME = CLOCK [DATE] [INCR]
CLOCK = <hh:mm>
DATE=<calendar date>
INCR = {+LEN} | {next SUFFIC}
LEN = {n} * SUFFIX
SUFFIX = <time, date, FREQ>
[FREQ from] TIME

Example
SCHEDULE=hourly_from_09:00am_May_01,_1999

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 we use
later in this course.

......................................................................................................................................................
17-13
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

Reports Caching

Cached reports on server


• Tolerance = nn (minutes)
• Tolerance = 0 (default/current behavior)
• Maximum tolerance is 232 minutes
(approximately 10,000 years)
• Cached output controlled by a server
parameter CACHEDIR

17-8 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-14
Reports Server Architecture and Configuration
......................................................................................................................................................

Reports Caching
Include the TOLERANCE parameter in your command line to cache the report
output for a specified number of minutes.
Setting TOLERANCE=60 means that the Reports Server 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
The Reports Server uses a parameter CACHEDIR to determine where to place the
cached output.
The default directory is <oracle_home>\report30\server\cache.

......................................................................................................................................................
17-15
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

Reports Server Configuration


Parameters

Installing a Reports Server on Windows NT


• Service example (normal):
R30MTS32 -install my_server tcpip

• Non-service (less common):


R30MTS32 -listen my_server INITENGINE=2 MINENGINE=1

– Command line values override server


.ora file
17-9 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-16
Reports Server Architecture and Configuration
......................................................................................................................................................

Reports Server Configuration Parameters


When you first install a Reports Server, it creates a .ora file with the same name as
the server. The file exists in <oracle_home>\report30\server, and you can edit the
parameters in the file.
You can start up the Reports Server manually as a non-service; however, on
Windows NT it is more common to install the server as a service.
• Service: All parameters have default values that you can modify in the server
.ora file.
• Non-service: You can initialize some parameters on the command line when you
start up the server.

Server File Contents


The following parameters exist in the <server>.ora file, and are also available on
the command line, if installing manually as a non-service:

Parameter Description
NAME A server name that exists in tnsnames.ora file
INITENGINE Number of runtime engines running after you invoke Reports Server
MINENGINE Minimum number of engines running per server at any time; default = 0
MAXENGINE Maximum number of engines running per server at any time; default = 1
MAXIDLE Maximum time for an engine to remain idle before it is shut down;
default = 30 (minutes)

......................................................................................................................................................
17-17
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

Reports Server Configuration


Parameters
Server .ORA file in
<oracle_home>\report30\server
MAXCONNECT=20
CACHEDIR="C:\ORAWIN95\REPORT30\server\cache"
CACHESIZE=50
SOURCEDIR="C:\develop\reports"
INITENGINE=1
MINENGINE=1
MAXENGINE=3
MAXIDLE=30
SECURITY=1
ENGLIFE=200
17-10 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-18
Reports Server Architecture and Configuration
......................................................................................................................................................

Reports Server Configuration Parameters


Additional <servername>.ora parameters:

Parameter Description
INTERACTIVE Enable Reports Server to send output to screen/preview (Y or N)
MAXCONNECT Number of Reports Server connections and number of ISV connections
SOURCEDIR Directory that Reports Server initially searches for source (.rdf, .rep)
file
CACHEDIR Output directory of cached report
CACHESIZE Size determines how big cache can be
TEMPDIR Directory that Reports Server uses for temporary filespace; if not speci-
fied, default = REPORTS30_TMP path
SECURITY Level of access, 0 to 3, for accessing cached output files through Queue
Manager. 0 = anyone; 1 = same userid, 2 = same process, 3 = none;
default = 1
ENGLIFE Maximum number of reports run before engine shuts down and is
replaced; default = 200

Log File Contents


A <servername>.log file in the same directory contains an administrative actions
log, which includes the following information:
• Shutdown time
• Startup time
• Engine start and stop time

How Parameters Control Runtime Engines


To conserve application server resources, excess or idle report engines remove
themselves from memory for one of the four following reasons:
• When an engine is idle for a [MAXIDLE] period of minutes, an engine removes
itself from the process table and frees up any associated resources.
• When an engine has run its [ENGLIFE] number of jobs, the reports engine dies
gracefully, to be replaced by another engine.
• In response to changes to the maximum number of engines [MAXENGINE],
excess engines are removed.
• When the multitiered Reports Server shuts down.

......................................................................................................................................................
17-19
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

Connecting to a Reports Server

• TNSNAMES.ORA in
<oracle_home>\network\admin
my_server = (ADDRESS = (PROTOCOL = TCP) (Host =
144.25.87.137)(Port = 1949) )

• Alias name identifies Reports Server


• Use different port number for multiple
servers on same machine
• Supported protocols: NAMED PIPES,
TCP/IP
17-11 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-20
Reports Server Architecture and Configuration
......................................................................................................................................................

Connecting to a Reports Server


When you install the Reports Server, the server name must already have an entry in
the tnsnames.ora file on the remote server machine.
The client machine must also contain an entry in the local tnsnames.ora file.
Modify your local tnsnames.ora file to include lines like that opposite for each
Reports Server. Place the entry on one line only. Use the name as a Reports Server
alias name.
• R30MTS uses the alias name on the remote machine to identify which server
you want to start:
R30MTS name=my_server maxengine=2...

• R30CLI uses the alias name on the client machine to identify the server to which
you want to send your report:
R30CLI server=my_server report=my_report...

Technical Note
The Reports Server requires SQL*Net 2.3. When installing Report Builder, the
Installer knows this is a dependency and installs it if necessary.
Reports supports the following protocols: NAMED PIPES, and TCP/IP.
If you have a sqlnet.ora file with a default domain, you must make sure that you
specify the domain in your tnsnames.ora file when entering the server name. For
example, my_server.world=(). Alternatively, if you do not use your
sqlnet.ora file, remove or rename it.

......................................................................................................................................................
17-21
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

What Is the Queue Manager?

Real-time Reports Server status


• View report status and scheduled jobs
• Refresh to see the up-to-date status
• Reprioritize or cancel jobs

• Administrator password encrypted in


.ora file
17-12 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-22
Viewing and Scheduling Reports in the Queue Manager
......................................................................................................................................................

Viewing and Scheduling Reports in the Queue Manager


Introduction
This section explains the features of the Queue Manager and how to use it to view
and schedule reports in an easy-to-use GUI interface.

What Is the Queue Manager?


The Queue Manager is a facility that enables users and administrators to view the
current status of each report.
You can see the time that each report started and finished and whether it terminated
successfully or with an error.
You can also view jobs that are scheduled to run at a future date or time.
You can reprioritize or cancel your own scheduled jobs. Administrators can
reprioritize or cancel any scheduled jobs.

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 Server. At the
login prompt, choose any username and password to assign as Administrator.

......................................................................................................................................................
17-23
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

Queue Manager
Past jobs
Current jobs
Scheduled jobs

17-13 Copyright  Oracle Corporation, 1998. All rights reserved.

Queue Manager
All my jobs
All jobs
Refresh

17-14 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-24
Viewing and Scheduling Reports in the Queue Manager
......................................................................................................................................................

Viewing Report Jobs


The Queue Manager status bar enables you to switch between different views of
report jobs.

Icon Name Description


Show Past Jobs Displays jobs that have already run for a given Reports Server
Show Current Jobs Displays jobs that are currently running
Show Scheduled Jobs Displays scheduled jobs, in order to reprioritize or cancel a job

Viewing Different Owners’ Jobs


The Queue Manager status bar enables you to restrict the view of jobs by owner.

Icon Name Description


Show all My Jobs Displays your reports for a given Reports Server
Show all Jobs Displays all reports for a given Reports Server

Displaying Up-to-Date Job Status


Choose Refresh on the status bar to refresh the screen and display the up-to-date
status.
The default update interval is every 15 seconds. You can alter this interval in the
Queue Manager preferences screen:
Options—>Preferences—>Polling Interval

......................................................................................................................................................
17-25
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

Using the Queue Manager


RSVR1
Queue
Manager RSVR2

• Connect to any number of servers


• Administrator can shut down server
• Reports Server restores scheduled jobs
after shutdown

17-15 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-26
Viewing and Scheduling Reports in the Queue Manager
......................................................................................................................................................

Connecting to a Reports Server


You can connect to any Reports Server by changing the server name in the Queue
Manager status bar.

Shutting Down a Reports Server


You can shut down the Reports Server from the Queue Manager menu if you have
Administrator privileges:
Queue—>Shutdown

This option remains grayed out if you are not logged on as administrator.

Retaining Scheduled Jobs After Shutdown


The Reports Server maintains a list of all scheduled jobs in a file,
<oracle_home>\report30\server\<servername>.dat. If the Reports Server shuts
down and restarts for any reason, it reads this file at startup and restores all
scheduled jobs.

......................................................................................................................................................
17-27
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

Reports Server ActiveX Control

• <oracle_home>\bin\R30SXU32.OCX
• Embed in any ActiveX container
• Run report with a call to:
– R30RBE
– R30MTS

17-16 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-28
Viewing and Scheduling Reports in the Queue Manager
......................................................................................................................................................

The Reports Server ActiveX Control


The Developer/2000 installation provides an ActiveX control, which you can use
from other Windows applications to invoke the remote Reports Server and schedule
your reports.
The ActiveX control is R30SXU32.OCX. This control displays the Queue Manager.
You can embed this control in any ActiveX container.

Remote or Local Remote Reporting


The ActiveX control can run a report by a synchronous, or an asynchronous call to
the remote Reports Server; it can also run a report by calling the Reports
Background Engine.

......................................................................................................................................................
17-29
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

Summary
Reports Server provides
• Increased efficiency
• Three-tiered architecture
• Reports client (R30CLI)
• Reports Server (R30MTS)
• Reports caching
• Status view and rescheduling (R30RQM)
• ActiveX control for other applications

17-17 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-30
Summary
......................................................................................................................................................

Summary
The new remote Reports Server provides increased efficiency and scalability for
large reports.
The Queue Manager provides an easy-to-use GUI for viewing and scheduling report
jobs.
By caching report output, you can ensure that users do not rerun common reports
unnecessarily.
You can embed the Reports Server ActiveX control in other Windows applications,
to run and schedule reports.

......................................................................................................................................................
17-31
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

Practice 17 Overview

• Running a report on your local machine


• Running reports on a remote server
using the Queue Manager
• Copying output from a remote server to
your local machine
• Running a report on a remote server
using the command line

17-18 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
17-32
Practice Session Overview: Lesson 17
......................................................................................................................................................

Practice Session Overview: Lesson 17


This practice session contains:
• Running a report on your local machine
• Running reports on a remote server using the Queue Manager
• Copying output from a remote server to your local machine
• Running a report on a remote server using the command line

Introduction
In this practice session you run a report locally and then on a remote server, using
the Queue Manager. You also use the Queue Manager to view the submitted jobs.
If you have time, you can submit a report to a remote server using the command line
options.

......................................................................................................................................................
17-33
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................

Practice Session: Lesson 17


1 Run longrun1.rdf on your local client machine.
aOpen longrun1.rdf and run the report. Notice the time it takes for the
report to run to completion. If it has not completed within five
minutes, note how many pages have been formatted, then cancel the
report.
Note: Change Destination Type to File in the runtime parameter
form when running this report.
2 Run longrun1.rdf and longrun2.rdf by calling the Reports Server from the
Queue Manager.
Note: Your instructor will give you specific instructions to complete this
exercise. The location of the remote server, directory paths, and so on, might
differ for your class.
a Invoke the Queue Manager. Enter repserver1 as your server
name. Note if there are any jobs in the queue.
b Schedule a new job to run longrun1.rdf report on the Reports Server.
Choose applicable settings from the tab pages of the Queue Manager.
For Destination Type, choose ToLocalFile, ToFile, or Cache; the
report default is Screen, which is not valid when running a remote
report.
c Do the same for longrun2.rdf.
d Display all jobs to see where your jobs are queued in relation to the
reports of other students.
e Display all your own jobs only.
f Refresh the screen several times to see how quickly the report pages
are formatted.
g Cancel your own longrun2.rdf from the server queue.
3 When the report longrun1.rdf has finished, copy the output to a filename,
longrun1.pdf, in your home directory.

If You Have Time


4 Run longrun1.rdf by scheduling a new job from the command line.
a Using R30CLI from the command line, submit your longrun1.rdf
report to the Reports Server.
b Ensure the output is in PDF format and that it is cached.

......................................................................................................................................................
17-34
18
................................

Building Reports for


Different Environments
Lesson 18: Building Reports for Different Environments
......................................................................................................................................................

Objectives

At the end of this lesson, you should be


able to
• Build reports for different GUIs.
• Build character mode reports.
• Build reports to run in other languages.

18-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
18-2
Overview
......................................................................................................................................................

Overview
Introduction
Developer/2000 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 learn how to build
reports to run on various platforms, and in different environments and languages.

Objectives
At the end of this lesson, you should be able to:
• Build and run reports in different environments, using the MODE parameter.
• Describe the considerations when building reports for different graphical user
interfaces (GUIs).
• Recognize the settings necessary to build character mode reports.
• Describe the facilities available for building reports to run in other languages.

......................................................................................................................................................
18-3
Lesson 18: Building Reports for Different Environments
......................................................................................................................................................

Different Development and


Runtime Environments

Report Builder development


• Bitmapped only
Runtime
• Bitmapped MODE = bitmap
• Character mode MODE = character

18-3 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
18-4
Different Development and Runtime Environments
......................................................................................................................................................

Different Development and Runtime Environments


Introduction
Although you always develop your reports in a bitmapped environment, the
production reports can run in either bitmapped or character mode.
Therefore, you can develop a report in a bitmapped environment that is to run in a
character mode environment.

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.

Character Mode Environment


This environment has a unit of character, typically 80x24, and rarely supports a
mouse. Interaction with the host computer is at field level, that is, when the user
navigates from the field.
A report that runs in character mode cannot display any graphics features, such as
images, drawings, or multimedia objects.

Running a Character Mode Report from the Builder


You can test your character mode reports very easily in the bitmapped Report
Builder and view the report output in the Previewer.
The execution of the report as bitmapped or character simply depends on a system
parameter called MODE. You can change this parameter in Report Builder, to test
the character output during your report development.

......................................................................................................................................................
18-5
Lesson 18: Building Reports for Different Environments
......................................................................................................................................................

Developing Reports to Run in


Different GUIs

• Use common fonts


– Or map fonts in uifont.ali
• Use common colors
• Beware of DPI (dots per inch)

18-4 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
18-6
Developing Reports to Run in Different GUIs
......................................................................................................................................................

Developing Reports to Run in Different GUIs


Introduction
There are a few points you should consider when moving a report from one GUI to
another, since the following GUI differences may affect the report output.

Use Common Fonts


If possible, use fonts that you know exist on the target GUI; otherwise, remember to
set up your font alias file so that the fonts that you use during development map to
existing similar fonts on the target GUI.

Example
In 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 uifont.ali file on UNIX (motif), map Microsoft Windows fonts to Motif:


/* Microsoft Windows fonts */
”Courier New” = lucidatypewriter
”Times New Roman”= lucidabright

Use Common Colors


If possible, use a color that you know exists on the target GUI; otherwise, use one
that maps well to the default color of the target GUI.

Beware of Dots-Per-Inch
The dots-per-inch (DPI) might differ between machines, even if they both use the
same GUI. This only affects how alphanumeric characters wordwrap on the screen.
Therefore, if you design a report that displays in the previewer, try to use the same
DPI as the users who will eventually run the report.

......................................................................................................................................................
18-7
Lesson 18: Building Reports for Different Environments
......................................................................................................................................................

Building Character Mode


Reports
• Use predefined character mode
template
• Modify report properties
• Avoid GUI objects: graphics, buttons,
OLE2
• Avoid borders

18-5 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
18-8
Building Character Mode Reports
......................................................................................................................................................

Building Character Mode Reports


Introduction
Because of the difference between GUI and character mode environments, and the
limitation of character mode, consider the following points during development.

Set Report-Level Properties


Define character mode settings before creating any part of your report layout, in
preparation for running in character mode. There are two methods:
• Select the character mode template in the Report wizard. This is the simplest
method. You can copy and modify the template to create character-mode
templates with different settings.
• Open the report property palette and modify the character mode settings.
Always select Use Character Units in Designer when developing character
reports.

Avoid Graphics, Buttons, and OLE


Avoid using graphic objects. When executing a report in character mode, Report
Builder converts all boilerplate objects (except rectangles, lines and text) to
rectangles, as well as any field with a nontext source (for example, a file column
referencing a multimedia file) and any Graphics Display.
To include graphics, you can choose to show the area that contains a graphic object
by selecting the Convert Bitmapped Objects to Boxes check box in the Character
Mode tab of report properties. This option displays an empty rectangle with a
border in place of the graphic object.

Avoid Borders
Border behavior differs between the environments. If you must use borders in
character mode reports, select the Convert Borders check box under the character
mode in the report property palette. This option displays borders in the Layout
editor more effectively.

......................................................................................................................................................
18-9
Lesson 18: Building Reports for Different Environments
......................................................................................................................................................

Building Character Mode


Reports
Also Consider:
• Font
• Color
• Fill patterns
• Format attributes
• Printer codes

18-6 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
18-10
Building Character Mode Reports
......................................................................................................................................................

Font
Choose a font, before creating any layout, which converts successfully to
ASCII/EBCDIC characters, such as Courier. The character template provides a
suitable font.
Text styles of Underline, Inverted, and Blink convert to character mode attributes
Underline, Reverse Video, and Blink, but only if you use a character mode terminal
definition that supports those attributes. Similarly, the text weight of Medium may
convert to bold.

Color
Avoid the use of color; Report Builder assigns colors to fill patterns.

Fill Patterns
Avoid the use of fill patterns; a transparent fill successfully converts to a character
mode transparent fill, but all other fill patterns convert to a solid fill.

Format Attributes
Only certain mask attributes apply in character mode when using the
SRW.SET_ATTR procedure. Report Builder ignores bitmapped codes when
running the report in character mode, and vice versa. You can therefore include both
bitmapped and character-mode attributes in the same report if you want it to run in
both environments.

Printer Codes
You can include printer codes in your reports in preparation for running in character
mode; Report Builder ignores the codes if you run the report in bitmapped mode.

......................................................................................................................................................
18-11
Lesson 18: Building Reports for Different Environments
......................................................................................................................................................

Setting NLS Language


Environment Variables
• NLS_LANG
• DEVELOPER_NLS_LANG,
USER_NLS_LANG

NLS_LANG=French_France.WE8DEC

• UNICODE
NLS_LANG=<lang>_<territory>.AL24UTFFSS

18-7 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
18-12
Building Reports to Run in Different Languages
......................................................................................................................................................

Building Reports to Run in Different Languages


Introduction
This section gives a brief overview of the features in Oracle and
Developer/2000 that provide support for building multilingual applications:
• Switching languages using Oracle’s National Language Support (NLS)
• Translating an application using the Developer/2000 Translation Builder

Setting NLS Language Environment Variables


Three language environment variables are available:
• NLS_LANG
• DEVELOPER_NLS_LANG
• USER_NLS_LANG
DEVELOPER_NLS_LANG and USER_NLS_LANG take the same parameter as
NLS_LANG. Use them as an alternative to NLS_LANG when you need to use two
sets of resource and message files at the same time; for example, if you prefer to
develop using English but need to build an application in another language.

Syntax
NLS_LANG = <language>_<territory>.character_set

• Language: language conventions for displaying messages, and day and month
names
• Territory: conventions for default date format, and for displaying currency,
decimal and thousands symbols
• Character_set: character set in which data is displayed

Example
NLS_LANG=French_France.WE8DEC

Using Unicode in Developer/2000


Unicode (UCS-2) is a fixed-length two-byte character set that represents up to
65,536 characters.
Using Unicode in Developer/2000 enables you to display multiple languages in one
application, without switching character sets.

Syntax
NLS_LANG = <language>_<territory>.AL24UTFFSS

......................................................................................................................................................
18-13
Lesson 18: Building Reports for Different Environments
......................................................................................................................................................

Translating a Developer/2000
Application
Use Translation Builder to:
• Extract strings; import into repository
• Execute translation
• Merge back into original resource
Consider:
• Format masks
• Hardcoded strings
• Multiple character sets
18-8 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
18-14
Building Reports to Run in Different Languages
......................................................................................................................................................

Translating a Developer/2000 Application


Translation Builder is a component of Developer/2000 that supports and manages
translations of text extracted from both Oracle resource files, such as
Developer/2000 applications, and non-Oracle resource files such as Microsoft
Windows (.rc) and HTML files.
You can translate a report from any language to any other language. Once a
translation is complete, you can use that translation as a base for further translations.
Translations are portable across multiple platforms.

Steps to Translate a Resource


1 Use the Project Navigator to extract translatable strings from Oracle or
non-Oracle resources and import them into the translation repository.
2 Add a translation by indicating the language.
3 Execute the translation using the Translation editor.
4 Preview the translation by performing appearance checking and tuning to
preserve an acceptable look and feel.
5 Extract the translated strings and merge them back into the original resource.

Considerations When Designing Multilingual Applications


• Format masks: Ensure you provide extra space for translation of date and
numeric format masks.
• Text strings: Avoid hardcoding a string containing language-specific words such
as a month name.
• Character sets: If using an application that will run with multiple character sets,
determine the one that is most frequently used, and generate the application files
with the relevant NLS language settings.

......................................................................................................................................................
18-15
Lesson 18: Building Reports for Different Environments
......................................................................................................................................................

Summary

• GUIs:
– Colors, uifont.ali
• Character mode:
– Templates, report properties, MODE
parameter
• Languages:
– NLS, Unicode, Translation Builder

18-9 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
18-16
Summary
......................................................................................................................................................

Summary
• Building reports to run on different GUIs
- If reports must run on different GUIs, remember to use common features,
such as the common color names.
- Use uifont.ali to map different fonts if necessary.
• Building character mode reports
- Use the character template.
- Copy the template and rename it to create several templates with different
settings, such as page sizes.
- The MODE parameter enables you to switch from bitmap to character mode.
• Building reports to run in different languages
- Developer/2000 provides National Language Support.
- Developer/2000 provides Unicode support to handle multiple character sets
in one application.
- Translation Builder supports and manages translations of extracted text
strings.

......................................................................................................................................................
18-17
Lesson 18: Building Reports for Different Environments
......................................................................................................................................................

......................................................................................................................................................
18-18
A
................................

Solutions
Appendix A: Solutions
......................................................................................................................................................

Practice Session Overview: Lesson 1


Introduction
This practice familiarizes you with Developer/2000 by asking you a number
of questions that you answer by navigating through the interface and by
investigating Help Topics.
After each question, space is provided for you to write the answer. Or, if you
prefer, use a separate Sheet of paper.
Depending on the size of your group, the instructor might ask you to answer
some of the questions and share your answers with the rest of the class.
Depending on the environment you are using in this course, the instructor
might ask you to compile some reports from the Project Builder.

Instructor Note
This practice is intended to serve the following purposes:
• Make students familiar and at-ease with the interface and Help system
• Show them the level and extent of information that is available
• Encourage them to seek help in the product and not expect every small detail to
be taught in the next four days
Suggestion: To make this exercise more entertaining and enjoyable, as well as
encourage interaction among the class, use this exercise as a class fact-finding
mission.
Divide students into groups and ask each group to concentrate on one group of
questions, for question numbers 8 to 11. Encourage them to work together. Then
allow time for each group to present the answers to the rest of the class.
You need a Web browser to use the manuals and the Quick Tour. Advise students
which browser to use, when they initialize the Web browser in Question 10.
To ensure the reports used in the next section are compiled for your
environment there is an optional practice at the end to compile all necessary
reports from the Project Builder. Give students the project directory name
(one level above the \Demo directory) and the connect string. They must
enter these properties for the project, Dev/2000: Build Reports course,
before they compile the files. We recommend you do this question first, if
you want to, so that you can step the students through it.

......................................................................................................................................................
A-2 Developer/2000: Build Reports
Practice Session Solutions: Lesson 1
......................................................................................................................................................

Practice Session Solutions: Lesson 1


1 Invoke Project Builder, and open a project reports.upd.
Choose Open an existing Project, then OK.
Select the file named reports.upd.
2 Launch Report Builder, and choose Cancel in the wizard.
Choose Report Builder in the launcher.
When Report Builder is up, choose Cancel in the wizard.
3 Change your preferences so that a newly opened report is not
immediately executed. To do this you must suppress the Report editor on
Open.
Select Tools—>Preferences from the menu. On the General tab,
select the option Suppress Report Editor on Open, then choose OK.
4 Open the report named p2q2.rdf.
Choose Open from the toolbar or File—>Open from the menu, and
select the file named p2q2.rdf.
5 Change your preferences so that you can work with a report definition
either in a file or the database. Ensure that the default list shows only
reports.
Select Tools—>Preferences from the menu. On the Objects tab
select the option File/Database and check Reports. Notice that the
select in All is cleared. Choose OK to accept your preferences.
6 Open another report: p2q3.rdf. Notice the additional dialog box.
Choose Open from the toolbar or File—>Open from the menu.
Accept the dialog box. In the File Browse dialog, select the file
named p2q3.rdf, and choose OK.
7 Reset your preferences to work with files only. Enable a report to be run
automatically on open.
Select Tools—>Preferences from the menu. On the General tab clear
the option Suppress Report Editor on Open. On the Objects tab select
the option File. Choose OK to accept your preferences.

......................................................................................................................................................
Developer/2000: Build Reports A-3
Appendix A: Solutions
......................................................................................................................................................

8 Use the context-sensitive Help to discover more about preferences.


Select Tools—>Preferences from the menu. Choose Help or press the
Help key (F1 on Windows systems).
General:
a What setting must you choose for color mode if you want to alter the
color palette for a specific report?
Choose the General tab in the Help system. In the upcoming
dialog, select Color Mode and choose Display.
You must set the color mode to Editable.
b What menu option do you use to alter the color palette?
Format—>Layout Options—>Color Palette.
Close the Help system.
Runtime Values:
Go back into the Tools—>Preferences Help system.
c What is the purpose of the Runtime Values?
Choose the Runtime Values tab in the Help system.
Runtime values are values used if you run your report in the
current session.
d When do they take effect?
Immediately
e What must you do to change the default setting in your report?
You must update the Initial Value of the appropriate parameter
in the report definition.
f What are the names of the three runtime values that affect the report
destination, and what are the three related report parameters?
Destination Format DESFORMAT
Destination Name DESNAME
Destination Type DESTYPE

Close the Help system and leave the Preferences dialog.

......................................................................................................................................................
A-4 Developer/2000: Build Reports
Practice Session Solutions: Lesson 1
......................................................................................................................................................

9 Use Help Topics to discover more about the functionality of Developer/


2000 Report Builder:
Choose Help—>Report Builder Help Topics from the menu.
a What is MAPI?
Use the index to look for MAPI. Choose MAPI, about.
MAPI is the Microsoft Messaging Application Program
Interface used to send reports to an e-mail system.
b What are the prerequisites for sending a report as an e-mail
attachment?
You must have an appropriate MAPI mail client.
c The report is sent as what type of attachment format?
Bitmapped reports are sent as PostScript files, character mode
reports as ASCII text.
d What are the three steps to install Developer/2000 demonstrations?
Use the index to look for Demos, Installing.
The three steps are:
Install the demo database objects.
Install Report Builder Demo fonts.
Install Java classes for the Java Reports demo.
10 Use Help on Manuals to answer the following questions in the Oracle
Information Navigator:
Note: In the Information Navigator, choose Tools—>Preferences to
initialize your Web browser. Your instructor will tell you which browser
to use.
Choose Help—>Manuals from the menu.
a What are the three top-level folder names for the online manuals?
Developer/2000: Guidelines for Building Applications
Developer/2000: Getting Started
Developer/2000 Reports Server, Web Cartridge, and Web CGI

......................................................................................................................................................
Developer/2000: Build Reports A-5
Appendix A: Solutions
......................................................................................................................................................

b In the Getting Started Manual, what are the five topics included in
Administrative Procedures?
Expand the node Developer/2000: Getting Started in the Oracle
Information Navigator.
Choose Developer/2000 -- Index
Go to Administrative Procedures
The five topics are:
Building Developer/2000 Database Tables
Using the Database Tables
Granting and Revoking User Access
Deleting the Developer/2000 Database Tables
Upgrading the Developer/2000 Database Tables
c In Designing Portable Applications, what is the purpose of section
5.3?
Expand the node Developer/2000: Guidelines for Building
Applications in the Oracle Information Navigator.
Choose Designing Portable Applications.
Section 5.3 discusses developing a report for maximum
portability.
d Name the three language environment variables available when
developing multilingual applications.
Choose Developer/2000 Index in the Oracle Information
Navigator.
Go to multilingual applications in the index.
The three environment variables are:
DEVELOPER_NLS_LANG
NLS_LANG
USER_NLS_LANG

......................................................................................................................................................
A-6 Developer/2000: Build Reports
Practice Session Solutions: Lesson 1
......................................................................................................................................................

11 Use Quick Tour to find out how to prepare a report for the World Wide
Web.
Choose Help—>Quick Tour from the menu.
In the Web browser, choose Report Builder, then choose Preparing a
Report for the World Wide Web.
a What changes do you have to make to your report to deploy it on the
Web?
Page 2 of 9: You can prepare an existing report for the World
Wide Web without making any changes to the report.
b What output formats can you choose from?
Page 4 of 9: You can choose from HTML or PDF output formats.
c What is the Web wizard?
Page 5 of 9: For reports that run infrequently, you can use the
Web wizard each time you run your report to post the updated
output on the Web.
d How can you dynamically deploy a report on The Web?
Page 5 of 9: For reports that run frequently, you should
implement dynamic Web reporting using the Reports Server and
the Reports Web Cartridge or Web CGI.

Optional Practice
12 Your instructor may ask you to do the following practice to prepare some
reports for the next practice session.
a In Project Builder, select the project “Developer/2000: Build Reports
course”. In the menu, choose Tools—>Property Palette, or use the
right mouse button.
b Under the General Information node, enter the Project directory
name that the instructor gives you.
c Under the Connection node, enter the username, password, and
database string that the instructor gives you.
d In the Object Navigator, select the node “Reports to be compiled”. It
is a subproject of the Reports course project that you opened.
e Choose Project—>Compile Selection from the menu. This creates
the runtime files that you need for the next practice session.

......................................................................................................................................................
Developer/2000: Build Reports A-7
Appendix A: Solutions
......................................................................................................................................................

Practice Session Overview: Lesson 2


This practice session contains:
• Invoking the Reports Runtime executable from the Program Manager
• Executing a number of different reports. For each report, answer some questions

Introduction
Before you learn to develop reports in the Builder, you should investigate the
runtime executable that you use constantly in the production environment and for
testing your reports prior to production.
This practice session consists of a combination of practical and paper based
questions.

......................................................................................................................................................
A-8 Developer/2000: Build Reports
Practice Session Solutions: Lesson 2
......................................................................................................................................................

Practice Session Solutions: Lesson 2


1 Invoke the Reports Runtime executable.
Choose Reports Runtime from the Developer/2000 menu.
This may differ according to the classroom setup.
2 Run the report called p2q2.rep.
From the menu choose File—>Run. The File Browse window
displays. Select p2q2.rep and choose Open.
a Examine the report in the Previewer window. Using the styles
discussed in this lesson as a reference, what style of report is it?
Tabular report
b How many groups of data are there in this report?
One group of data, each row being displayed once within the
group
c In the Previewer window use the scrollbars to move up and down the
report to see all of the data.
Use the scrollbar on the right hand side of the Previewer to scroll
up and down the report data.
d Close the previewer window. You are now back in the Runtime
window.
In the Previewer choose Close Previewer.
3 From the Runtime window, run report p2q3.rep.
From the menu choose File—>Run.The file Browse window
displays. Select p2q3.rep and choose Open.
a In the Previewer window, move to the next page. Notice this report
has a header page with text. Notice that the Previewer also has many
more buttons highlighted. This is because there are more available
actions, such as Next Page, Previous Page, Last Page, First Page.
Choose Next Page to navigate from one page to another.
b What style of report is this?
Tabular report

......................................................................................................................................................
Developer/2000: Build Reports A-9
Appendix A: Solutions
......................................................................................................................................................

In the Previewer window, experiment with the horizontal and vertical


c
split screen features.
To split the Previewer horizontally: choose the small gray area at
the top of the right hand scroll bar. Keep 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. Release 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: choose the small gray area at
the left of the horizontal scroll bar at the bottom of the window.
Keep 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. Release 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. You are now back in the Runtime
window.
In the Previewer choose Close Previewer.
4 From the Runtime window, run report p2q4.rep.
From the menu choose File—>Run. The file Browse window
displays. Select p2q4.rep and choose Open.
a The first thing you will notice is the size of the Previewer window.
The reason it is so small is that the page size specification is inherited
by the Previewer screen.
The page size always determines the Previewer window size.
b What style of report is this?
It is a Master/Detail report.
c How many groups of data are in this report?
There are two groups of data.
d How many pages are there in this report?
There are three pages. Choose Last Page to navigate to the last
page.
e Close the Previewer window. You are now back in the Runtime
window.
In the Previewer choose Close Previewer.

......................................................................................................................................................
A-10 Developer/2000: Build Reports
Practice Session Solutions: Lesson 2
......................................................................................................................................................

5 From the Runtime window, run report p2q5.rep


From the menu choose File—>Run.The file Browse window
displays. Select p2q5.rep and choose Open.
a What style of report is this?
It is a Matrix report.
b How many groups of data are in this report?
There are four groups of data:
Year
Department
Job Title
Salary
There is an additional, invisible “cross product” group around
Year, Department, and Job; this special group defines the matrix
structure and is explained in the lesson on matrix reports.
c Close the Previewer window. You are now back in the Runtime
window.
In the Previewer choose Close Previewer.
6 From the Runtime window, run report p2q6.rep.
From the menu choose File—>Run. The file Browse window
displays. Select p2q6.rep and choose Open.
a Notice the Parameter Form. Choose the Destination Type: “Screen”.
Select Screen from the list of values.
b In the Parameter Form you are requested to input a customer ID. The
report will display order information based on your input.
c Specify a valid customer ID and run the report. Valid values include:
201, 210 or 213; choose one of these. Having entered a valid number
choose Run Report.
Click into the Customer Id field, and enter one of the suggested
numbers. Choose Run Report.
d What do you think would be a better method of providing valid
values to a user?
It would be more user-friendly to display a list of values for the
Customer IDs; maybe even make the list more meaningful by
adding the customer names. This can be built into the report. In
later lessons you will see how this can be implemented.

......................................................................................................................................................
Developer/2000: Build Reports A-11
Appendix A: Solutions
......................................................................................................................................................

e Close the Previewer window. You are now back in the Runtime
window.
In the Previewer choose Close Previewer.
f Run the report again, this time do not specify a customer ID.
From the menu choose File—>Run. The File Browse window
displays. Select p2q6.rep and choose Open, then immediately
Run Report without entering a value for customer ID.
i What is the result?
The result is that the report does run; however it does not display any
data. There are no NULL customer IDs.
ii In a production situation, what should happen in this instance?
The user should be prevented from entering a NULL value or a blank.
In later lessons you will see how this can be implemented.
g Close the Previewer window. You are now back in the Runtime
window.
In the Previewer choose Close Previewer.
h Run the report again, this time enter Customer Id 999.
From the menu choose File—>Run. The File Browse window
displays. Select p2q6.rep and choose Open. Enter the customer
ID 999, and choose Run Report.
i What is the result?
The result is that the report does run; however it does not display any
data. There is no customer ID 999.
ii In a production situation, what should happen in this instance?
The user should be prevented from entering an invalid value. In later
lessons you will see how this can be implemented.
i Close the Previewer window. You are now back in the Runtime
window
In the Previewer choose Close Previewer.

......................................................................................................................................................
A-12 Developer/2000: Build Reports
Practice Session Solutions: Lesson 2
......................................................................................................................................................

7 From the Runtime window, run report p2q7.rep.


From the menu choose File—>Run.The file Browse window
displays. Select p2q7.rep and choose Open.
a In the Parameter Form notice the list of values for the Customer
information. The report will display order information based on your
input.
b Select a valid customer name and run the report. In the Previewer
choose Print
Select Screen from the list of values for destination type.
Select a customer name from the list of values for customer.
In the Previewer choose Print.
What is the result?
You get a warning that there may be a truncation of data,
because the destination type was not Preview.
You see the Print Job Box specific to your operating system.
c Do not print the report.
d Close the Previewer window. You are now back in the Runtime
window.
In the Previewer choose Close Previewer.
e Run the report again, this time choose Preview as destination type.
From the menu choose File—>Run. The File Browse window
displays. Select p2q7.rep and choose Open.
f In the Previewer, choose Print. What is the result?
Select Screen from the list of values for destination type.
You see the Print Job Box specific to your operating system.
g Do not print the report.
Choose Cancel.
h Close the Previewer window. You are now back in the Runtime
window.
In the Previewer choose Close Previewer.

......................................................................................................................................................
Developer/2000: Build Reports A-13
Appendix A: Solutions
......................................................................................................................................................

8 From the Runtime window, run report p2q8.rep.


From the menu choose File—>Run. The File Browse window
displays. Select p2q8.rep and choose Open.
a What do you notice that is different about this report?
A button is displayed to the right of the customer information.
b Choose Details. Another report is called to display information about
the orders the customer has placed with the company. This is called a
Drill-Down report.
c Close the Orders report Previewer window, and then close the
Customer report Previewer window. You are now back in the
Runtime window.
In the Orders report Previewer choose Close Previewer.
In the Customer report Previewer choose Close Previewer.
d Exit Reports Runtime.
From the menu choose File—>Exit.

......................................................................................................................................................
A-14 Developer/2000: Build Reports
Practice Session Overview: Lesson 3
......................................................................................................................................................

Practice Session Overview: Lesson 3


This practice session contains:
• Invoking Report Builder
• Opening an existing report
• Switching views in the Report editor
• Accessing the Help System

Introduction
The questions in the practice session provide an introduction to the Report 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.

......................................................................................................................................................
Developer/2000: Build Reports A-15
Appendix A: Solutions
......................................................................................................................................................

Practice Session Solutions: Lesson 3


1 If you closed Project Builder in Practice 1, invoke Project Builder, and
then invoke Report Builder from the Project Builder Launcher toolbar. If
it is still open, go to Report Builder.
If you need to reopen Report Builder, choose Project Builder from
the Developer/2000 menu. Do not open an existing project. Choose
Cancel.
In the Launcher choose Report Builder.
2 Open an existing report: p3q2.rdf.
In the welcome dialog of Report Builder select the Open an existing
report option and choose OK.
Open p3q2.rdf from the file system and run the report.
If prompted, connect to the database using the login information
your instructor gives to you.
When the parameter form comes up, choose Run Report, accepting
all the defaults.
3 In the Report editor, switch to the Data Model view.
In the Object Navigator, select Q_1.
Hint: Use the Find field at the top of the Object Navigator.
Notice the object that is selected in the Data Model view.
While the Report editor window is active, choose View—>Data
Model from the menu.
Activate the Object Navigator Window.
Click in the Find: field and enter Q_. Immediately the navigator will
expand the appropriate node and highlight the first object that
meets the entered value.
In the Data Model editor the query object Q_1 is selected.

......................................................................................................................................................
A-16 Developer/2000: Build Reports
Practice Session Solutions: Lesson 3
......................................................................................................................................................

4 In the Report editor, switch to the Layout Model.


In the Object Navigator, select F_ID.
Hint: Use the Find field at the top of the Object Navigator.
Notice the object that is selected in the Layout Model view.
Fully expand the Layout Model node, and select R_G_ORD_ID.
Notice the object that is selected in the Layout Model view.
While the Report editor window is active, choose View—>Layout
Model from the menu.
Activate the Object Navigator window.
Click in the Find: field and enter F_. Immediately the navigator will
expand the appropriate node and highlight the first object that
meets the entered value.
In the Layout Model editor the field F_ID is selected.
Activate the Object Navigator window. Select the Layout Model
node and choose Expand All in the toolbar or choose
Navigator—>Layout Model editor. Expand All from the menu.
Select R_G_ORD_ID.
In the Layout Model editor the repeating frame R_G_ORD_ID is
selected.
5 In the Report editor, switch to the Parameter Form view.
In the Object Navigator, expand the Parameter Form node. Select
PF_DESTYPE. Notice the object that is selected in the Parameter Form.
Use the Find field at the top of the Object Navigator to select
P_CUSTID. Is any object selected in the Parameter Form? What is the
reason?
While the Report editor window is active, choose View—>
Parameter Form from the menu.
In the Object Navigator select the Parameter Form node and choose
Expand All in the toolbar or choose Navigator—>Expand All from
the menu. Select PF_DESTYPE.
In the Parameter Form editor the object PF_DESTYPE is selected.
Activate the Object Navigator window.
Click in the Find: field and enter P_. Immediately the navigator will
expand the appropriate node and highlight P_CUSTID.
In the Parameter Form editor the object PF_DESTYPE is not
selected, because P_CUSTID is a parameter and not a parameter
field. Parameters are part of the Data Model, not the Parameter
Form.

......................................................................................................................................................
Developer/2000: Build Reports A-17
Appendix A: Solutions
......................................................................................................................................................

6 Use Help Topics to answer the following questions:


From the menu, choose Help—>Report Builder Help Topics. In the
Index tab, enter executables in the selection field; select invoking
from the index entry list below and choose Display. Choose Related
Topics.
a What is R30MTS?
Choose R30MTS from the dialog box.
b What is R30CLI?
Close the Help on R30MTS and choose Related Topics.
Choose R30CLI from the dialog box.
c Close the Help system.

......................................................................................................................................................
A-18 Developer/2000: Build Reports
Practice Session Overview: Lesson 4
......................................................................................................................................................

Practice Session Overview: Lesson 4


IThis practice session contains:
• Creating and saving a Tabular report
• Modifying the report, to create and save a Group Above break report
• Creating and saving a Form Letter
• Creating and saving a Matrix report
• Creating and saving a Matrix with Group report

Introduction
The questions in the practice session are intended to ensure that you have a good
understanding of how to create various styles of report using the Report wizard.
Note: When you are completing the practice sessions, please keep to file naming
conventions that the questions specify. You might need these files in later practices.
In addition, please 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, please ensure you
use Save As, not Save, so that you do not overwrite the existing file name.

......................................................................................................................................................
Developer/2000: Build Reports A-19
Appendix A: Solutions
......................................................................................................................................................

Practice Session Solutions: Lesson 4


Invoking Report Builder and the Wizard
If Report Builder is not open, launch it from Project Builder and create a
new report using the Report wizard.
Select Project Builder from the Developer/2000 menu. Do not open an
existing project. Choose Cancel.
In the Launcher, choose Report Builder.
In the welcome dialog of Report Builder, select the Use the Report Wizard
option and choose OK.
If Report Builder is open after the previous practice session:
• Close any reports currently in the Object Navigator.
• Create a new report by selecting the Report node and choosing Create
Object.
Note: there is an alternative method, if no reports are open in the Object
Navigator, you can double-click the Report node.
1 Create a tabular report containing the following data. Use Query Builder
to build the query.
S_DEPT: NAME
S_EMP: FIRST_NAME, LAST_NAME, TITLE, SALARY, COMMISSION_PCT
Display all fields. Do not make any changes to the other wizard pages.
In the Select Data Tables dialog, choose the S_DEPT and S_EMP
tables and close the dialog.
In the Query Builder window, select the columns from the tables and
choose OK.
Choose next.
Copy all fields from the Available Fields to the Displayed Fields area.
Choose Next on all other wizard pages and Finish at the last page.

......................................................................................................................................................
A-20 Developer/2000: 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 choose Report
Wizard from the horizontal toolbar.
Modify the query to sort the data in descending order of salary.
On the Data tab choose Query Builder.
In the Query Builder window choose Sort. Copy the SALARY
column to the Sorted Columns, select it and choose Sorting Order
Descending. Close the Sort dialog and the Query Builder.
Choose Finish to test your report.
Add a summary to show the total salary value.
Reenter the Report wizard by choosing Report Wizard from the
toolbar.
On the Totals tab select SALARY and choose Sum.
Reduce the width of SALARY and TOTAL to 6.
Change the COMMISSION_PCT label to Comm and reduce the width
to 4.
Make the necessary changes on the Labels tab and choose Finish to
test your report.
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.
Choose report style Group Above.
Choose the report style on the Style Tab.
Group the report by the department name.
On the Groups tab copy NAME to the Group Fields area.
Do not forget to copy all fields to Displayed Fields on the Fields tab.
Choose the template called Bright 1.
Choose the template on the Template tab.
Save the report as p4q3.rdf.
Select File—>Save As from the menu and save the file to disk.

......................................................................................................................................................
Developer/2000: Build Reports A-21
Appendix A: Solutions
......................................................................................................................................................

4 Create a new report containing the following data.


Choose Mailing Labels style.
Use Query Builder to build the query.
Create a new report by selecting the Report node in the Object
Navigator and choosing Create Object.
As an alternative you can also select File—>New—>Report from the
menu.
Choose Mailing Label style and go to the next tab.
Choose Query Builder.
In the Select Data Tables dialog choose the S_CUSTOMER and
S_ORD tables and close the dialog.
In the Query Builder window select the necessary columns from the
tables and choose OK.
S_CUSTOMER: NAME, CITY, ADDRESS, STATE
S_ORD: ID, DATE_SHIPPED, TOTAL
Copy all fields from the Available Fields to the Displayed Fields area
and go to the next page.
In the text area, include all four customer fields, each field on a new line.
Copy NAME, CITY, ADDRESS, and STATE to the Mailing Label
Text area. To enter the line feeds you can either use the button or
simply press the return key.
Select the template Draft.
Select the template on the next page.
Save the report to a file named p4q4.rdf.
Select File—>Save As from the menu, and save the file to disk.

......................................................................................................................................................
A-22 Developer/2000: Build Reports
Practice Session Solutions: Lesson 4
......................................................................................................................................................

5 Using the reentrant wizard, modify the report to create a Form Letter
style.
Reenter the Report wizard by choosing Report Wizard from the
toolbar or selecting Tools—>Report Wizard from the menu.
On the Style tab choose Form Letter.
In the text area, enter some free-flowing text for each order. For example:
Order No. &<ID> was shipped to &<NAME> in &<CITY> on
&<DATE_SHIPPED>.
The order has a total value of &<TOTAL> dollars.
Copy the fields that you want to use to the Form Letter Text area,
and enter your free-flowing text.
Save the report as p4q5.rdf.
Select File—>Save As from the menu and save the file to disk.
6 Create a new report.Use Query Builder to build the query.
Create a new report by selecting the Report node in the Object
Navigator and choosing Create Object.
As an alternative you can also select File—>New—>Report from the
menu.
Choose the matrix report style.
On the first page choose Matrix.
For the query, import the contents of p4q6.sql.
Choose Import SQL Query and select p4q6.sql from the import
dialog.
Display customer names down the left side of the page.
Copy NAME to the Matrix Row Fields area.
Display product numbers across the top of the page.
Copy PRODUCT_ID to the Matrix Column Fields area.
Display the total value in the cells.
Choose Sum to copy the sum of TOTAL_VALUE to the Matrix Cell
Fields area.
Create a summary to give the total of the sum(salary) values.
Select Sum(TOTAL_VALUE) and choose Sum.

......................................................................................................................................................
Developer/2000: Build Reports A-23
Appendix A: Solutions
......................................................................................................................................................

Reduce the widths of PRODUCT_ID and all four summaries to 5.


Change the PRODUCT_ID label to Product.
Make the necessary changes in the Labels and Width fields.
Choose a template that gives Landscape output.
Select one of the Landscape templates, and choose Finish to run
your report.
Save the report to a file named p4q6.rdf.
Select File—>Save As from the menu, and save the file to disk.

If You Have Time


7 Modify the matrix report, to create a Matrix with Group.
Reenter the Report wizard by choosing Report Wizard from the
toolbar or selecting Tools—>Report Wizard from the menu.
On the Style tab choose Matrix with Group.
Choose Month as the group and check that all totals have a width of 5.
Go to the Group tab and copy MONTH to the Matrix Group Fields
area.
Check on the Labels tab that all fields with a label Total: have a
width of 5.
Save the report as p4q7.rdf.
Select File—>Save As from the menu, and save the file to disk.
Note: The query for the matrix reports above has been restricted to display
only products beginning with “4”, so that you can see and understand the
complete matrix more easily.

......................................................................................................................................................
A-24 Developer/2000: Build Reports
Practice Session Overview: Lesson 5
......................................................................................................................................................

Practice Session Overview: Lesson 5


This practice session contains:
• Modifying reports by applying changes in the Live Previewer

Introduction
In this practice session you will reuse some of the reports that you created in the last
session.

......................................................................................................................................................
Developer/2000: Build Reports A-25
Appendix A: Solutions
......................................................................................................................................................

Practice Session Solutions: Lesson 5


1 Open report p4q2.rdf. Make the following changes in the Live
Previewer:
To open the file select File—>Open from the menu or choose Open
on the toolbar.
If the report was saved with the Previewer open, it will open and run
the report automatically. If the report was saved with another editor
window open, it will open that window. Run the report by selecting it
in the Object Navigator and then selecting Program—> Run Report
from the menu or choosing Run in the toolbar.
a Make the columns SALARY and COMM right justified. Do not
forget to justify the column header accordingly.
Select the columns SALARY and COMM and their labels. Then
choose End Justify from the style bar or select Format—>
Justify—>End from the menu.
b Add commas and a currency symbol to SALARY. Add two decimal
places.
While the column is selected choose Commas from the style bar.
This will add the group separators. Then choose Add decimal
place from the style bar to add one decimal place. Repeat the
action for the second decimal place. You can also select the
commas and decimal places options from the Format menu.
c Add one decimal place and a percent sign to COMM.
While the column is selected choose Percent and then Add
decimal place from the style bar. You can also select the percent
and decimal places options from the Format menu.
d Edit the heading of the COMM field. Change the text to Comm Pct.
Select the label of the COMM field, then click on it again to get
into change mode. Enter your text, then click outside the label to
make your changes permanent.

......................................................................................................................................................
A-26 Developer/2000: Build Reports
Practice Session Solutions: Lesson 5
......................................................................................................................................................

eMake the Total at the end of the report right justified, add commas,
currency symbol and two decimal places as in the column SALARY.
Select the column, then choose End Justify from the style bar or
select Format—>Justify—>End 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.
f Change the label of the total to bold font.
Select the label, then choose Bold from the style bar or use
Format—>Font in the menu.
g Make whatever other changes you like.
No formal solution
h Save the report to a file named p5q1.rdf and close it.
2 Open report p4q3.rdf. Make the following changes in the Live
Previewer:
To open the file select File—>Open from the menu or choose Open
on the toolbar.
If the report was saved with the Previewer open, it will open and run
the report automatically. If the report was saved with another editor
window open, it will open that window. Run the report by selecting it
in the Object Navigator and then selecting Program—> Run Report
from the menu or choosing Run in the toolbar.
a Remove the border around the total for each department.
Select the column, and choose Line Color from the vertical
toolbar. Choose No Line to remove the line color.
b Add commas and two decimal places to the SALARY field and the
total and make them right justified.
Select the column, then choose End Justify from the style bar or
select Format—>Justify—>End 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.

......................................................................................................................................................
Developer/2000: Build Reports A-27
Appendix A: Solutions
......................................................................................................................................................

cMake 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 End Justify from the style bar or
select Format—>Justify—>End 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 heading to grey.
Select a label, and choose Select Parent Frame from the style bar.
Choose 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.
3 Open report p5q3_a.rdf. Make the following changes in the Live
Previewer:
To open the file select File—>Open from the menu or choose Open
on the toolbar.
If the report was saved with the Previewer open, it will open and run
the report automatically. If the report was saved with another editor
window open, it will open that window. Run the report by selecting it
in the Object Navigator and then selecting Program—> Run Report
from the menu or choosing Run in 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.
Choose Insert Date and Time on the top toolbar or 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.

......................................................................................................................................................
A-28 Developer/2000: Build Reports
Practice Session Solutions: Lesson 5
......................................................................................................................................................

4 Open report p4q6.rdf. Make the following changes in the Live


Previewer:
To open the file select File—>Open from the menu or choose Open
on the toolbar.
If the report was saved with the Previewer open, it will open and run
the report automatically. If the report was saved with another editor
window open, it will open that window. Run the report by selecting it
in the Object Navigator and then selecting Program—> Run Report
from the menu or choosing Run in the toolbar.
a Right justify the Product ID field.
Select the Product ID field, then choose End Justify from the style
bar or choose Format—>Justify—>End from the menu.
b Remove the border around the cell values and the parent frame.
Select the column, hold down the shift key, and choose Select
Parent Frame from the style bar, and choose Line Color from the
vertical toolbar. Choose No Line to remove the line color.
c Add commas and two decimal places to the cells and summaries and
make them right justified.
Select the columns, and choose End Justify 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.
d Add a gray line color to the parent frames of NAME and PRODUCT
ID.
Select the column NAME, and choose Select Parent Frame from
the style bar. Choose Line Color from the vertical toolbar.
Repeat the above for the column PRODUCT.
e Save the report to a file named p5q4.rdf and close it.

If You Have Time


5 Open the file p4q7.rdf and make any changes you wish to the report.
No formal solution

......................................................................................................................................................
Developer/2000: Build Reports A-29
Appendix A: Solutions
......................................................................................................................................................

Practice Session Overview: Lesson 6


This practice session contains:
• Customizing an existing template
• Applying the modified template to an existing report

Introduction
In this practice session, you open an existing template, which is one of the standard
templates shipped with the Developer/2000 Release 2 installation.
You modify objects in the margin and body regions 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 a predefined
templates. You can suggest they 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>\REPORTS30\ADMIN\TEMPLATE directory.

......................................................................................................................................................
A-30 Developer/2000: Build Reports
Practice Session Solutions: Lesson 6
......................................................................................................................................................

Practice Session Solutions: Lesson 6


1 Customize an existing template, adding a company logo and report title
to the report margin, and modify the report body.
a Open corp1.tdf. This file should exist in your home directory; it is a
copy of the Corporate 1 predefined template.
Select the Templates node in the Object Navigator.
Choose Open and select the file named corp1.tdf.
b Display the margin region. (This usually appears by default when
you open a template.)
c Delete the Oracle buildings logo. Import summitlo.tif and place in
the top left corner of the margin; this file should exist in your home
directory.
Select the Oracle buildings logo and press the Delete key.
Choose File—>Import—>Image from the menu.
From the File Browse window choose the file name summitlo.tif.
Resize it to fit into the margin region.
d Modify the report title line: change 21st Century Products to Summit
Report.
Choose the Text tool from the vertical toolbar.
Select the text 21st Century Products and change it to Summit
Report.
e Display the body region to view the changes you make in this
practice.
Choose Body from the toolbar in the Template editor or select
View—>Layout Select—>Body View from the menu.
f Change the foreground color of the body to white. Make these
changes general, not specific to a particular layout.
In the Object Navigator expand the Body node, and the Default
Section node. Open the property palette for the Body of the
Default Section.
Under the heading Style, change the Foreground Color property
to White.
g Change the justification of number fields to Right. Do not forget to
change the justification of labels for number fields to Right.
Under the headings Label and Fields, change the Number
Justification to Right.

......................................................................................................................................................
Developer/2000: Build Reports A-31
Appendix A: Solutions
......................................................................................................................................................

Change the justification of number summary fields to Right.


h
Select Summaries in the Object Navigator.
In the property palette change the Number Justifications for
Fields to Right.
i Save the template as summit.tdf.
2 Apply the modified template to an existing report.
Hint: you must search for the template file, it does not appear in the list of
predefined templates.
Open p4q3.rdf.
a
b Apply summit.tdf to the report.
Invoke the Report wizard. On the Template tab select the option
Template file. Choose Browse to enter the name of the file in the
field below.
c The report shows some changes but not all. Which template changes
have been applied, and which have not?
Changes applied: Logo, report title, color of body region
Changes not applied: number justification
d To apply all changes to your report you will have to create the layout
again.From the menu choose Edit—>Select all to select all layout
objects. Now delete them. Invoke the Report wizard and reapply
your template.
e Save the report as p6q2.rdf.
3 Continue to modify the template and test it using a new report.
a Change the text color of the master group fields to red for the Group
Left style only.
Hint: In the Template editor, use the Report Style list to switch to a
Group Left style. This way you can select the correct group in the
Object Navigator. You may also want to use the Zoom Out tool, so
that you can see the entire template layout structure, and recognize
the difference between the master group fields and the detail group
fields.
In the Object Navigator expand the Override node, then the
Group Left and the Section (Level1) nodes.
Bring up the property palette for the body.
Change the Text Color for Fields to “Red”.

......................................................................................................................................................
A-32 Developer/2000: Build Reports
Practice Session Solutions: Lesson 6
......................................................................................................................................................

b Save your template as summit2.tdf and close it.


c Create a new report, using the Report wizard.
Use the layout style Group Left.
Import the query p6q3.sql from your working directory.
Make NAME the group field.
Display all other columns.
Do not create summaries.
Change the width of SALARY to 6 and COMM to 4.
Apply the Template file summit2.tdf
No formal solution
d Save the report as p6q3.rdf and close it.

......................................................................................................................................................
Developer/2000: Build Reports A-33
Appendix A: Solutions
......................................................................................................................................................

Practice Session Overview: Lesson 7


This practice session contains:
• Using the Help system to find comprehensive information on storage types and
executables
• Converting the storage type of a report using the Convert utility
• Documenting a report using the Report on Reports utility
Since the Report Builder tables are optional in Developer/2000, your classroom
might not have the tables available for you to save your report. Therefore your
instructor will advise you whether to attempt this question

Instructor Note
In the production version of Developer/2000 Release 2.0 the executable is
R30CON(32.EXE), but in the Help system it is still called R30CONV. Just point this
out to students, if they have difficulty finding it in the Help system, since the
practice uses the correct name R30CON.
The if you have time question is optional, since some classes might not have the
database tables available.
The Report on Reports runtime parameter form cuts off the names of the
parameters.You should point out to students which is which.
The Destination ones are:
• Destination Type
• Destination Name
• Destination Format
Remember that these reports exist as .rdf files; therefore developers can modify
these in Report Builder if they want.

......................................................................................................................................................
A-34 Developer/2000: Build Reports
Practice Session Solutions: Lesson 7
......................................................................................................................................................

Practice Session Solutions: Lesson 7


1 Search in the Help system for information on the R30CONV executable.
From the menu choose Help—>Report Builder Help Topics. Enter
R30CON in the Find tab.
What is this executable used for?
R30CON enables you to convert one or more report definitions or
PL/SQL libraries from one storage format to another.
Can you compile more than one report with this utility?
Yes
What other tool could you use to compile several reports?
Hint: You may want to refer to Lesson 1.
Project Builder
When converting a report to a template, what is converted and what is
not?
Only objects in the header and trailer pages and in the margin area
are used in the template. Objects in the body are ignored.
2 Use the Convert utility in Report Builder to convert a report from .rdf to
.rep.
a Open p6q3.rdf, if not already open.
b Convert it to a .rep file.
Choose File—>Administration—>Convert from the menu.
Document Type: Report
Source Type: Report Binary File (RDF)
Source: Enter the file name including the path or choose Browse.
Destination Type: Report Binary Run-only File (REP)
You can leave Destination empty.
c What other methods could you use to compile a report?
File—>Administration—>Compile or Ctrl T
What is the difference?
The compile option from the menu compiles the presently
selected report, the convert utility enables you to choose which
report or reports to compile. It also enables you to convert to
other storage types.

......................................................................................................................................................
Developer/2000: Build Reports A-35
Appendix A: Solutions
......................................................................................................................................................

d Convert the same report to a .rex file.


Choose File—>Administration—>Convert from the menu.
Document Type: Report
Source Type: Report Binary File (RDF)
Source: Enter the file name including the path or choose Browse.
Destination Type: Report ASCII File (REX)
You can leave Destination empty.
e Open a system editor to look at the .rex file.
No formal solution

If You Have Time


3 If the database product tables are installed, document a report definition
that is saved in the database.
a Save report p6q3 to the database.
Either change your preferences to be able to save to the database
(Tools—>Preferences, Object tab)
or use the convert utility (File—>Administration—>Convert)
b Run the Report on Reports utility to produce documentation on the
report p6q3. Set the runtime parameters to output to a file in PDF
format.
Choose File—>Administration—>Report on Reports.
Select Report name P6Q3
Destination Type: File
Destination Name: p6q3.pdf
Destination Format: PDF
c Open the PDF file and scroll through the documentation.

......................................................................................................................................................
A-36 Developer/2000: Build Reports
Practice Session Overview: Lesson 8
......................................................................................................................................................

Practice Session Overview: Lesson 8


This practice session contains:
• Creating a second query in an existing report.
• Restricting records in a query.
• Restricting records with a packaged filter.
• Creating a data link.
• Creating a report containing a master group with two detail groups.
• Creating an external query file and referencing the file in a new report.

Introduction
In this practice session you include new data in a report by adding a query to
an existing single-query report created with the wizard. You also practice
linking data from different queries to alter the report structure. Using two
different techniques, you restrict the records in a report. If you have time,
you create a external query and link it to a report.

......................................................................................................................................................
Developer/2000: Build Reports A-37
Appendix A: Solutions
......................................................................................................................................................

Practice Session Solutions: Lesson 8


1 Open report p8q1_a.rdf that contains a single-query report showing
customer information.
d In the Data Model create a new query. Either use the Query Builder,
or import filename p8q1.sql.
QUERY: Q_ORD:

SELECT customer_id, id, date_shipped, total


FROM s_ord

eOpen the Report wizard and choose a Tabular layout.


f Copy group G_ORD to the Displayed Groups area.
g Copy all remaining fields to the Displayed Fields area.
h Choose Finish.
i Note how the data appears in the Live Previewer. The
Q_CUSTOMER data appears before the Q_ORD data. Remember
you can alter the order in which the data prints by modifying query
order in the Data Model. You may want to try that.
Note: If you do adjust the order of the queries, please put them back in
the original order, and save before the next question.
j Save the report as p8q1.rdf, do not close the report.
2 Modify the previous report to restrict the number of customer records
processed by the group.
a Place a filter on the G_CUSTOMER group, to display only the first
four customers. Run to test.
Select the group G_CUSTOMER in the Data Model and open
the property palette. Set the property Filter Type to First, and
enter the number of records.
b Save the report as p8q2.rdf and close it.
c Close the report, and any other you still have open in the Object
Navigator.

......................................................................................................................................................
A-38 Developer/2000: Build Reports
Practice Session Solutions: Lesson 8
......................................................................................................................................................

3 Open p8q1.rdf.
aIn the Data Model link the two queries together on the primary and
foreign keys.
Hint: To create the link, select the Link tool. Click and drag from the
primary key field in the Customer group to the foreign key field in
the Ord group.
b Redo the layout by opening the Report wizard. Choose Group Above
style. Do not display CUSTOMER_ID.
c Run to test.
d Save the report as p8q3.rdf.
4 Modify p8q3.rdf to show and restrict customers’ credit rating. You need
to modify the query properties.
a Include CREDIT_RATING in the query statement, though you need
not display it. Restrict the query statement to show those who have a
POOR credit rating.
In the Data Model select the query Q_1. Click the right mouse
button to open the SQL Query Statement or open it from the
property palette.
Either type WHERE S_CUSTOMER.CREDIT_RATING =
’POOR’ directly in the query statement area or use the Query
Builder to build the WHERE clause.
If you use the Query Builder, click in the blank condition field
Conditions panel to activate it. Then click the column
CREDIT_RATING in the S_CUSTOMER table. Type = ’POOR’
and press return.
b Run to test.
c Save the report as p8q4.rdf and close it.

......................................................................................................................................................
Developer/2000: Build Reports A-39
Appendix A: Solutions
......................................................................................................................................................

5 Create a new report that lists the sales representatives and the products
they have sold.
a Choose a Group Above report style.
b Import the query file p8q5_a.sql.
c Make NAME and ID the group fields. Ensure that these fields are in
one group, at Level 1, not two separate groups.
d Do not display ID but display all other fields in the order described in
the table below.
Hint: You can change the order of fields in the Report wizard on the
fields tab.
e Change the following field attributes:

Column Label Width


NAME Name 20
PRODUCT Product 10
PRODUCT_ID ID 4
QUANTITY Quantity 4
PROD_TOTAL Total 6

f Use the template file summit.tdf


g Run and test your report.
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
p8q5_b.sql. This query returns the customers and the total sales per
customer for each sales representative.
i Rename the group to G_CUSTOMER.
j Link the second query to the correct group.
Click and drag from ID in G_NAME to CUSTOMER_ID in
G_CUSTOMER.
k Use the Report wizard to display the new group. Do not display
SALES_REP_ID or ID.

......................................................................................................................................................
A-40 Developer/2000: Build Reports
Practice Session Solutions: Lesson 8
......................................................................................................................................................

l Change the following field attributes:

Column Label Width


CUSTOMER Customer 10
CUSTOMER_ID ID 4
CUST_TOTAL Total 6

m Run and test your report.


n Save the report as p8q5.rdf and close it.

If You Have Time


6 Create an External Query module that selects the following data:
Select the External SQL Queries in the Object Navigator, and
choose Create.

Columns Table
id, name s_dept
id, first_name||’ ’||last_name, title, salary s_emp
a Remember to include a join condition:
b Give the columns meaningful names.
Write the following query:

SELECT S_DEPT.ID DEPT_ID


, S_DEPT.NAME DEPARTMENT
, S_EMP.ID EMP_ID
, S_EMP.FIRST_NAME ||' '|| S_EMP.LAST_NAME EMPLOYEE
, S_EMP.TITLE
, S_EMP.SALARY
FROM S_DEPT, S_EMP
WHERE S_EMP.DEPT_ID=S_DEPT.ID

c Save the query as p8q5.sql and close the query window.

......................................................................................................................................................
Developer/2000: Build Reports A-41
Appendix A: Solutions
......................................................................................................................................................

7 Use the Report wizard to create a Group Left report using the external
query created in question 5.
a Department information should be in the master group.
b Look at the Data Model. Notice the break group exists.
c In the Data Model, move TITLE into a group at the top of the
hierarchy.
Hint: Move it into the department group first, then up into its own
new group.
Click and drag TITLE to the department group, then up again
to make a separate group. Rename the group G_TITLE.
Note: Since this is a single-query report, you can also make the group
change using the Report wizard, Group tab. However, you have learned
that you can combine many queries and groups in your own reports and
this simple exercise helps you to practice moving columns in the data
model.
d Open the Report wizard and choose Finish, to update the layout and
run the report.
e Run and test the report.
f Save the report as p8q7.rdf and close it.
Do you still have any objects open in the Object Navigator? If you do close them all.

......................................................................................................................................................
A-42 Developer/2000: Build Reports
Practice Session Overview: Lesson 9
......................................................................................................................................................

Practice Session Overview: Lesson 9


This practice session contains:
• Creating a new report with summaries
• Opening an existing report to add summary calculations to the columns
• Creating a report that displays the contents of a file in a column
• Creating a new report with ranking summary columns
(Use ORDER BY clause to create the ranking effect.)
• Opening an existing report to add placeholders for the highest and lowest
values in the report

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.

......................................................................................................................................................
Developer/2000: Build Reports A-43
Appendix A: Solutions
......................................................................................................................................................

Practice Session Solutions: Lesson 9


1 Create a new report using the Report wizard. Choose a Group Above
report style.
a Display the following data:

Table Column Definition Label Width


s_ord id Ord. No. 4
date_ordered Order Date 9
s_item item_id No. 2
product_id Product No. 5
price Price 4
quantity_shipped Quantity 4
line_total price*quantity_shipped Total 4

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.
Type the formula price*quantity_shipped 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 S_ITEM.
Choose Define Column.
Click inside the Defined Columns box.
Type Line_Total.
Click inside the Defined as box.
Type the expression price*quantity_shipped.
Choose OK.

......................................................................................................................................................
A-44 Developer/2000: Build Reports
Practice Session Solutions: Lesson 9
......................................................................................................................................................

c Create the following summaries. Can you use the Report wizard to
create the summaries?
As this is a single query report you can use the Report wizard.

Column Summary
line_total sum
line_total % Total

Use the summit.tdf template file from the file system.


d
In the template tab choose and apply the template. Finish and
run the report.
e In the Data Model, rename the groups to G_ORD for the break group
and G_ITEM for the detail group. Alter the position of columns in
the G_ORD group so that DATE_ORDERED is above ID, and
change the break order on DATE_ORDERED so that it is sorted in
descending order.
Open the property palettes for each group, and change the
names.
Click on DATE_ORDERED and drag it above ID; be careful not
to drag it outside the group.
Open the property palette for DATE_ORDERED, and change
the Break Order property to Descending.
f Run and test the report. (Do not reenter the wizard!)
g Save the report as p9q1.rdf and close it.
2 Open report p8q5.rdf.
a Add a summary to total PROD_TOTAL for each employee master.
Can you use the Report wizard?
As this is a multiquery report you have to create all summaries
manually unless you created them with the first query.
Select Summary Column in the vertical toolbar, and click inside
the group G_NAME. This will create a new summary.
Open the property palette for the new column, and name it
REP_TOTAL.
In the Summary section select the function Sum.
The Source is PROD_TOTAL.
Reset at G_NAME.

......................................................................................................................................................
Developer/2000: Build Reports A-45
Appendix A: Solutions
......................................................................................................................................................

Create columns to show the percentage of the total per sales


b
representative for PROD_TOTAL and CUST_TOTAL.
Select Summary Column in the vertical toolbar, and click inside
the group G_PRODUCT. This will create a new summary.
Open the property palette for the new column, and name it
PCT_PROD.
In the Summary section select the function % of Total
The Source is PROD_TOTAL.
Reset at G_PRODUCT.
Compute at G_NAME.
Select Summary Column in the vertical toolbar, and click inside
the group G_CUSTOMER. This will create a new summary.
Open the property palette for the new column, and name it
PCT_CUST.
In the Summary section select the function % of Total.
The Source is CUST_TOTAL.
Reset at G_CUSTOMER.
Compute at G_NAME.
c Make all the new summaries four characters wide.
d Run and test the report.
e Save the report as p9q2.rdf and close it.
3 Create a new report using the Report wizard.
a Choose a Tabular report style and display the following information:

Table Column Label


s_product id Id
name Name
short_desc Description
s_image filename picture

......................................................................................................................................................
A-46 Developer/2000: Build Reports
Practice Session Solutions: Lesson 9
......................................................................................................................................................

Restrict the query to return only products with id beginning with 10


b
or 30 as we do not have picture files for all products.
Type
WHERE S_PRODUCT.ID LIKE '10%'
OR S_PRODUCT.ID LIKE '30%'
into the query.
You can also use the Query Builder to create complex WHERE
clauses.
Click in the condition fields in the Conditions panel. Then select
the column ID from the S_PRODUCT table. This copies the
name of the column into the condition field.
Type LIKE '10%' into the condition field and press return.
Type S_PRODUCT.ID LIKE '30%' and press return.
You will see AND in the box to the left.
To put an OR between the two conditions select AND, then
choose Or on the toolbar.
c Run the report.
d In the Data Model change the properties for the column filename to
read from file, file format image.
e Use the Report wizard to redo the layout.
f In the Live Previewer resize the picture column to about 3x3 inches.
Hint: You need to enable Flex Mode. Use the last image on the page
to resize the picture column
g Save the report as p9q3.rdf and close it.
4 Open report p9q1.rdf to list the orders ranked by their total.
a In the Data Model add a new column s_ord.total to the query.
Hint: You will have to move the new column TOTAL to the G_ORD
group.
Any new column will be added in the lowest group. So you will
have to move it up to G_ORD.
b As you want to list the highest total first, set the break order for
TOTAL accordingly, and move the TOTAL column so that it is first
in the G_ORD group.
Set the Break Order for TOTAL to Descending. Click and drag
TOTAL to be the first column in the group G_ORD.

......................................................................................................................................................
Developer/2000: Build Reports A-47
Appendix A: Solutions
......................................................................................................................................................

c To display the ranking add another column called RANK in the


group G_ORD.
Create a summary column in the group G_ORD.
Name it Rank. Select the function Count.
The Source is ID.
Reset at Report.
d Use the Report wizard to display the rank, giving it a width of 2. You
need not display the total, because there is already a total on the
G_ITEM group.
e Run the report to test.
f Save the report as p9q4.rdf and close it

If You Have Time


5 Open report p9q1.rdf to display the highest and lowest orders at the end
of the report.
a In the Data Model add the columns necessary to list the maximum
order total and the corresponding ID as well as the minimum order
total and the corresponding ID.
Hint: You will need one formula column and some summaries and
placeholders.
You can import the code for the formula column from the file
p9q5.txt.
At report level create two summary columns:

Name Function Source Reset At


CS_Max Maximum SumLine_totalPerID Report
CS_Min Minimum SumLine_totalPerID Report

......................................................................................................................................................
A-48 Developer/2000: Build Reports
Practice Session Solutions: Lesson 9
......................................................................................................................................................

a (continued)
Also at report level create two placeholder columns. Name them
CP_Maxid and CP_Minid. This is where the IDs of the highest
and lowest orders will go.
Create a formula column in the upper group and name it
CF_GetIds.
Return number 1 (though it does not really matter what you
return if the formula column is a character type).
The PL/SQL Formula is the following:

function CF_GetIdsFormula return Number is


begin
if :SumLine_TotalPerId = :CS_Max then
:CP_Maxid := :ID;
end if;
if :SumLine_TotalPerId = :CS_Min then
:CP_Minid := :Id;
end if;
return (1);
end;

b Use the Report wizard to put the new columns into the layout.
Display the maximum order total, the maximum ID, the minimum
order total and the minimum ID.
Display columns CS_Max, CS_Min, CP_Maxid, and CP_Minid.
Give them more meaningful labels.
c Run the report to test. Scroll down to the last page to see the new
columns.
d Save the report as p9q5.rdf and close it.

......................................................................................................................................................
Developer/2000: Build Reports A-49
Appendix A: Solutions
......................................................................................................................................................

Practice Session Overview: Lesson 10


This practice session contains:
• Opening an existing report to add header and trailer pages
• Modifying an existing report to add a button to display a multimedia
column
• Modifying an existing report to add a repeating frame to the header page
displaying order information.
• Opening an existing report and adding flexible lines.
• Modifying an existing report to anchor a boilerplate object to an outer
frame.

Introduction
In this practice session you use reports created in earlier practice sessions.
The aim is to familiarize you with the different layout regions of a report.
You also add flexible lines to a frame and anchor one object to another.

......................................................................................................................................................
A-50 Developer/2000: Build Reports
Practice Session Solutions: Lesson 10
......................................................................................................................................................

Practice Session Solutions: Lesson 10


1 Open report p9q4.rdf. Modify the report as follows:
a Create a header page.
Open the Layout Model editor. Choose Header from the
horizontal toolbar or choose Layout Section—>Header View
from the menu.
Display the summitlo.tif file as fixed boilerplate.
Choose File—>Import—>Image from the menu to import the
file. Move and resize it.
Add a rectangle boilerplate object. Give it fill color
Choose the Rectangle tool from the vertical toolbar. Make the
rectangle large enough to fit the logo inside.
Choose Fill Color from the vertical toolbar.
Place the logo on top of the rectangle. Center the two objects.
Select the rectangle, and choose Arrange—>Send to back from
the menu.
Select the logo, press the shift key and select the rectangle.
Choose Arrange—>Align Objects from the menu. In the dialog
box select Align to each other and then Align Center both
horizontally and vertically. Choose Ok.
Hint: Use the Arrange option from the menu.
b Add a report title.
Use font Arial, size 18 bold.
Choose 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, choose font and size from the
stylebar.

......................................................................................................................................................
Developer/2000: Build Reports A-51
Appendix A: Solutions
......................................................................................................................................................

Add a trailer page which displays today’s date with the text “End of
c
report run on: ”. Choose a larger font.
Hint: Copy and paste the date from the Margin Area of the report.
Choose Trailer from the horizontal toolbar, or choose Layout
Section—>Trailer View from the menu.
Choose 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, choose font and size from the
stylebar.
Choose Margin from the horizontal toolbar, or choose Layout
Section—>Margin View from the menu.
Select the f_date1 field then choose Edit—>Copy from the menu.
Choose Trailer from the horizontal toolbar, or choose Layout
Section—>Trailer View from the menu.
Choose Edit—>Paste from the menu, and move the field to the
desired place.
d Run and test the report.
e Save the report as p10q1.rdf and close it.
2 Open report p9q3.rdf and modify it to display the product picture in a
separate window.
a Delete field F_PICTURE from the body of the Layout Model (not
the column from the Data Model!).
Open the Layout Model editor. Choose Body from the horizontal
toolbar or choose Layout Section—>Body View from the menu.
Select the f_filename field and press delete.

......................................................................................................................................................
A-52 Developer/2000: Build Reports
Practice Session Solutions: Lesson 10
......................................................................................................................................................

b Add a button to display the picture from the multimedia column.


Give it a meaningful label.
Choose the button tool from the vertical toolbar, and create a
button in place of the f_filename field.
Make the following changes in the property palette:

Property Value
Name PICTURE_BUTTON
Label Type Text
Text Picture
Type Multimedia Column
Multimedia Column Filename

c Resize the other layout fields to 1/4 inch in height.


Hint: Use the Arrange option in the menu.
Select all the layout fields by shift-clicking on them.
Choose Arrange—>Size Objects from the menu.
Select custom for height and enter .25.
d Make the button the same size.
Hint: Use the Arrange option in the menu.
e Give all fields and the button the same vertical alignment.
Hint: Use the Arrange option in the menu.
Align the fields and the button using Arrange—>Align Objects
from the menu.
f Resize the repeating frame and all enclosing frame to be just large
enough to fit the fields inside.
Hint: Think of the Flex Mode.
Resize the repeating frame.
g Save the report as p10q2.rdf and close it.
h Run and test your report. Run the .rdf file from the Reports Runtime,
do not use the Live Previewer!

......................................................................................................................................................
Developer/2000: Build Reports A-53
Appendix A: Solutions
......................................................................................................................................................

3 Open report p9q1.rdf.


Add a header page to list all orders and order dates contained in the
a
report.
Hint: Use the additional layout feature for this.
Open the Layout Model editor. Choose Header from the
horizontal toolbar, or choose Layout Section—>Header View
from the menu.
Choose the Additional Layout tool from the vertical toolbar, and
click in the layout area.
In the Report wizard choose a tabular layout.
Select the group G_ORD and give a print direction down.
Select the fields ID and DATE_ORDERED.
b Save the report as p10q3.rdf and close it.
4 Open report p5q3.rdf.
a Use the Report wizard to give last_name and first_name a width of
6. (You can also do it directly in the Layout Model or from the Live
Previewer.)
b Add flexible lines vertically between the fields.
Choose the line tool from the vertical toolbar. Create lines
between the fields. If you want to ensure that the lines are
vertical, press the shift key while drawing. Make the lines the
same height as the fields using the Arrange—>Size Objects menu
option.
In the property palette set Line Stretch with Frame to
R_G_LAST_NAME.
c Run and test the report.
d Save the report as p10q4.rdf.

......................................................................................................................................................
A-54 Developer/2000: Build Reports
Practice Session Solutions: Lesson 10
......................................................................................................................................................

If You Have Time


5 Continue with report p10q4.rdf.
a Add boilerplate and anchor it to half way down the right side of the
report group frame.
Hint: To ensure that you get the right frame, select the frame
M_G_LAST_NAME_GRPFR. You can use either the Object
Navigator or the Select Parent Frame tool. Pull the frame out slightly
to the right. After you have fastened your anchor you can make it
smaller again.
Choose the Text tool from the vertical toolbar, and click to the
right of the layout objects. Enter the text, and click outside the
text object.
Give it a line color. This makes it easier to click on the edge.
Click on a field, choose Select Parent Frame from the stylebar
twice to select the group frame. Drag the right edge a little to the
right to make the frame larger.
Select the Anchor tool from the vertical toolbar, and click on the
left edge of the boilerplate text object. Then click on the right
edge of the group frame. You can press the shift key while you
create the anchor to anchor it at 50% of the edges or you can
make the adjustments later in the property palette of the anchor.
Move the boilerplate so that the anchor is a straight horizontal
line.
Resize the group frame to its original size.
b Run and check that the text is in fact half way down the data output.
c Rerun the report, this time only displaying 10 rows. The boilerplate
should still be halfway down the data output.
Create a group filter in the Data Model editor to restrict the
number of records.
d Save the report as p10q5.rdf and close it.

......................................................................................................................................................
Developer/2000: Build Reports A-55
Appendix A: Solutions
......................................................................................................................................................

Practice Session Overview: Lesson 11


This practice session contains:
• Modifying the printing of a mailing label report
• Controlling the number of records on a page
• Adding a link file to a report
• Ensuring that all details of a master print on the same page
• Creating a page level running sum and a carry over sum

Introduction
Modify a mailing label report to ensure you fill the printed page with label
records. You then restrict the number of labels that print on each page.
You add a link file to display a company logo by dynamically referencing a
file at runtime.

......................................................................................................................................................
A-56 Developer/2000: Build Reports
Practice Session Solutions: Lesson 11
......................................................................................................................................................

Practice Session Solutions: Lesson 11


1 Open report p4q4.rdf.
a Modify the layout so that the mailing labels are 2 inches wide and 1
inch high. Use the Arrange option in the menu. Ensure that the
company names print in alphabetical order across the page.
Open the Layout Model editor. Select the repeating frame: either
select the boilerplate object in the Layout Model editor and then
choose Select Parent Frame from the stylebar,
or select the repeating frame in the Object Navigator.
While the Layout Model editor is the active window, choose
Arrange—>Size Objects from the menu. Select Custom for both
width and height, and enter the width and height in the fields
below.
You can also drag the repeating frame in the Layout Model
editor to the desired width and height.
Add an order by clause to the query.
b Give each label a solid fill.
Choose Fill Color from the vertical toolbar, and select a color.
c Make the boilerplate object 1.8 inches wide and center it horizontally
and vertically in the repeating frame.
Select the boilerplate object in the Layout Model editor, and
choose Arrange—>Size Objects from the menu. Select Custom
for the width and No Change for the height. Enter the width in
the field below.
Select both the boilerplate object and the repeating frame, and
choose Arrange—>Align Objects from the menu.
d Add spacing between the labels: .25 inch between each column of
labels across the page; .5 inch between each row of labels down the
page.
Select the repeating frame and open the property palette. Set
Horizontal Space Between Frames to .25 and Vertical Space
Between Frames to .5
e Save the report as p11q1.rdf.

......................................................................................................................................................
Developer/2000: Build Reports A-57
Appendix A: Solutions
......................................................................................................................................................

2 Continue with report p11q1.rdf.


Modify the report so that only six labels print on each page.
a
Select the repeating frame and open the property palette. Set
Maximum Records per Page to 6.
b Save the report as p11q2.rdf and close it.
3 Open p9q1.rdf.
a On the operating system copy the file summitlo.tif to a file logo.tif.
Ask your instructor for help, because this is operating system
specific.
b Delete the logo in the margin area and create a link file in its place to
display the contents of logo.tif.
Choose Margin from the horizontal toolbar, or choose Layout
Section—>Margin View from the menu.
Select the logo boilerplate object and press Delete.
Choose the Link File tool from the vertical toolbar and create an
external boilerplate object in the margin region where the logo
was.
Set the following properties:

Property Value
Name B_logo
Source File Format Image
Source File Name logo.tif

c Run the report.


d On the operating system copy any other .tif file to logo.tif.
Ask your instructor for help, because this is operating system
specific.
e Rerun your report.
f Save the report as p11q3.rdf.

......................................................................................................................................................
A-58 Developer/2000: Build Reports
Practice Session Solutions: Lesson 11
......................................................................................................................................................

4 Continue with report p11q3.rdf.


a Ensure that all items of one order are printed on the same page.
Choose Body from the horizontal toolbar, or choose Layout
Section—>Body View from the menu.
Open the property palette for the repeating frame R_G_ORD,
and set the property Page Protect to Yes.
b Save the report as p11q4.rdf and close it.

......................................................................................................................................................
Developer/2000: Build Reports A-59
Appendix A: Solutions
......................................................................................................................................................

Practice Session Overview: Lesson 12


This practice session contains:
• Modifying an existing report to use a bind parameter
• Adding a dynamic list of values
• Adding a lexical parameter
• Adding a static list of values
• Creating a customized parameter form

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.

......................................................................................................................................................
A-60 Developer/2000: Build Reports
Practice Session Solutions: Lesson 12
......................................................................................................................................................

Practice Session Solutions: Lesson 12


1 Open report p11q3.rdf.
a In the Report wizard add the following columns from the
S_CUSTOMER table. Create a new group for the customer
information above the order group.

Column Label Width


NAME 30
ADDRESS 30
CITY 30

Create a reference to a bind parameter P_CUSTOMER in the query


to restrict orders to the parameter value you input at run time.
Note how Reports creates the parameter automatically.
Add the following to the WHERE clause of the query:

AND s_customer.id =:p_customer

Run and test the report with valid customer ids.


b
Choose any number in the range 201 to 215.
c Save the report as p12q1.rdf. Do not close it.
2 Continue with report p12q1.rdf.
Add a list of values to select any valid customer id in the
S_CUSTOMER table. Do not allow users to enter any other value.
The list should display customer names, not id numbers.
In the Object Navigator, expand the Data Model node, and the
User Parameter node.
Open the property palette for the P_CUSTOMER parameter,
and ensure that the datatype is Number.
In the parameter property palette, choose List of Values.
In the dialog box, choose Select Statement.
Ensure the Restrict List to Predetermined Values check box is

......................................................................................................................................................
Developer/2000: Build Reports A-61
Appendix A: Solutions
......................................................................................................................................................

checked.
Check the Hide First Value check box.
Enter the following statement in the Enter Query area:

SELECT id, name


FROM s_customer
ORDER BY name

Run and test the report with different values.


d
e Save the report as p12q2.rdf. Do not close it for the moment.
3 Open report p5q3.rdf.
a Create a lexical parameter to enable users to order the data by
different columns (or not at all) at run time. Replace the ORDER BY
clause in the query with a lexical reference to the parameter. Type in
an initial value for the parameter, to order by the employee’s last
name.
In the Object Navigator, expand the Data Model node. Double-
click the User Parameter node, to create a parameter.
Select the parameter name P_1 and change it to P_ORDER.
Open the parameter property palette.
Ensure that the datatype is Character, and increase the width to
50.
Enter an Initial Value:
ORDER BY s_emp.last_name
In the Data Model, open the query property palette and add the
following lexical reference to the end of the query:
&P_ORDER
b Add a static list of values. Code two or three alternative ORDER BY
clauses. Allow any clause to be entered at run time.
In the parameter property palette, choose List of Values.
In the dialog box choose Static Values and enter other order by
clauses in the Value field, for example:
ORDER BY s_emp.last_name
ORDER BY s_emp.title
For each Value, remember to choose Add>> to add the value to
the list.
Clear the Restrict List to Predetermined Values check box.

......................................................................................................................................................
A-62 Developer/2000: Build Reports
Practice Session Solutions: Lesson 12
......................................................................................................................................................

c Run the report to test.


Select an order by clause from the list.
Enter your own order by clause.
Delete the default parameter value.
d Save the report as p12q3.rdf and close it.

......................................................................................................................................................
Developer/2000: Build Reports A-63
Appendix A: Solutions
......................................................................................................................................................

4 Continue with report p12q2.rdf.


a Create a default parameter form.
Include a Title message, but not a Hint message.
Display the parameters DESNAME and P_CUSTOMER.
Select Tools—>Parameter Form Builder from the menu.
Enter your own Title message. Delete the Hint message.
Select DESNAME.
P_ORDER is already selected.
b Use your imagination to customize the form in the Parameter Form
editor.
Ensure that the parameter P_CUSTOMER is placed in a prominent
position for user entry.
Add some graphics; modify colors and fill patterns.
No formal solution
c Run the report to test.
d Save the report as p12q4.rdf and close it.

......................................................................................................................................................
A-64 Developer/2000: Build Reports
Practice Session Overview: Lesson 13
......................................................................................................................................................

Practice Session Overview: Lesson 13


This practice session contains:
• Using the Chart wizard to create a chart in an existing report
• Altering the chart with the Chart wizard
• Creating charts in an existing report that will print once for each record
of a group

Introduction
In this practice session you open existing reports to add charts using the
chart wizard. You also reenter the chart wizard to change the characteristics
for a chart.

Instructor Note
Due to a known problem in production release of Developer/2000 R2.0, the
Chart wizard may not work properly. Be sure to tell students to close the
Graphics Batch after each run of the report.

......................................................................................................................................................
Developer/2000: Build Reports A-65
Appendix A: Solutions
......................................................................................................................................................

Practice Session Solutions: Lesson 13


1 Open report p12q1.rdf.
a Remove all reference to the parameter P_CUSTOMER from the
query.
Open the Data Model editor.
Use the right mouse button to open the SQL Query Dialog.
Delete the row:
AND S_CUSTOMER.ID = :P_CUSTOMER
b Rename SumLine_totalPerNAME to Total. (A shorter name looks
better in a chart.)
Open the property palette for SumLine_totalPerNAME to
change the name or make the change in the Object Navigator.
c Use the Chart wizard to create a line chart.
Choose Tools—>Chart Wizard from the menu, and enter the
following properties in the wizard pages:
Chart Type Line
Chart Subtype Plain
Category NAME
Value TOTAL
Position At the beginning of the report
File Name p13q1.ogd

d Run report to test. Resize the chart if necessary.


e Close the Graphics Batch.
f Save report to p13q1.rdf.

......................................................................................................................................................
A-66 Developer/2000: Build Reports
Practice Session Solutions: Lesson 13
......................................................................................................................................................

2 Reenter the Chart wizard to change characteristics of the chart created in


the previous exercise.
Ensure that the chart is selected, otherwise you will create a new
chart.
Choose Chart Wizard from the horizontal toolbar or Tools—>
Chart Wizard from the menu.
a Give the chart the following characteristics:
Enter the following properties in the wizard pages:
Title Ordertotal per Customer
Chart Style Column
Chart Subtype Depth

Run the report to test.


b
c Close the Graphics Batch.
d Save report to p13q2.rdf and close it.
3 Open report p8q5.rdf.
a Use the Chart wizard to create a pie chart for the data group
G_PRODUCT.
Choose Chart Wizard from the horizontal toolbar or Tools—>
Chart Wizard from the menu, and enter the following properties
in the wizard pages:
Chart Type Pie
Chart Subtype Plain
Data Group G_product
Category PRODUCT_ID
Value PROD_TOTAL
Chart Frequency Once per Name
File Name p13q3a.ogd

......................................................................................................................................................
Developer/2000: Build Reports A-67
Appendix A: Solutions
......................................................................................................................................................

b In the layout editor move the chart beneath the product group and
resize it to the same width as the product group.
Select the chart and drag it below the product group frame. You
will need to enable Flex Mode. Do not forget to tun it off again
when you have finished.
Select the group frame and the chart, and choose Arrange—>
Size Objects from the menu to resize the chart.
c Run and test the report.
d Close the Graphics Batch.
e Create a second chart for the customer group
Choose Chart Wizard from the horizontal toolbar or Tools—>
Chart Wizard from the menu, and enter the following properties
in the wizard pages:
Chart Type Pie
Chart Subtype Plain
Data Group G_customer
Category CUSTOMER_ID
Value CUST_TOTAL
Chart Frequency Once per Name
File Name p13q3e.ogd

f In the layout editor move the chart beneath the customer group.
Select the chart and drag it below the product group frame. You
will need to enable Flex Mode. Do not forget to tun it off again
when you have finished.
g Run and test the report.
h Close the Graphics Batch.
i Save the report to p13q3.rdf and close it.

......................................................................................................................................................
A-68 Developer/2000: Build Reports
Practice Session Overview: Lesson 14
......................................................................................................................................................

Practice Session Overview: Lesson 14


This practice session contains:
• Opening and changing an existing matrix report
• Building a nested matrix report
• Adding summaries to the nested matrix report
• Displaying zeros for summary values and restricting the number of
columns per page
• Displaying more meaningful column information and rotating the text

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

......................................................................................................................................................
Developer/2000: Build Reports A-69
Appendix A: Solutions
......................................................................................................................................................

Practice Session Solutions: Lesson 14


1 Open report p4q6.rdf.
aUse the Report wizard to apply a template file to the report. The file
corpmat.tdf should be located in your working directory. The new
template gives you spaces between the layout objects to make it
easier to see the different objects in the Layout editor.
b How many repeating frames do you have?
There are two repeating frames, R_G_NAME and
R_G_PRODUCT_ID.
c Change the properties of the cell object to display zero for a null
value.
Open the property palette for F_SumTOTAL_VALUE and set
Value if Null to 0.
d Run and test the report.
All cells without a value now display 0.
e Close the report without saving it.
2 Create a new report, importing the external query p4q6.sql from your
working directory.
Choose File—>New—Report from the menu, or open a new report
in the Object Navigator. Use the Report wizard.
a Choose the following settings:
Report Style Matrix
Query (import file p4q6.sql)
Matrix Row Fields - Level 1 - Month
- Level 2 - Name
Matrix Column Fields Product_id
Matrix Cell Fields Sum of total_value
Matrix Totals Sum of the cell field

......................................................................................................................................................
A-70 Developer/2000: Build Reports
Practice Session Solutions: Lesson 14
......................................................................................................................................................

b Change the labels and widths for the following fields:

Field Label Width


NAME Customer 10
PRODUCT_ID Product 5
MONTH Month 4
SUMTOTALVALUE Total 5
All Summaries Total: 5

c Run the report.


d Which summaries were created?
SumTOTAL_VALUEPerName
SumTOTAL_VALUEPerPRODUCT_ID
SumTOTAL_VALUEPerReport
These are the row, the column, and the report summaries.

......................................................................................................................................................
Developer/2000: Build Reports A-71
Appendix A: Solutions
......................................................................................................................................................

e Use the Data Model editor to create summaries for each month and
for the level month and product.
Create both summaries in the cross product group.
Use the following settings:

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

f Use the Layout editor to create the fields. You will have to expand
the appropriate repeating frame.
Select and expand R_G_MONTH. You will need to enable Flex
Mode. Do not forget to disable it again when you have finished.
Choose 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

......................................................................................................................................................
A-72 Developer/2000: Build Reports
Practice Session Solutions: Lesson 14
......................................................................................................................................................

Choose the Field tool from the vertical toolbar.


Create a field below F_SumSumTOTAL_VALUEPerNAME.
Position the field in the R_G_MONTH repeating frame but
outside any other repeating frames.
Set the following properties:

Property Value
Name F_SumMonth
Source SumMonth

Run and test the report.


g
h Save the report as p14q2.rdf. Do not close it.
3 Continue with the report from the previous exercise.
a Add zeros for null values in the cells.
Open the property palette for F_SumTOTAL_VALUE, and set
Value if Null to 0.
b Ensure that the report shows only three product columns on each
page.
Open the property palette for R_G_PRODUCT_ID, and set
Maximum Records per Page to 3.
c Format all numeric data to be right aligned.
Use the style bar.
d Add comas and two decimal places where appropriate.
Use the style bar.
e Run and test the report.
f Save the report as p14q3.rdf, and close it.

If You Have Time


4 Open the report as p14q3.rdf.
a Make the necessary changes in the Data Model editor to include the
product name.

......................................................................................................................................................
Developer/2000: Build Reports A-73
Appendix A: Solutions
......................................................................................................................................................

Use the right mouse button to open the SQL Query Dialog.
The query should read:

SELECT S_CUSTOMER.NAME
, S_ITEM.PRODUCT_ID
, SUM(S_ITEM.PRICE*S_ITEM.QUANTITY_SHIPPED) TOTAL_VALUE
, TO_CHAR(S_ORD.DATE_ORDERED, 'MM/RR') MONTH
, S_PRODUCT.NAME PRODUCT
FROM S_CUSTOMER, S_ITEM, S_ORD, S_PRODUCT
WHERE S_ITEM.PRODUCT_ID LIKE '4%'
AND S_ITEM.ORD_ID=S_ORD.ID
AND S_PRODUCT.ID=S_ITEM.PRODUCT_ID
AND S_ORD.CUSTOMER_ID=S_CUSTOMER.ID
GROUP BY S_CUSTOMER.NAME
, S_ITEM.PRODUCT_ID
, TO_CHAR(S_ORD.DATE_ORDERED, 'MM/RR')
, S_PRODUCT.NAME

b In the Layout Model editor delete the product_id field and insert a
boilerplate object to display the product name. Rotate this object by
90 degrees.
Select F_PRODUCT_ID and press delete.
Choose the text tool from the vertical toolbar, and create a text
object in the place of the F_PRODUCT_ID field.
Enter: &PRODUCT.
Select the boilerplate object.
Choose the Rotate tool from the vertical toolbar.
Press shift and click on the boilerplate object to rotate it by 90
degrees.
Open the property palette for the boilerplate object, and set
Vertical and Horizontal Elasticity to variable.
c Run and test the report.
d Save the report as p14q4.rdf, and close it.

......................................................................................................................................................
A-74 Developer/2000: Build Reports
Practice Session Overview: Lesson 15
......................................................................................................................................................

Practice Session Overview: Lesson 15


This practice session contains:
• Creating a format trigger to conditionally display different layouts
• Creating and use a report-level PL/SQL function.
• Creating and use an external PL/SQL library.
• Creating a PL/SQL group filter.

Introduction
In this practice session, you create a format trigger to conditionally one of
two layout versions 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.

......................................................................................................................................................
Developer/2000: Build Reports A-75
Appendix A: Solutions
......................................................................................................................................................

Practice Session Solutions: Lesson 15


1 Create a new report, using p15q1.sql.
a Display the records in two different layouts, showing different
columns in each.
b Create a Group Above layout using the following columns from the
query:
Create a new report, using the Report wizard.
Import the SQL Query from file p15q1.sql.
Display the following fields. Choose Labels and other properties
as you wish.

Group Column
G_CUSTOMER CUSTOMER_ID
G_ID ID
DATE_ORDERED
DATE_SHIPPED
PAYMENT_TYPE
TOTAL

c Create a Tabular layout using the following columns from the query:
In the Layout Model editor choose the Additional Default
Layout tool from the vertical toolbar.
Display the following fields. Choose Labels and other properties
as you wish.

Column
ID
DATE_ORDERED
DATE_SHIPPED
TOTAL

......................................................................................................................................................
A-76 Developer/2000: Build Reports
Practice Session Solutions: Lesson 15
......................................................................................................................................................

d Ensure that only the Group Above layout displays when you choose
a destination of Screen, and only the Tabular layout displays when
you choose a destination of Preview.
Create a format trigger on the M_G_CUSTOMER_ID_GRPFR
group frame in the first layout.

function M_G_CUSTOMER_ID_GRPFRFormatTrigger return BOOLEAN is


begin
if:destype = ’Screen’ then
return(true);
else
return(false);
end if;

Create a format trigger on the M_G_ID_GRPFR1 group frame in the second


layout, with the reverse logic:

function M_G_ID_GRPFR1FormatTrigger return BOOLEAN is


begin
if :destype = ’Preview’ then
return(true);
else
return(false);
end if;

Create an anchor from the top edge of the second layout group frame up to the
bottom edge of the first layout group frame.
Open the anchor property palette, and set the Collapse Vertically property to Yes.
Alternatively, ensure there is almost no space between the two layouts, so that
there is no extra white space at the top of the report when the second layout is
output.
To test the result, display the DESTYPE parameter in the report.
Create a field to display the system parameter DESTYPE.
Ensure that you can enter a parameter value at runtime.
Choose Tools—>Parameter Form Builder from the menu to create a parameter
form.
Test the report by changing the Destination Type parameter on the
Runtime Parameter Form.
e Save the report as p15q1.rdf.

......................................................................................................................................................
Developer/2000: Build Reports A-77
Appendix A: Solutions
......................................................................................................................................................

2 Continue with the previous report.


a Modify the report so that the Tabular (“Preview”) layout displays an
extra column that indicates, with an asterisk, those orders that were
shipped more than 15 days after the order date.
Create a new Program Unit, either from the Tools menu or in the
Object Navigator. Create a function called ASTERISK:

function asterisk return char is


begin
if :date_ordered + 15 < :date_shipped then
return(’*’);
else
return(’’);
end if;

In the Data Model editor, create a formula column in the detail group G_ORD.
Open the property palette, and alter the following properties for the column
CF_ASTERISK:

Name Datatype Width


CF_ASTERISK Character 1

Click PL/SQL Formula, to open the PL/SQL editor, and call the ASTERISK function
from the formula.

function CF_asteriskFormula return Char is


begin
return(asterisk);
end;

In the Layout editor, increase the width of the R_G_ID1 repeating frame in the
second layout to allow room for another field.
Create a field inside the repeating frame, rename it F_CF_ASTERISK and
source it to CF_ASTERISK.
b Remember to change destination to Preview during testing!
Save the report, and test it.

......................................................................................................................................................
A-78 Developer/2000: Build Reports
Practice Session Solutions: Lesson 15
......................................................................................................................................................

c Move the function code into a new PL/SQL library, named


p15lib.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.
Open the new function in the library and alter the code to pass
the two dates as arguments, because the report columns are not
recognized in a library.

function asterisk return char is


odate date,
sdate date
begin
if odate + 10 < sdate then
return(’*’);
else
return(’’);
end if;
end;

Modify the LATE_SHIP formula code to pass the values of


DATE_ORDERED and DATE_SHIPPED to the function.
Delete the report-level ASTERISK function.
d Call the external function from your report, instead of calling the
report-level function.
e Save the report to p15q2.rdf.
3 Continue with the previous report.
a Modify the same layout to display additional spacing between every
two records.
b Save the report as p15q3.rdf and close it.

......................................................................................................................................................
Developer/2000: Build Reports A-79
Appendix A: Solutions
......................................................................................................................................................

If You Have Time


4 Open report p15q1.rdf.
a Write your own group filter to restrict the number of customers
displayed depending on the value of a parameter that you enter at
runtime.
Hint: You need to create two parameters, to keep track of how many
records have been processed compared to the cutoff number of
records required.
In the Object Navigator, open the Data Model node, and
double-click the User Parameters node to create the first
parameter.
Choose the Create tool to create a second parameter.
Rename the parameters, P_COUNT_CUST and P_CUTOFF.
Give P_COUNT_CUST an initial value of 0.
Open the G_CUSTOMER_ID group property palette.
Set Filter Type to PL/SQL
Choose PL/SQL Filter to open the PL/SQL editor.
Enter the following code:

function G_CUSTOMER_IDGroupFilter return boolean is


begin
:p_count_cust := :p_count_cust + 1;
if :p_count_cust <= nvl(:p_cutoff, :p_count_cust) then
return(TRUE);
else
return(FALSE);
end if;
end;

b Test the report several times by changing the cutoff parameter at


runtime.
c Save the report as p15q4.rdf.

......................................................................................................................................................
A-80 Developer/2000: Build Reports
Practice Session Overview: Lesson 16
......................................................................................................................................................

Practice Session Overview: Lesson 16


This practice session contains:
• Building a report containing conditional highlighting
• Building a drill-down report
• Writing to a temporary table from a report

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 separate report from a
button in the previewer.
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.

......................................................................................................................................................
Developer/2000: Build Reports A-81
Appendix A: Solutions
......................................................................................................................................................

Practice Session Solutions: Lesson 16


1 Open report p8q5.rdf.
a Display the column CUST_TOTAL in the customer group as red,
bold italics if its value is 10,000 or more.
Hint: Use the following mask attributes:
Mask Attribute Suggested Values
SRW.ATTR.GCOLOR red
SRW.ATTR.WEIGHT SRW.BOLD_WEIGHT
SRW.ATTR.STYLE SRW.ITALIC_STYLE

You can import the file p16q1a.txt.


Open the PL/SQL editor, and create a function to apply the
format mask.

function FIELD_MASK return boolean is


begin
/* what attributes? */
srw.attr.mask:= srw.gcolor_attr +
srw.weight_attr +
srw.style_attr;
/* what values? */
srw.attr.gcolor := ’red’;
srw.attr.weight := srw.bold_weight;
srw.attr.style := srw.italic_style;
/* now apply the mask */
srw.set_attr(0,srw.attr);
return(TRUE);
end;

......................................................................................................................................................
A-82 Developer/2000: Build Reports
Practice Session Solutions: Lesson 16
......................................................................................................................................................

b Alter the pattern and color of those records where the customer total
is 5000 or less.
Hint: Use the following attributes:
Mask Attribute Suggested Values
SRW.ATTR.FILLPATT (fill pattern) crisscross, sandpaper
blue, cyan, green, magenta, red,
SRW.ATTR.BFCOLOR (background fill) yellow
SRW.ATTR.FFCOLOR (foreground fill)

You can import the file p16q1b.txt.


Open the PL/SQL editor, and create a function to apply the
format mask.

function RECORD_MASK return boolean is


begin
/* what attributes? */
srw.attr.mask:= srw.fillpatt_attr +
srw.ffcolor_attr +
srw.bfcolor_attr;
/* what values? */
srw.attr.ffcolor := ’green’;
srw.attr.bfcolor := ’yellow’;
srw.attr.fillpatt := ’sandpaper’;
/* now apply the mask */
srw.set_attr(0,srw.attr);
return(TRUE);
end;

......................................................................................................................................................
Developer/2000: Build Reports A-83
Appendix A: Solutions
......................................................................................................................................................

c Write the necessary format triggers.


Create a format trigger on the F_CUST_TOTAL field to call the
function.

function F_CUST_TOTALFormatTrigger return boolean is


begin
if :cust_total >= 10000 then
return(field_mask);
else
return(TRUE);
end if;
end;

Create a format trigger on the R_G_CUSTOMER repeating frame to call


the function.

function R_G_CUSTOMERFormatTrigger return boolean is


begin
if :cust_total <= 5000 then
return(record_mask);
else
return(TRUE);
end if;
end;

d Save the report as p16q1.rdf.

......................................................................................................................................................
A-84 Developer/2000: Build Reports
Practice Session Solutions: Lesson 16
......................................................................................................................................................

2 Call a drill-down report, using a button.


a Continue with the previous report.
b Alter query Q_2 to include the customer ID, but do not display it in
the report.
Use the right mouse button to open the SQL Query Dialog.
The query should read:

SELECT S_ORD.SALES_REP_ID
, S_CUSTOMER.NAME CUSTOMER
, SUM(S_ORD.TOTAL) CUST_TOTAL
, S_ORD.CUSTOMER_ID
FROM S_ORD, S_CUSTOMER
WHERE S_ORD.CUSTOMER_ID=S_CUSTOMER.ID
GROUP BY S_ORD.SALES_REP_ID
, S_CUSTOMER.NAME
, S_ORD.CUSTOMER_ID

Add a button to this report, to display a drill-down report when the button is
pressed at run time. The button should display once for every customer record.
In the Layout editor, increase the width of the R_G_CUSTOMER repeating
frame to allow room for the button.
Create a button inside the repeating frame.
c When the button is pressed, the detail report (p12q1.rdf) is called
with the customer ID as a parameter.
Hint: Have a look at report p12q1.rdf to check the name of the
parameter.
You can import the file p16q2d.txt.
Open the property palette for the button, and set the Type
property to PL/SQL.
Import the file p16q2d.txt into the PL/SQL code, or enter the
following code:

procedure U_1ButtonAction is
begin
srw.run_report('report=s12q1.rdf
p_customer='||to_char(:customer_id)||' paramform=no');
end;

d Save the report as p16q2.rdf.

......................................................................................................................................................
Developer/2000: Build Reports A-85
Appendix A: Solutions
......................................................................................................................................................

e Test the report using the runtime executable and the close the
runtime.

......................................................................................................................................................
A-86 Developer/2000: Build Reports
Practice Session Solutions: Lesson 16
......................................................................................................................................................

If You Have Time


3 Open report p9q1.rdf.
In this report, you use report triggers to create a temporary table at the start
of report execution, and you insert rows into the table at various stages of the
execution.
a Write a trigger that creates a temporary table to hold the date and
userid each time the report is run. The table should contain three
columns: one date column, one character column of width 10, and
one character column of width 80.

CREATE TABLE RUNREPORT


(DATE_RUN DATE, USER_RUN VARCHAR2(10), COMMENTS VARCHAR2(80)

In the Object Navigator, expand the Report Triggers node, and


double-click the Before Report PL/SQL icon to open the PL/SQL editor.
Create the following function.

function BeforeReport return boolean is


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;

......................................................................................................................................................
Developer/2000: Build Reports A-87
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’’)’);
return(TRUE);
end;

c Save the report as p16q3.rdf.


d Compile the PL/SQL and run the report. Make sure you view more
than one page.
e Run and test the report.
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-88 Developer/2000: Build Reports
Practice Session Solutions: Lesson 16
......................................................................................................................................................

i Try running the report more than once. When you run the report a
second time, the table already exists and Report 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’’)’);
return(TRUE);
end;
end;

......................................................................................................................................................
Developer/2000: Build Reports A-89
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’’)’);
return(TRUE);
end;

k Write a trigger that inserts a record with the comment “Report


completed” when the report finishes.Save and run the report.
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 Pages.
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’’)’);
return(TRUE);
end;

l Verify the results in SQL*Plus.

......................................................................................................................................................
A-90 Developer/2000: Build Reports
Practice Session Overview: Lesson 17
......................................................................................................................................................

Practice Session Overview: Lesson 17


This practice session contains:
• Running a report on your local machine
• Running reports on a remote server using the report Queue Manager
• Copying output from remote server to your local machine
• Running a report on a remote server using the command line

Introduction
In this practice session you run a report locally and then on a remote server,
using the Queue Manager. You also use the Queue Manager to view the
submitted jobs.
If you have time, you can submit a report to a remote server using the
command line options.

Instructor Note
To run this practice session, a remote server called repserver1 must be set
up. The owner of the server must have access to a printer.
The tnsnames.ora file on each student PC must be configured to have access
to the remote server.
The reports longrun1.rdf and longrun2.rdf must be on the server as well as
on the client PCs.

......................................................................................................................................................
Developer/2000: Build Reports A-91
Appendix A: Solutions
......................................................................................................................................................

Practice Session Solutions: Lesson 17


1 Run longrun1.rdf on your local client machine.
aOpen longrun1.rdf and run the report. Notice the time it takes for the
report to run to completion. If it has not completed within five
minutes, note how many pages have been formatted, then cancel the
report.
Note: Ensure DESTYPE=FILE is set in the Parameter Form when
running this report.
2 Run longrun1.rdf and longrun2.rdf by calling the Reports Server from
the Queue Manager.
Note: Your instructor will give you specific instructions to complete this
exercise. The location of the remote server, directory paths, and so on,
might differ for your class.
a Invoke the Queue Manager. Enter repserver1 as your server name.
Note if there are any jobs in the queue.
b Schedule a new job to run longrun1.rdf report on the Reports Server.
Choose applicable settings from the tab pages of the Queue Manager.
For Destination Type, choose ToLocalFile, ToFile, or Cache; the
report default is Screen, which is not valid when running a remote
report.
Choose Job—>New from the menu, then choose Set Options.
In the dialog enter the following information:

Tab Parameter Value


General Report Name longrun1.rdf
Type 7 - ToServerCache
Data Connection User Name Your User Name
Password Your Password
Database Your Database
Output Options Output Driver PDF

......................................................................................................................................................
A-92 Developer/2000: Build Reports
Practice Session Solutions: Lesson 17
......................................................................................................................................................

c Do the same for longrun2.rdf.


Choose Job—>New from the menu, then choose Set Options.
In the dialog enter the following information:

Tab Parameter Value


General Report Name longrun2.rdf
Type 7 - ToServerCache
Data Connection User Name Your User Name
Password Your Password
Database Your Database
Output Options Output Driver PDF

dDisplay all jobs to see where your jobs are queued in relation to the
reports of other students.
Choose Show all Jobs from the toolbar if it is not selected.
e Display all your own jobs only.
Choose Show all My Jobs from the toolbar.
f Refresh the screen several times to see how quickly the report pages
are formatted.
Choose Refresh from the toolbar
g Cancel your own longrun2.rdf from the server queue.
Select the job and choose Job—>Remove from the menu.
3 When the report longrun1.rdf has finished, copy the output to a filename,
longrun1.pdf, in your home directory.
When the job has finished, it is no longer displayed in the Current
Jobs window.
Choose Show Past Jobs from the toolbar.
Select the job and choose Job—>Copy Output to, from the menu.
Choose your home directory.
Enter the filename longrun1.pdf, and choose Save.

......................................................................................................................................................
Developer/2000: Build Reports A-93
Appendix A: Solutions
......................................................................................................................................................

If You Have Time


4 Run longrun1.rdf by scheduling a new job from the command line.
a Using R30CLI from the command line, submit your longrun1.rdf
report to the Reports Server.
Your instructor will give you specific instructions to complete
this exercise, because this is operating system specific.
b Ensure the output is in PDF format and that it is cached.
On Windows platforms enter the following command:
R30CLI32 LONGRUN1.RDF USERID=<userid>/<password>
@<alias> SERVER=repserver1 DESTYPE=CACHE DESFORMAT=PDF

......................................................................................................................................................
A-94 Developer/2000: Build Reports
B
................................

Table Descriptions and


Data
Appendix B: Table Descriptions and Data
......................................................................................................................................................

Summit Sporting Goods Database Diagram

ORD_ID
ID
S_ITEM S_ORD

PRODUCT_ID CUSTOMER_ID
SALES_REP_ID

S_INVENTORY
*
PRODUCT_ID
ID

ID ID
S_CUSTOMER
S_PRODUCT SALES_REP_ID

IMAGE_ID

ID ID ID

S_IMAGE S_EMP
DEPT_ID

ID

S_DEPT

*Unique occurrences are identified by PRODUCT_ID and WAREHOUSE_ID.

......................................................................................................................................................
B-2 Developer/2000: Build Reports
S_CUSTOMER Description
......................................................................................................................................................

S_CUSTOMER Description
Column Name Null? Datatype
----------------------------------------- -------------------- -------------------------
ID NOT NULL NUMBER(7)
NAME NOT NULL VARCHAR2(50)
PHONE VARCHAR2(25)
ADDRESS VARCHAR2(400)
CITY VARCHAR2(30)
STATE VARCHAR2(20)
COUNTRY VARCHAR2(30)
ZIP_CODE VARCHAR2(75)
CREDIT_RATING VARCHAR2(9)
SALES_REP_ID NUMBER(7)
REGION_ID NUMBER(7)
COMMENTS VARCHAR2(255)

......................................................................................................................................................
Developer/2000: Build Reports B-3
Appendix B: Table Descriptions and Data
......................................................................................................................................................

S_CUSTOMER Data
SQL> SELECT * FROM s_customer;

Id Name Phone Address


------- ------------------ ------------ -----------
City State Country
-------------------- ---------------- ------------
Zip_code Credit_ra Sales_rep_id Region_id
---------- --------- ------------ ---------
Comments
--------------------------------------------------
201 Unisports 55-2066101 72 Via Bahia
Sao Paolo Brazil
Excellent 12 2
Customer Usually Orders Large Amounts And Has A High
Order Total. This Is Okay As Long As The Credit Rating
Remains Excellent.

202 Oj Atheletics 81-20101 6741 Takashi


Blvd.
Osaka Japan
Poor 14 4
Customer Should Always Pay By Cash Until His Credit
Rating Improves.

203 Delhi Sports 91-10351 11368


Chanakya
New Delhi India
Good 14 4
Customer Specializes In Baseball Equipment And Is The
Largest Retailer In India.

Continued on Next Page

......................................................................................................................................................
B-4 Developer/2000: Build Reports
S_CUSTOMER Data (continued)
......................................................................................................................................................

S_CUSTOMER Data (continued)


Id Name Phone Address
------- ------------------ ------------ -----------
City State Country
-------------------- ---------------- ------------
Zip_code Credit_ra Sales_rep_id Region_id
---------- --------- ------------ ---------
Comments
--------------------------------------------------
204 Womansport 1-206-104-0103 281 King
Street
Seattle Washington USA
98101 EXCELLENT 11 1

205 Kam’s Sporting Goods 852-3692888 15 Henessey


Road
Hong Kong EXCELLENT 15 4

206 Sportique 33-2257201 172 Rue de


Rivoli
Cannes France
EXCELLENT 15 5
Customer specializes in Soccer. Likes to order
accessories in bright colors.

207 Sweet Rock Sports 234-603620 6 Saint


Antoine
Lagos Nigeria
GOOD 3

Continued on Next Page

......................................................................................................................................................
Developer/2000: Build Reports B-5
Appendix B: Table Descriptions and Data
......................................................................................................................................................

S_CUSTOMER Data (continued)


Id Name Phone Address
------- ------------------ ------------ -----------
City State Country
-------------------- ---------------- ------------
Zip_code Credit_ra Sales_rep_id Region_id
---------- --------- ------------ ---------
Comments
--------------------------------------------------
208 Muench Sports 49-527454 435
Gruenestrasse
Stuttgart Germany
GOOD 15 5
Customer usually pays small orders by cash and large orders
on credit.

209 Beisbol Si! 809-352689 789 Playa Del


Mar
San Pedro de Macon’s Dominican Republic
EXCELLENT 11 1

210 Futbol Sonora 52-404562 3 Via


Saguaro Nogales
EXCELLENT 12 2
Customer is difficult to reach by phone. Try mail.

Continued on Next Page

......................................................................................................................................................
B-6 Developer/2000: Build Reports
S_CUSTOMER Data (continued)
......................................................................................................................................................

S_CUSTOMER Data (continued)


Id Name Phone Address
------- ------------------ ------------ -----------
City State Country
-------------------- ---------------- ------------
Zip_code Credit_ra Sales_rep_id Region_id
---------- --------- ------------ ---------
Comments
--------------------------------------------------
212 Hamada Sport 20-1209211 57A Corniche
Alexandria Egypt
EXCELLENT 13 3
Customer orders sea and water equipment.

213 Big John’s Sports 1-415-555-62814783 18th


Street Emporium
San Francisco CA USA
94117 EXCELLENT 11 1
Customer has a dependable credit record.

214 Ojibway Retail 1-716-555-7171


415 Main Street
Buffalo NY USA
14202 POOR 11 1

215 Sporta Russia 7-3892456 6000


Yekatamina
St. Petersburg Russia
Note: The above display has been formatted.

......................................................................................................................................................
Developer/2000: Build Reports B-7
Appendix B: Table Descriptions and Data
......................................................................................................................................................

S_DEPT Description and Data


Column Name Null? Datatype
--------------------------------------------------------------------------------------
ID NOT NULL NUMBER(7)
NAME NOT NULL VARCHAR2(25)
REGION_ID NUMBER(7)

SQL> SELECT * FROM s_dept;

ID NAME REGION_ID
------- --------------------- ---------
10 Finance 1
31 Sales 1
32 Sales 2
33 Sales 3
34 Sales 4
35 Sales 5
41 Operations 1
42 Operations 2
43 Operations 3
44 Operations 4
45 Operations 5
50 Administration 1

12 rows selected.

......................................................................................................................................................
B-8 Developer/2000: Build Reports
S_EMP Description
......................................................................................................................................................

S_EMP Description
Column Name Null? Datatype
----------------------------------------- -------------------- -------------------------
ID NOT NULL NUMBER(7)
LAST_NAME NOT NULL VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
COMMENT VARCHAR2(255)
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)
DEPT_ID NUMBER(7)
SALARY NUMBER(11,2)
COMMISSION_PCT NUMBER(4,2)

......................................................................................................................................................
Developer/2000: Build Reports B-9
Appendix B: Table Descriptions and Data
......................................................................................................................................................

S_EMP Data
SQL> SELECT * FROM s_emp;

ID LAST_NAME FIRST_NAME USERID START_DAT


---- ----------------- ----------- -------- ---------
COMMENTS
---------------------------------------------------
MANAGER_ID TITLE DEPT_ID SALARY
---------- -------------------- ------- ------
COMMISSION_PCT
---------------
1 Velasquez Carmen cvelasqu 03-MAR-90
President 50 2500
2 Ngao LaDoris lngao 08-MAR-90
1 VP, Operations 41 1450
3 Nagayama Midori mnagayam 17-JUN-91
1 VP, Sales 31 1400
4 Quick-To-See Mark mquickto 07-APR-90
1 VP, Finance 10 1450
5 Ropeburn Audry aropebur 04-MAR-90
1 VP, Administration 50 1550
6 Urguhart Molly murguhar 18-JAN-91
2 Warehouse Manager 41 1200
7 Menchu Roberta rmenchu 14-MAY-90
2 Warehouse Manager 42 1250
8 Biri Ben bbiri 07-APR-90
2 Warehouse Manager 43 1100
9 Catchpole Antoinette acatchpo 09-FEB-92
2 Warehouse Manager 44 1300

Continued on Next Page

......................................................................................................................................................
B-10 Developer/2000: Build Reports
S_EMP Data (continued)
......................................................................................................................................................

S_EMP Data (continued)


ID LAST_NAME FIRST_NAME USERID START_DAT
---- ----------------- ----------- -------- ---------
COMMENTS
---------------------------------------------------
MANAGER_ID TITLE DEPT_ID SALARY
---------- -------------------- ------- ------
COMMISSION_PCT
---------------
10 Havel Marta mhavel 27-FEB-91
2 Warehouse Manager 45 1307
11 Magee Colin cmagee 14-MAY-90
3 Sales Representative 31 1400
10
12 Giljum Henry hgiljum 18-JAN-92
3 Sales Representative 32 1490
12.5
13 Sedeghi Yasmin ysedeghi 18-FEB-91
3 Sales Representative 33 1515
10
14 Nguyen Mai mnguyen 22-JAN-92
3 Sales Representative 34 1525
15
15 Dumas Andre adumas 09-OCT-91
3 Sales Representative 35 1450
17.5
16 Maduro Elena emaduro 07-FEB-92
6 Stock Clerk 41 1400

Continued on Next Page

......................................................................................................................................................
Developer/2000: Build Reports B-11
Appendix B: Table Descriptions and Data
......................................................................................................................................................

S_EMP Data (continued)


ID LAST_NAME FIRST_NAME USERID START_DAT
---- ----------------- ----------- -------- ---------
COMMENTS
---------------------------------------------------
MANAGER_ID TITLE DEPT_ID SALARY
---------- -------------------- ------- ------
COMMISSION_PCT
---------------
17 Smith George gsmith 08-MAR-90
6 Stock Clerk 41 940
18 Nozaki Akira anozaki 09-FEB-91
7 Stock Clerk 42 1200
19 Patel Vikram vpatel 06-AUG-91
7 Stock Clerk 42 795
20 Newman Chad cnewman 21-JUL-91
8 Stock Clerk 43 750
21 Markarian Alexander amarkari 26-MAY-91
8 Stock Clerk 43 850
22 Chang Eddie echang 30-NOV-90
9 Stock Clerk 44 800
23 Patel Radha rpatel 17-OCT-90
9 Stock Clerk 34 795
24 Dancs Bela bdancs 17-MAR-91
10 Stock Clerk 45 860
25 Schwartz Sylvie sschwart 09-MAY-91
10 Stock Clerk 45 1100
25 rows selected.

Note: The above display has been formatted.

......................................................................................................................................................
B-12 Developer/2000: Build Reports
S_ITEM Description
......................................................................................................................................................

S_ITEM Description
Column Name Null? Datatype
--------------------------------------------------------------------------------------
ORD_ID NOT NULL NUMBER(7)
ITEM_ID NOT NULL NUMBER(7)
PRODUCT_ID NOT NULL NUMBER(7)
PRICE NUMBER(11,2)
QUANTITY NUMBER(9)
QUANTITY_SHIPPED NUMBER(9)

......................................................................................................................................................
Developer/2000: Build Reports B-13
Appendix B: Table Descriptions and Data
......................................................................................................................................................

S_ITEM Data
SQL> SELECT * FROM s_item;

ORD_ID ITEM_ID PRODUCT_ID PRICE QUANTITY QUANTITY_SHIPPED


------ ------- ---------- ----- -------- ----------------
100 1 10011 135 500 500
100 2 10013 380 400 400
100 3 10021 14 500 500
100 5 30326 582 600 600
100 7 41010 8 250 250
100 6 30433 20 450 450
100 4 10023 36 400 400
101 1 30421 16 15 15
101 3 41010 8 20 20
101 5 50169 4.29 40 40
101 6 50417 80 27 27
101 7 50530 45 50 50
101 4 41100 45 35 35
101 2 40422 50 30 30
102 1 20108 28 100 100
102 2 20201 123 45 45
103 1 30433 20 15 15
103 2 32779 7 11 11
104 1 20510 9 7 7
104 4 30421 16 35 35
104 2 20512 8 12 12
104 3 30321 1669 19 19
105 1 50273 22.8 16 16
105 3 50532 47 28 28
105 2 50419 80 13 13

Continued on Next Page

......................................................................................................................................................
B-14 Developer/2000: Build Reports
S_ITEM Data (continued)
......................................................................................................................................................

S_ITEM Data (continued)


ORD_ID ITEM_ID PRODUCT_ID PRICE QUANTITYQUANTITY_SHIPPED---
----------------------- ----- -------- ----------- ------------------
106 1 20108 28 46 46
106 4 50273 22.89 75 75
106 5 50418 75 98 98
106 6 50419 80 27 27
106 2 20201 123 21 21
106 3 50169 4.29 125 125
107 1 20106 11 50 50
107 3 20201 115 130 130
107 5 30421 16 55 55
107 4 30321 1669 75 75
107 2 20108 28 22 22
108 1 20510 9 9 9
108 6 41080 35 50 50
108 7 41100 45 42 42
108 5 32861 60 57 57
108 2 20512 8 18 18
108 4 32779 7 60 60
108 3 30321 1669 85 85
109 1 10011 140 150 150
109 5 30426 18.25 500 500
109 7 50418 75 43 43
109 6 32861 60 50 50
109 4 30326 582 1500 1500
109 2 10012 175 600 600
109 3 10022 21.95 300 300
110 1 50273 22.89 17 17
110 2 50536 50 23 23
111 1 40421 65 27 27
111 2 41080 35 29 29
97 1 20106 9 1000 1000
97 2 30321 1500 50 50
98 1 40421 85 7 7
99 1 20510 9 18 18
99 2 20512 8 25 25
99 3 50417 80 53 53
99 4 50530 45 69 69
112 1 20106 11 50 50

62 rows selected.

Note: The above display has been formatted.

......................................................................................................................................................
Developer/2000: Build Reports B-15
Appendix B: Table Descriptions and Data
......................................................................................................................................................

S_ORD Description and Data


Column Name Null? Datatype
--------------------------------------------------------------------------------------
ID NOT NULL NUMBER(7)
CUSTOMER_ID NOT NULL NUMBER(7)
DATE_ORDERED DATE
DATE_SHIPPED DATE
SALES_REP_ID NUMBER(7)
TOTAL NUMBER(11,2)
PAYMENT_TYPE VARCHAR2(6)
ORDER_FILLED VARCHAR2(1)

SQL> SELECT * FROM s_ord;

ID CUSTOMER_ID DATE_ORDE DATE_SHIP SALES_REP_ID TOTAL PAYMEN ORDER_F


--- ----------- --------- --------- ------------ ------- ------ -------
100 204 31-AUG92 10-SEP-92 11 601100 CREDIT Y
101 205 31-AUG-92 15-SEP-92 14 8056.6 CREDIT Y
102 206 01-SEP-92 08-SEP-92 15 8335 CREDIT Y
103 208 02-SEP-92 22-SEP-92 15 377 CASH Y
104 208 03-SEP-92 23-SEP-92 15 32430 CREDIT Y
105 209 04-SEP-92 18-SEP-92 11 2722.24 CREDIT Y
106 210 07-SEP-92 15-SEP-92 12 15634 CREDIT Y
107 211 07-SEP-92 21-SEP-92 15 142171 CREDIT Y
108 212 07-SEP-92 10-SEP-92 13 149570 CREDIT Y
109 213 08-SEP-92 28-SEP-92 11 1020935 CREDIT Y
110 214 09-SEP-92 21-SEP-92 11 1539.13 CASH Y
111 204 09-SEP-92 21-SEP-92 11 2770 CASH Y
97 201 28-AUG-92 17-SEP-92 12 84000 CREDIT Y
98 202 31-AUG-92 10-SEP-92 14 595 CASH Y
99 203 31-AUG-92 18-SEP-92 14 7707 CREDIT Y
112 210 31-AUG-92 10-SEP-92 12 550 CREDIT Y

16 rows selected.

......................................................................................................................................................
B-16 Developer/2000: Build Reports
S_PRODUCT Description
......................................................................................................................................................

S_PRODUCT Description
Column Name Null? Datatype
----------------------------------------- -------------------- -------------------------
ID NOT NULL NUMBER(7)
NAME NOT NULL VARCHAR2(50)
SHORT_DESC VARCHAR2(255)
LONGTEXT_ID NUMBER(7)
IMAGE_ID NUMBER(7)
SUGGESTED_WHLSL_PRICE‘ NUMBER(11,2)
WHLSL_UNITS VARCHAR2(25)

......................................................................................................................................................
Developer/2000: Build Reports B-17
Appendix B: Table Descriptions and Data
......................................................................................................................................................

S_PRODUCT Data
SQL> SELECT * FROM s_product;

ID NAME SHORT_DESC LONGTEXT_ID


---- --------------- --------------- -----------
IMAGE_ID SUGGESTED_WHLSL_PRICE WHLSL_UNITS
-------- --------------------- -----------
10011 Boot Beginner’s ski boot 518
1001 150

10012 Ace Ski Boot Intermediate ski boot 519


1002 200

10013 Pro Ski Boot Advanced ski boot 520


1003 410

10021 Bunny Ski Pole Beginner’s ski pole 528


1011 16.25

10022 Ace Ski Pole Intermediate ski pole 529


1012 21.95

10023 Pro Ski Pole Advanced ski pole 530


1013 40.95

20106 Junior Soccer BallJunior soccer ball613


11

20108 World Cup Soccer Ball World cup soccer ball615


28

20201 World Cup Net World cup net 708


123

Continued on Next Page

......................................................................................................................................................
B-18 Developer/2000: Build Reports
S_PRODUCT Data (continued)
......................................................................................................................................................

S_PRODUCT Data (continued)


ID NAME SHORT_DESC LONGTEXT_ID
---- --------------- --------------- -----------
IMAGE_ID SUGGESTED_WHLSL_PRICE WHLSL_UNITS
-------- --------------------- -----------
20510 Black Hawk Knee pads, pair 1017
Knee Pads 9
20512 Black Hawk Elbow pads, pair 1019
Elbow Pads 8
30321 Grand Prix Bicycle Road bicycle 828
1291 1669
30326 Himalaya Bicycle Mountain bicycle 833
1296 582
30421 Grand Prix Road bicycle tires 927
Bicycle Tires 16
30426 Himalaya Tires Mountain bicycle tires 933
18.25
30433 New Air Pump Tire pump 940
20
32779 Slaker Water Water bottle 1286
Bottle 7
32861 Safe-T Helmet Bicycle helmet 1368
1829 60
40421 Alexeyer Pro Straight bar 928
Lifting Bar
1381 65
40422 Pro Curling Bar Curling bar 929
1382 50

Continued on Next Page

......................................................................................................................................................
Developer/2000: Build Reports B-19
Appendix B: Table Descriptions and Data
......................................................................................................................................................

S_PRODUCT Data (continued)


ID NAME SHORT_DESC LONGTEXT_ID
---- --------------- --------------- -----------
IMAGE_ID SUGGESTED_WHLSL_PRICE WHLSL_UNITS
-------- --------------------- -----------
40421 Alexeyer Pro Straight bar 928
Lifting Bar
1381 65

40422 Pro Curling Bar Curling bar 929


1382 50

41010 Prostar 10 Ten pound weight 517


Pound Weight
8

41020 Prostar 20 Twenty pound weight 527


Pound Weight
12

41050 Prostar 50 Fifty pound weight 557


Pound Weight
25

41080 Prostar 80 Eighty pound weight 587


Pound Weight
35

41100 Prostar 100 One hundred pound 607


Pound Weight weight
45

50169 Major League Baseball 676


Baseball
1119 4.29

Continued on Next Page

......................................................................................................................................................
B-20 Developer/2000: Build Reports
S_PRODUCT Data (continued)
......................................................................................................................................................

S_PRODUCT Data (continued)


ID NAME SHORT_DESC LONGTEXT_ID
---- --------------- --------------- -----------
IMAGE_ID SUGGESTED_WHLSL_PRICE WHLSL_UNITS
-------- --------------------- -----------
50273 Chapman Helmet Batting helmet 780
1223 22.89

50417 Griffey Glove Outfielder’s glove 924


1367 80

50418 Alomar Glove Infielder’s glove 925


1368 75

50419 Steinbach Glove Catcher’s glove 926


1369 80

50530 Cabrera Bat Thirty inch bat 1037


1480 45

50532 Puckett Bat Thirty-two inch bat 1039


1482 47

50536 Winfield Bat Thirty-six inch bat 1043


1486 50

33 rows selected.

Note: The above display has been formatted.

......................................................................................................................................................
Developer/2000: Build Reports B-21
Appendix B: Table Descriptions and Data
......................................................................................................................................................

S_REGION Description and Data


Column Name Null? Datatype
----------------------------------------- -------------------- -------------------------
ID NOT NULL NUMBER(7)
NAME NOT NULL VARCHAR2(50)

SQL> SELECT * FROM s_region;

ID NAME
--- ---------------------------
1 North America
2 South America
3 Africa / Middle East
4 Asia
5 Europe

......................................................................................................................................................
B-22 Developer/2000: Build Reports
S_TITLE Description and Data
......................................................................................................................................................

S_TITLE Description and Data


Column Name Null? Datatype
--------------------------------------------------------------------------------------
TITLE NOT NULL VARCHAR2(25)

SQL> SELECT * FROM s_title;

TITLE
------------------------
President
Sales Representative
Stock Clerk
VP, Administration
VP, Finance
VP, Operations
VP, Sales
Warehouse Manager

8 rows selected.

......................................................................................................................................................
Developer/2000: Build Reports B-23
Appendix B: Table Descriptions and Data
......................................................................................................................................................

......................................................................................................................................................
B-24 Developer/2000: Build Reports
C
................................

Frequently Asked
Questions
Appendix C: Frequently Asked Questions
......................................................................................................................................................

Frequently Asked Questions


Contents
1 How do I set up and run my reports on a remote server?
2 How can the Report Builder Background Engine be shut down
programmatically from another Developer/2000 application?
3 How do I pass parameters with spaces from command line or from the
Form Builder built-ins RUN_REPORT_OBJECT or RUN_PRODUCT?
4 How do I print a report to an ASCII file with no page breaks or control
characters?
5 How do I create a report containing barcodes in Report Builder?
6 How do I print a character mode report in landscape orientation?
7 How do I send report output to a FAX?
8 How do I suppress rows or columns in a Matrix report?
9 How can I print to the second printer tray using Report Builder?
10 What Registry parameter is used on Windows to redirect where
temporary files are created?
11 How do I automatically delete temporary files created when running
Report Builder?
12 Is there any way to programmatically disable the PRINT button in the
runtime Previewer?

......................................................................................................................................................
C-2 Developer/2000: Build Reports
Frequently Asked Questions and Answers
......................................................................................................................................................

Frequently Asked Questions and Answers


Accessing Reference Material
The reference numbers quoted in these answers are the index numbers that
enable you to search for a document within Metalink if you are a member of
the Oracle Metals Program, that is, support levels Bronze, Silver, or Gold. If
you do not currently have one of these metal support services, you can call
your sales representative to upgrade your support service level.
You can use these numbers for an exact match, or you can search on full
words pertaining to the problem you are having, such as BOILERPLATE.
From http://support.oracle.com/metalink choose the TOOLS option and then
Developer 2000/reports. From there choose Top Product Articles and enter
the text for your search. Click the Advanced button, and choose ConText
Syntax before starting the search.
Oracle allows access to published bulletins only from Metalink. If you do
not find the topic you need, call the support center for help. Material is
constantly being added to this site in an effort to give customers fast access
to the information they need.
Note: These documents can also be obtained by calling the customer
support hotline.

1. How do I set up and run my reports on a remote server?

Answer
The Multitiered Reports Server, which is part of Developer/2000 Release 2,
enables you to run reports on a remote, application server. When used in
conjunction with the Reports Web CGI or Web Cartridge, it also enables you
to run reports from a Web browser using standard URL syntax. The server
can be installed on Windows NT, Windows95, or Unix. It handles client
requests to run reports by entering all requests into a job queue.

For further information:


Oracle Developer/2000 R2.0 Documentation: Online Manuals
Developer/2000: Guidelines for Building Applications
2: Deploying Applications on the Web
2.2.3: Configuring Reports for the Web
2.2.3.1: Setting up the Reports Server (r30mtsus.htm)

......................................................................................................................................................
Developer/2000: Build Reports C-3
Appendix C: Frequently Asked Questions
......................................................................................................................................................

2.How can the Report Builder Background Engine be shut down


programmatically from another Developer/2000 application?

Answer
In your Form application, use ORACLE_SHUTDOWN = Yes as a
parameter in a parameter list that you pass to the Form Builder built-in,
RUN_PRODUCT.
The parameter value, Yes, must be in initial capitals.

References
<PrSol:2067466.6>

3.How do I pass parameters with spaces from command line or from the
Form Builder built-ins RUN_REPORT_OBJECT or RUN_PRODUCT?

Answer
• Use a CMDFILE for passing parameters with spaces from command
line.
• Use extra quotes to delimit values to pass parameter values with spaces
when using RUN_REPORT_OBJECT or RUN_PRODUCT.

References
<PrSol:2056652.6>

4.How do I print a report to an ASCII file with no page breaks or control


characters?

Answer
Remove "CONTROL(L)" from "AFTER PAGE{S} CONTROL(L)" line in
dflt.prt or use DESFORMAT=no_ff (no_ff.prt printer definition file is
supplied as part of the Report Builder installation, in
<oracle_home>\report30\printers directory)

References
<PrSol:2058834.6>

......................................................................................................................................................
C-4 Developer/2000: Build Reports
Frequently Asked Questions and Answers
......................................................................................................................................................

5. How do I create a report containing barcodes in Report Builder?

Answer
On Windows, use the barcode font supplied as part of the Report Builder
installation, in <oracle_home>\tools\devdem20\bin directory, or any
third- party barcode font.
Alternatively, you can use Developer/2000 Graphics Builder.

References
<PrSol:2059321.6>

6. How do I print a character mode report in landscape orientation?

Answer
Manually edit escape sequences into a .prt file.

References
<Note:34318.1> Landscape Printing in Reports on Windows

7. How do I send report output to a FAX?

Answer
Install a third-party software, for example Winfax, and make that a printer.
In order to programmatically fax a report without any user interaction
through Microsoft Exchange Fax driver, look up bulletin BUL 13000147.6
(CR 159472).

References
<PrSol:2083424.6>

......................................................................................................................................................
Developer/2000: Build Reports C-5
Appendix C: Frequently Asked Questions
......................................................................................................................................................

8. How do I suppress blank rows or columns in a Matrix report?

Answer
In Release 2.0 or earlier, create a summary column in the cross product
group to count the number of cells that hold a NOT NULL value. Use a
format trigger to suppress the row or column if this value is zero.
In Release 2.1, a nested matrix style creates a ënon-sparseí matrix by
default, which means it suppresses all blank rows or columns.

References
<PrSol:2065884.6>

9. How can I print to the second printer tray using Report Builder?

Answer
Use a Before Report, Between Pages, or other format trigger to switch to
different printer trays as your report formats. You can determine the names
of the printer trays defined for your printer in the Page Setup dialog.
In Release 2.0, use SRW.SET_ATTR (PRINTER_INTRAY attribute) to set
printer tray as desired.
In Release 2.1, use SRW.SET_PRINTER_TRAY, which provides easier
syntax similar to Form Builder.

References
<PrSol:2063840.4>
<Note:40507.1>

......................................................................................................................................................
C-6 Developer/2000: Build Reports
Frequently Asked Questions and Answers
......................................................................................................................................................

10.What Registry parameter is used on Windows to redirect where


temporary files are created?

Answer
Report Builder uses REPORTS30_TMP parameter in the Registry. If this is
not set then it uses the working directory instead.

11.How do I automatically delete temporary files created when running


reports using Reports Runtime?

Answer
Running a report to a file from the runtime module does not delete the idx
files. The idx files must be deleted manually. This is a documented bug.

References
<BUG:332572>

12.Is there any way to programmatically disable the PRINT button in the
runtime Previewer?

Answer
Yes, but only from Release 2.1 onwards. Include the DISABLEPRINT=YES
argument in your command line. Release 2.1 also provides a
DISABLEMAIL argument.

......................................................................................................................................................
Developer/2000: Build Reports C-7
Appendix C: Frequently Asked Questions
......................................................................................................................................................

......................................................................................................................................................
C-8 Developer/2000: Build Reports
D
................................

Oracle Rdb Overview


Appendix D: Oracle Rdb Overview
......................................................................................................................................................

What Is Oracle Rdb?


Oracle Rdb is a multiuser relational database management system designed
for high availability, high performance, and ease of use. It supports a full set
of utilities and an industry-standard data definition and manipulation
language that lets you create, query, and maintain your Oracle Rdb
databases.
Oracle Rdb is currently running on over 45 thousand servers at more than 15
thousand sites worldwide. It is used in many large online transaction
processing (OLTP) systems and its customer list comprises some of the
world’s leading corporations. Oracle continues to enhance the functionality
of Oracle Rdb by adding new features and making Oracle technology and
tools work with Rdb.

Supported Platforms
Oracle Rdb is available on the following computing platforms:
• Digital OpenVMS VAX
• Digital OpenVMS Alpha
• Digital UNIX
• Microsoft Windows NT on Digital Alpha
• Microsoft Windows NT on Intel

......................................................................................................................................................
D-2 Developer/2000: Build Reports
Oracle Rdb Features
......................................................................................................................................................

Oracle Rdb Features


These are some of the features that Oracle Rdb offers:
• Industry standard SQL interface
- This includes interactive SQL for prototyping queries and data
definition as well as SQL module language and SQL precompilers
for many programming languages. Oracle Rdb SQL also supports
multistatement SQL stored procedures, user-defined functions, and
many other features.
• Database maintenance and diagnostic tools
- The Oracle Rdb management utility (RMU) provides a full set of
tools for the database administrator to use to perform database
maintenance tasks and monitor and display information about the
database.
• Multiversion support
- Oracle Rdb will support multiple software versions simultaneously
on the same system. This enables developers to test new applications
without disturbing the production environment.
• Data security
- Access to the database and individual database objects can be limited
to authorized users only. Role-oriented privileges can be placed on
maintenance functions and database events can be audited.
• Data consistency
- Data definitions can be stored in the database instead of application
programs. Views can be used to manage data stored in multiple
tables. Constraints and triggers can be used to ensure that changed
data remains consistent throughout the database. Journal files ensure
that incomplete transactions and database recoveries preserve the
original data.
• VLDB and record partitioning
- Oracle Rdb can cache large amounts of data in memory for fast
access and data records can be partitioned across storage areas and
disks.
• Optional hot standby
- This option provides a transaction-consistent standby system for use
in the event of a catastrophic failure.

......................................................................................................................................................
Developer/2000: Build Reports D-3
Appendix D: Oracle Rdb Overview
......................................................................................................................................................

Standard User Interfaces


Oracle and Oracle Rdb users can use the same applications development
tools, system, and network management environment, and can share data
across Rdb and Oracle7 databases.
• The SQL*Net for Rdb transport allows applications using the Oracle
Call Interface (OCI) or software such as PL/SQL or Developer/2000 to
access and manage data in an Oracle Rdb database.
• Applications can also use the ODBC interface to access both Oracle and
Oracle Rdb databases.
• Internet and intranet applications using the Rdb Web Cartridge can be
delivered to the user through the Oracle WebServer.
• The Oracle Enterprise Manager can be used to manage both Oracle and
Oracle Rdb databases.
• Oracle Trace and Oracle Expert can be used for diagnosis and tuning of
both Oracle and Oracle Rdb databases.
• Oracle Express Server can query Oracle Rdb databases and load Rdb
data into the Express Server engine for present or future online
analytical processing (OLAP).

......................................................................................................................................................
D-4 Developer/2000: Build Reports
Other Information
......................................................................................................................................................

Other Information
Oracle Rdb Education
Oracle Education offers a comprehensive series of Oracle Rdb courses. The
course titles are:
• Introduction to Oracle Rdb: Technical Overview and SQL Language
• Oracle Rdb for the Database Administrator
• Oracle Rdb for the Database Designer
• Oracle Rdb 3GL Programming
• Oracle Rdb Performance and Tuning
• Oracle Rdb Internals
To receive the Oracle Rdb education schedule and catalogue, which contains
complete course descriptions, pricing and enrollment information, call
1.800.633.0575 within the continental US or 650.506.6800 from outside the
US.

Oracle Rdb Product Information and Demonstration CD-ROM


To receive an Oracle Rdb product information and demonstration CD-ROM,
send e-mail with your name, address, and company name to:
• infordb@us.oracle.com
Specify that you’d like to receive the Oracle Rdb CD-ROM.

Oracle Rdb Web site


The Oracle Rdb Web site is a resource for finding out the latest news on the
product and its features. Look here for information such as:
• New product release information
• Product interoperability information
• Feature descriptions
• Calendar of product-related events
To access the Web site, go to the following address:
• http://www.oracle.com/rdb

......................................................................................................................................................
Developer/2000: Build Reports D-5
Appendix D: Oracle Rdb Overview
......................................................................................................................................................

......................................................................................................................................................
D-6 Developer/2000: Build Reports

Das könnte Ihnen auch gefallen