Professional Documents
Culture Documents
Reports
43212GC10
Production 1.0
April 1999
M08693
Authors Copyright Oracle Corporation, 1999. All rights reserved.
Technical Reviewers
Restricted Rights Legend
Gunnar Boehrs Use, duplication or disclosure by the Government is subject to restrictions for
Jackie Bruce 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
Ruth Delaney 252.227-7013, Rights in Technical Data and Computer Software (October 1988).
Laurent Dereac
This material or any portion of it may not be copied in any form or by any means
Astrid Dietrich without the express prior written permission of Oracle Corporation. Any other
Brian Fry copying is a violation of copyright law and may result in civil and/or criminal
penalties.
Mary Lee
Stella Misiulis If this documentation is delivered to a U.S. Government Agency not within the
Department of Defense, then it is delivered with “Restricted Rights,” as defined in
Paul Narth FAR 52.227-14, Rights in Data-General, including Alternate III (June 1987).
Sergiy Pechersky
The information in this document is subject to change without notice. If you find
Raza Siddiqui any problems in the documentation, please report them in writing to Education
John Walsh Products, Oracle Corporation, 500 Oracle Parkway, Box SB-6, Redwood Shores,
CA 94065. Oracle Corporation does not warrant that this document is error-free.
Preface
Profile xv
Related Publications xvi
Typographic Conventions xvii
Introduction
Overview I-3
Course Objectives I-5
Course Content I-7
.....................................................................................................................................................
Oracle Developer: Build Reports iii
Contents
.....................................................................................................................................................
.....................................................................................................................................................
iv Oracle Developer: Build Reports
Contents
.....................................................................................................................................................
.....................................................................................................................................................
Oracle Developer: Build Reports v
Contents
.....................................................................................................................................................
.....................................................................................................................................................
vi Oracle Developer: Build Reports
Contents
.....................................................................................................................................................
.....................................................................................................................................................
Oracle Developer: Build Reports vii
Contents
.....................................................................................................................................................
.....................................................................................................................................................
viii Oracle Developer: Build Reports
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-14
Practice Session Solutions: Lesson 3 A-15
Practice Session Overview: Lesson 4 A-18
Practice Session Solutions: Lesson 4 A-19
Practice Session Overview: Lesson 5 A-24
Practice Session Solutions: Lesson 5 A-25
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-44
Practice Session Solutions: Lesson 9 A-45
Practice Session Overview: Lesson 10 A-51
Practice Session Solutions: Lesson 10 A-52
Practice Session Overview: Lesson 11 A-57
Practice Session Solutions: Lesson 11 A-58
Practice Session Overview: Lesson 12 A-61
Practice Session Solutions: Lesson 12 A-62
.....................................................................................................................................................
Oracle Developer: Build Reports ix
Contents
.....................................................................................................................................................
.....................................................................................................................................................
x Oracle Developer: Build Reports
Contents
.....................................................................................................................................................
.....................................................................................................................................................
Oracle Developer: Build Reports xi
Contents
.....................................................................................................................................................
.....................................................................................................................................................
xii Oracle Developer: Build Reports
14
................................
Objectives
......................................................................................................................................................
14-2 Oracle Developer: Build Reports
Overview
......................................................................................................................................................
Overview
Introduction
Matrix or cross product reports show cells of information that relate to values
appearing across the top and down the left side of the report.
In an earlier lesson you created a matrix report 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 do the following:
• 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
......................................................................................................................................................
Oracle Developer: Build Reports 14-3
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................
1 4
5
3
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
14-4 Oracle Developer: Build Reports
The Matrix Data Model
......................................................................................................................................................
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.
......................................................................................................................................................
Oracle Developer: Build Reports 14-5
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................
1 2 3 4
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
14-6 Oracle Developer: Build Reports
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 covered so far.
This section explains the objects by showing an expanded layout where each outer
object is slightly larger than its contents.
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.
......................................................................................................................................................
Oracle Developer: Build Reports 14-7
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................
3
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
14-8 Oracle Developer: Build Reports
Creating Matrix Summaries
......................................................................................................................................................
The Reset At option has the same effect as in other report styles. When you create
summaries with the wizard, each summary resets for each occurrence of the group. For
example, the department summary resets for each department. If you want the
summary values to accumulate throughout the report, change Reset At to a higher
level, such as Report.
......................................................................................................................................................
Oracle Developer: Build Reports 14-9
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................
......................................................................................................................................................
14-10 Oracle Developer: Build Reports
Building a Nested Matrix
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 14-11
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................
......................................................................................................................................................
14-12 Oracle Developer: Build Reports
Building a Nested Matrix
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 14-13
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................
F_SumSALARY F_SumSALPerDEPT
F_Sum_REG_NAME
F_SumSALPerTITLE
......................................................................................................................................................
14-14 Oracle Developer: Build Reports
Building a Nested Matrix
......................................................................................................................................................
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 following table shows the property settings.
......................................................................................................................................................
Oracle Developer: Build Reports 14-15
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................
Displaying Zeros
......................................................................................................................................................
14-16 Oracle Developer: Build Reports
Building a Nested Matrix
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 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
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
14-18 Oracle Developer: Build Reports
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.
......................................................................................................................................................
Oracle Developer: Build Reports 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-20 Oracle Developer: Build Reports
Practice Session Overview: Lesson 14
......................................................................................................................................................
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.
......................................................................................................................................................
Oracle Developer: Build Reports 14-21
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................
......................................................................................................................................................
14-22 Oracle Developer: Build Reports
Practice Session: Lesson 14
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 14-23
Lesson 14: Enhancing Matrix Reports
......................................................................................................................................................
......................................................................................................................................................
14-24 Oracle Developer: Build Reports
15
................................
Objectives
......................................................................................................................................................
15-2 Oracle Developer: Build Reports
Overview
......................................................................................................................................................
Overview
Introduction
This lesson identifies different trigger types and creates conditional trigger code to
control report output. It also explains how to improve productivity and maintenance
by sharing and reusing commonly referenced code.
Objectives
At the end of this lesson, you should be able to do the following:
• Describe the different types of triggers
• Describe sample uses of the different types of triggers
• Write and reference common code
• Create and reference a PL/SQL library
......................................................................................................................................................
Oracle Developer: Build Reports 15-3
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................
Trigger Code
Parameter
Boolean:
boolean
true
false
Column
Character
Number
Number
Date
......................................................................................................................................................
15-4 Oracle Developer: Build Reports
Types of Triggers in Reports
......................................................................................................................................................
Trigger Code
When you create a trigger such as a report trigger or a PL/SQL formula, the
Program Unit editor supplies a template for the function block, giving the basic
syntax that you require.
You can change the name of the function.
The value that you return must match the return datatype in the function declaration.
......................................................................................................................................................
Oracle Developer: Build Reports 15-5
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................
1 2 if readonly=yes 3
F
if > 1 page
After Between After
Before page1 page2
Parameter Pages Report
Report
Form
F F
......................................................................................................................................................
15-6 Oracle Developer: Build Reports
Using Report Triggers
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 15-7
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................
• Query syntax:
SELECT
SELECT ID,
ID, NAME
NAME
FROM
FROM CUSTOMER
CUSTOMER
&p_where_clause
ORDER
ORDER BY
BY NAME
NAME
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
15-8 Oracle Developer: Build Reports
Using Report Triggers
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 15-9
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................
......................................................................................................................................................
15-10 Oracle Developer: Build Reports
Using Data Model Triggers
......................................................................................................................................................
Example
Use a group filter that calls a function for some records in the G_emp group,
depending on the department in the master group.
1 Open the property palette for the G_emp group.
2 Change Group Filter to PL/SQL.
The PL/SQL Filter property appears.
3 Choose 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. You
cannot use a WHERE clause in this case, because you want to process all records
and call the function for some.
......................................................................................................................................................
Oracle Developer: Build Reports 15-11
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................
......................................................................................................................................................
15-12 Oracle Developer: Build Reports
Using Data Model Triggers
......................................................................................................................................................
Example To prevent report output from being sent directly to a printer, test the
value of the DESTYPE system parameter.
1 Open the property palette for the DESTYPE parameter.
2 Choose Validation Trigger to open the PL/SQL editor.
3 Enter the code and make sure that the value Printer has an initial capital.
......................................................................................................................................................
Oracle Developer: Build Reports 15-13
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................
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-14 Oracle Developer: Build Reports
Using Layout Model Triggers
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 15-15
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................
......................................................................................................................................................
15-16 Oracle Developer: Build Reports
Using Layout Model Triggers
......................................................................................................................................................
Example
1 Create a summary column, :count_emp, in the master group that counts the
number of employee records (reset = master group).
2 Create a piece of boilerplate text, “No employees in this department”.
3 Position the text behind the column heading frame.
4 Code a format trigger on the column heading:
function hide_headings return boolean is
begin
if :count_emp = 0 then
return(false);
else
return(true);
end if;
end;
5 Either code the reverse logic in the format trigger of the boilerplate text item
created in step 2 or ensure that the column heading frame has a solid fill.
Note: You should code format triggers at the highest possible level of the 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.
......................................................................................................................................................
Oracle Developer: Build Reports 15-17
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................
1 3
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
15-18 Oracle Developer: Build Reports
Using Layout Model Triggers
......................................................................................................................................................
Example
1 In the layout, create two repeating frames sourced by the same group. One
repeating frame must contain a salary field, the other must not.
Note: You can create two separate default layouts and modify the layout as
required.
2 Place one repeating frame behind the other.
3 Add a format trigger to suppress the top repeating frame (the one that contains
the salary field), or alternatively use conditional formating:
function pay_clerks_see_this return boolean is
begin
if :user_type = ’PAY_CLERK’ then
return(true);
else
return(false);
end if;
end;
Note: User_type can be a column or parameter that is initialized at run time.
4 Either code the reverse logic on the other repeating frame or ensure that the top
repeating frame (containing salary) has a solid fill.
......................................................................................................................................................
Oracle Developer: Build Reports 15-19
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................
Employee Details
Employee Details
Ngao 08-MAR-90
Biri 07-APR-91
Magee14-MAY-90
2
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
15-20 Oracle Developer: Build Reports
Using Layout Model Triggers
......................................................................................................................................................
Example Place the format trigger on the salary field to display it only when
payment clerks run the report. The code is the same as before:
function pay_clerks_see_this return boolean is
begin
if :user_type = ’PAY_CLERK’ then
return(true);
else
return(false);
end if;
end;
In this example you do not need to create any additional layout object or code.
......................................................................................................................................................
Oracle Developer: Build Reports 15-21
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................
......................................................................................................................................................
15-22 Oracle Developer: Build Reports
Using Layout Model Triggers
......................................................................................................................................................
Example
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.
......................................................................................................................................................
Oracle Developer: Build Reports 15-23
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................
1 2
3 4
FUNCTION
FUNCTION spacing
spacing RETURN
RETURN BOOLEAN
BOOLEAN IS
IS
BEGIN
BEGIN
IF
IF MOD(:count_column,
MOD(:count_column, 3)
3) == 00 THEN
THEN
RETURN(TRUE);
RETURN(TRUE);
ELSE
ELSE
RETURN(FALSE);
RETURN(FALSE);
END
END IF;
IF;
END;
END;
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
15-24 Oracle Developer: Build Reports
Using Layout Model Triggers
......................................................................................................................................................
Example
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.
......................................................................................................................................................
Oracle Developer: Build Reports 15-25
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................
......................................................................................................................................................
15-26 Oracle Developer: Build Reports
Writing Common Code
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 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
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
15-28 Oracle Developer: Build Reports
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 and how they are
processed.
Layout triggers affect the way in which objects are formatted.
......................................................................................................................................................
Oracle Developer: Build Reports 15-29
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................
Practice 15 Overview
......................................................................................................................................................
15-30 Oracle Developer: Build Reports
Practice Session Overview: Lesson 15
......................................................................................................................................................
Introduction
In this practice session you create a format trigger, or use conditional formatting 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.
......................................................................................................................................................
Oracle Developer: Build Reports 15-31
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................
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 Make sure that only the Group Above layout is displayed when you
choose a destination of Screen, and only the Tabular layout is
displayed when you choose a destination of Preview.
To test the result, display the DESTYPE parameter in the report.
Make sure that you can enter a parameter value at run time.
Hint: As an alternative to coding Format triggers, you can also use
Conditional Formatting.
e Save the report as p15q1.rdf.
......................................................................................................................................................
15-32 Oracle Developer: Build Reports
Practice Session: Lesson 15
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 15-33
Lesson 15: Coding PL/SQL Triggers in Reports
......................................................................................................................................................
......................................................................................................................................................
15-34 Oracle Developer: Build Reports
16
................................
Objectives
......................................................................................................................................................
16-2 Oracle Developer: Build Reports
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 do the following:
• 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
......................................................................................................................................................
Oracle Developer: Build Reports 16-3
Lesson 16: Using the Report Builder Built-In 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-4 Oracle Developer: Build Reports
Contents of the Report Builder Built-in Package
......................................................................................................................................................
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.
......................................................................................................................................................
Oracle Developer: Build Reports 16-5
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................
Outputting Messages
Warning
WHEN
WHEN <exception>
<exception> THEN
THEN
SRW.MESSAGE(999,
SRW.MESSAGE(999,
’Warning:
’Warning: report
report continues’);
continues’);
Error
WHEN
WHEN <exception>
<exception> THEN
THEN
SRW.MESSAGE(999,
SRW.MESSAGE(999,
’Error:
’Error: report
report terminated’);
terminated’);
RAISE SRW.PROGRAM_ABORT;
Exceptions
SRW.INTEGER_ERROR
SRW.INTEGER_ERROR
SRW.NULL_ARGUMENTS
SRW.NULL_ARGUMENTS
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
16-6 Oracle Developer: Build Reports
Outputting Messages
......................................................................................................................................................
Outputting Messages
Introduction
The SRW.MESSAGE packaged procedure displays a message with a code and text
string, which you specify. The message is displayed in the following format:
MSG-code: text
The message is displayed in a small dialog box. The user must acknowledge the
message before continuing.
Is It a Warning or an Error?
SRW.MESSAGE does not implicitly terminate the report execution. You can choose
to issue a warning message that enables the report to continue execution after the
user accepts the message.
To force the report to terminate after outputting the message, raise the exception
SRW.PROGRAM_ABORT.
Note: You cannot suppress or replace the default message that 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.
......................................................................................................................................................
Oracle Developer: Build Reports 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.LIS
zzz zzzzzzz
SRW.RUN_REPORT zzz zzzzzzz
......................................................................................................................................................
16-8 Oracle Developer: Build Reports
Executing a Nested Report
......................................................................................................................................................
Example
Run a report called MANAGERS that retrieves the employee record for each
manager. Call the EMPS report (for example, from a group filter). EMPS retrieves
the employee records of all employees managed by the current manager only.
Sample code to implement this example appears on the following page.
......................................................................................................................................................
Oracle Developer: Build Reports 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_FAILURE
SRW.RUN_REPORT_BATCHNO
SRW.RUN_REPORT_BATCHNO
Function
SRW.GETERR_RUN
SRW.GETERR_RUN
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
16-10 Oracle Developer: Build Reports
Executing a Nested Report
......................................................................................................................................................
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.
......................................................................................................................................................
Oracle Developer: Build Reports 16-11
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................
41 Details 42
xxxxxxxxx
42 Details
SRW.RUN_REPORT xxxxxxxxx
xxxxxxxxx
43 Details
xxxxxxxxx
......................................................................................................................................................
16-12 Oracle Developer: Build Reports
Executing a Nested Report
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 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-14 Oracle Developer: Build Reports
Restricting Data
......................................................................................................................................................
Restricting Data
Introduction
Use SRW.SET_MAXROW to restrict the maximum number of records you want to
retrieve for a specified query. 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 run-time parameter called HOW_MANY:
FUNCTION FETCHIT RETURN BOOLEAN IS
BEGIN
IF :HOW_MANY >= 1 THEN
SRW.SET_MAXROW (’Q_emp’, :how_many);
ELSE
SRW.SET_MAXROW(’Q_emp’, 0);
END IF;
RETURN(TRUE);
EXCEPTION
WHEN SRW.MAXROW_UNSET THEN
SRW.MESSAGE (100,
’Data was fetched before SRW.MAXROW was called’);
RAISE SRW.PROGRAM_ABORT;
WHEN SRW.MAXROW_INERR THEN
SRW.MESSAGE(200, ’Contact someone clever!’);
RAISE SRW.PROGRAM_ABORT;
END;
You must set SRW.SET_MAXROW in the Before Report trigger; that is, after the
query has been parsed but before it has been executed. If you call it after the Before
Report trigger, 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.
......................................................................................................................................................
Oracle Developer: Build Reports 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
FUNCTION F_LOGICAL_PAGEFormatTrigger
F_LOGICAL_PAGEFormatTrigger
RETURN
RETURN BOOLEAN
BOOLEAN IS
IS
my_page
my_page number;
number;
BEGIN
BEGIN
SRW.GET_PAGE_NUM(my_page);
SRW.GET_PAGE_NUM(my_page); 2
SRW.SET_FIELD_NUM(0,my_page+3);
SRW.SET_FIELD_NUM(0,my_page+3);
RETURN(TRUE);
RETURN(TRUE);
END;
END;
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
16-16 Oracle Developer: Build Reports
Initializing Fields
......................................................................................................................................................
Initializing Fields
You can dynamically initialize the value in a layout field by using the relevant
SET_FIELD packaged procedure; for example:
• SRW.SET_FIELD_CHAR (0, ’a text string’)
• SRW.SET_FIELD_NUM (0, 1234)
• SRW.SET_FIELD_DATE (0, ’01-JAN-95’)
The first argument is always 0 (zero); you can set the value of the current object.
These procedures are relevant only in the format trigger of a field of the correct
type. If you use a procedure that conflicts with the field type, it has no effect in the
report; Report Builder ignores the code and does not raise an error.
Example Create a function to display the logical page number + 3 in a field called
F_NEWPAGE.
Because the logical page number variable is available only in the report layout, not
in the Data Model, you cannot calculate the value in a data column. Therefore you
use a layout field to get the current page number and output a new number by
initializing the same field.
Make use of a packaged procedure called SRW.GET_PAGE_NUM to retrieve the
current logical page number into a local PL/SQL variable, as in the format trigger
code opposite.
......................................................................................................................................................
Oracle Developer: Build Reports 16-17
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................
Exception
SRW.DO_SQL_FAILURE
SRW.DO_SQL_FAILURE
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
16-18 Oracle Developer: Build Reports
Performing DDL Statements
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 16-19
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................
......................................................................................................................................................
16-20 Oracle Developer: Build Reports
Setting Format Attributes
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 16-21
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................
Visual attributes
SRW.SET_FILL_PATTERN(’solid’);
SRW.SET_BORDER_WIDTH(250);
SRW.SET_FORMAT_MASK(’Day, Month yyyy’);
Define a bookmark
SRW.SET_BOOKMARK(’Car
SRW.SET_BOOKMARK(’Car Policy’);
Policy’);
......................................................................................................................................................
16-22 Oracle Developer: Build Reports
Setting Format Attributes
......................................................................................................................................................
Example
Conditionally set the following attributes if salary equals 2000:
Attribute Value
Background fill color Dark yellow
Fill pattern Sandpaper
Font style Italic
Font face Helvetica
Font weight Extra bold
Text color Dark blue
FUNCTION SAL_MASK RETURN BOOLEAN IS
BEGIN
IF :SALARY > 2000 THEN
SRW.SET_BACKGROUND_FILL_COLOR(‘darkyellow’);
SRW.SET_FILL_PATTERN(‘sandpaper’);
SRW.SET_FONT_STYLE(SRW.ITALIC_STYLE);
SRW.SET_FONT_FACE(‘helvetica’);
SRW.SET_FONT_WEIGHT(SRW.EXTRABOLD_WEIGHT);
SRW.SET_TEXT_COLOR(‘darkblue’);
END IF;
RETURN(TRUE);
END;
......................................................................................................................................................
Oracle Developer: Build Reports 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
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
16-24 Oracle Developer: Build Reports
Summary
......................................................................................................................................................
Summary
• The SRW package contains procedures, functions, and exceptions.
Remember that you can raise the exception SRW.PROGRAM_ABORT in your
PL/SQL code to stop report processing at any time.
• The SRW package provides a number of features, including:
- 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 formatting and display using SRW.SET<attr> attributes
......................................................................................................................................................
Oracle Developer: Build Reports 16-25
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................
Practice 16 Overview
......................................................................................................................................................
16-26 Oracle Developer: Build Reports
Practice Session Overview: Lesson 16
......................................................................................................................................................
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.
......................................................................................................................................................
Oracle Developer: Build Reports 16-27
Lesson 16: Using the Report Builder Built-In Package
......................................................................................................................................................
......................................................................................................................................................
16-28 Oracle Developer: Build Reports
Practice Session: Lesson 16
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 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 Oracle Developer: Build Reports
17
................................
Maximizing Performance
Using the Reports Server
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
Objectives
......................................................................................................................................................
17-2 Oracle Developer: Build Reports
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 do the following:
• 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
......................................................................................................................................................
Oracle Developer: Build Reports 17-3
Lesson 17: Maximizing Performance Using the Reports 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
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
17-4 Oracle Developer: Build Reports
Why Use a Remote Server?
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 17-5
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
reports
DB DB
• Enhances scalability
and performance Oracle Developer
Release 6
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
17-6 Oracle Developer: Build Reports
Why Use a Remote Server?
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 17-7
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
Application server
(Unix/NT) RWMTS60
DB
server DB DB
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
17-8 Oracle Developer: Build Reports
Reports Server Architecture and Configuration
......................................................................................................................................................
Client Tier The client tier is a front-end machine that sends commands to the
remote Reports Server.
• Invoke the executable RWCLI60 to schedule a report from the command line.
• Invoke the Queue Manager (RWRQM60) 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 run-time 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 run-time engine can connect to different
database aliases for each report run.
......................................................................................................................................................
Oracle Developer: Build Reports 17-9
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
Multi Tiered
Server Multi Tiered
Server
Engine Engine
Engine Engine
Engine Engine
Engine Multi Tiered Engine
Server
Engine Engine
Engine
Engine
......................................................................................................................................................
17-10 Oracle Developer: Build Reports
Reports Server Clustering
......................................................................................................................................................
Optimizing Resources
The master server performs duplicate job and tolerance checks before a job is
allocated. If it receives a duplicate request within a defined time period, the job is
serviced from the cache rather than by re-executing it.
Running a Report
In a Report Server Cluster you run a report by specifying server=master_name in
the command line for the client executable. The master server then assigns
incoming jobs to the engines on the slave servers.
......................................................................................................................................................
Oracle Developer: Build Reports 17-11
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
......................................................................................................................................................
17-12 Oracle Developer: Build Reports
Reports Server Clustering
......................................................................................................................................................
Example
1 Invoke the command line. In Windows NT, Choose Start—>Run.
2 Enter the command string, for example:
RWCLI60.EXE SERVER=masterserver REPORT=my_rep.rdf DESTYPE=FILE
This command sends the report to the remote master server, and the report runs
immediately.
......................................................................................................................................................
Oracle Developer: Build Reports 17-13
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
RWCLI60...
SCHEDULE=monthly_last_weekday_from_17:00_Oct_23,_1999_
retry_3_after_1_hour
TIME
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
17-14 Oracle Developer: Build Reports
Reports Server Clustering
......................................................................................................................................................
Syntax
The full syntax of the SCHEDULE parameter is: [SCHEDULE=] string
where the string is: [FREQ from] TIME [retry {n} + after LEN]
FREQ = hourly|daily|weekly|monthly|{every LEN|DAYREPEAT}|{last {WEEKDAYS|
weekday | weekend} before {n}+}
TIME = CLOCK [DATE] [INCR]
CLOCK = <hh:mm>
DATE=<calendar date>
INCR = {+LEN} | {next SUFFIX}
LEN = {n} * SUFFIX
SUFFIX = <time, date, FREQ>
Example
SCHEDULE=hourly_from_09:00am_May_01,_1999
SCHEDULE=last_weekday_from_17:00_Oct_23,_1999_retry_3_after_1_hour
Note: This syntax is necessary only if you want to control your report jobs from the
command line. You can also specify the scheduled time and frequency of a report
when you define a new job in the easy-to-use Queue Manager screen, which we use
later in this course.
......................................................................................................................................................
Oracle Developer: Build Reports 17-15
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
Reports Caching
......................................................................................................................................................
17-16 Oracle Developer: Build Reports
Reports Server Clustering
......................................................................................................................................................
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>\report60\server\cache.
......................................................................................................................................................
Oracle Developer: Build Reports 17-17
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
......................................................................................................................................................
17-18 Oracle Developer: Build Reports
Reports Server Clustering
......................................................................................................................................................
Parameter Description
NAME A server name that exists in TNSNAMES.ORA file
INITENGINE Number of run-time 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)
......................................................................................................................................................
Oracle Developer: Build Reports 17-19
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
......................................................................................................................................................
17-20 Oracle Developer: Build Reports
Reports Server Clustering
......................................................................................................................................................
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
......................................................................................................................................................
Oracle Developer: Build Reports 17-21
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
clusterconfig=“(server=nt-2
minengine=0
maxengine=2
initengine=2
cachedir=“H:\Cache”)
(server=sun-1
minengine=0
maxengine=2
initengine=2
cachedir=“/share/Cache”)”
......................................................................................................................................................
17-22 Oracle Developer: Build Reports
Reports Server Clustering
......................................................................................................................................................
Technical Note
The Reports Server requires Oracle Net8. 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.
......................................................................................................................................................
Oracle Developer: Build Reports 17-23
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
......................................................................................................................................................
17-24 Oracle Developer: Build Reports
Viewing and Scheduling Reports in the Queue Manager
......................................................................................................................................................
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.
......................................................................................................................................................
Oracle Developer: Build Reports 17-25
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
Queue Manager
Past jobs
Current jobs
Scheduled jobs
Queue Manager
All my jobs
All jobs
Refresh
......................................................................................................................................................
17-26 Oracle Developer: Build Reports
Viewing and Scheduling Reports in the Queue Manager
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 17-27
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
......................................................................................................................................................
17-28 Oracle Developer: Build Reports
Viewing and Scheduling Reports in the Queue Manager
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 17-29
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
......................................................................................................................................................
17-30 Oracle Developer: Build Reports
Viewing and Scheduling Reports in the Queue Manager
......................................................................................................................................................
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.
......................................................................................................................................................
Oracle Developer: Build Reports 17-31
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
Summary
Reports Server provides:
• Increased efficiency and scalability
• Three-tiered architecture
• Reports client (RWCLI60)
• Reports Server (RWMTS60)
• Reports caching
• Status and rescheduling (RWRQM60)
• ActiveX control for other applications
......................................................................................................................................................
17-32 Oracle Developer: Build Reports
Summary
......................................................................................................................................................
Summary
The new remote Reports Server provides increased efficiency, scalability and
distributed capabilities 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.
......................................................................................................................................................
Oracle Developer: Build Reports 17-33
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
Practice 17 Overview
......................................................................................................................................................
17-34 Oracle Developer: Build Reports
Practice Session Overview: Lesson 17
......................................................................................................................................................
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.
......................................................................................................................................................
Oracle Developer: Build Reports 17-35
Lesson 17: Maximizing Performance Using the Reports Server
......................................................................................................................................................
......................................................................................................................................................
17-36 Oracle Developer: Build Reports
18
................................
Objectives
......................................................................................................................................................
18-2 Oracle Developer: Build Reports
Overview
......................................................................................................................................................
Overview
Introduction
Oracle Developer 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 do the following:
• 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
......................................................................................................................................................
Oracle Developer: Build Reports 18-3
Lesson 18: Building Reports for Different Environments
......................................................................................................................................................
......................................................................................................................................................
18-4 Oracle Developer: Build Reports
Different Development and Run-Time Environments
......................................................................................................................................................
Bitmapped Environment
This environment has a unit of pixel and typically supports a mouse. Interaction
with the host computer is continuous.
The bitmapped Designer allows you, as a developer, to take advantage of the
graphical user interface.
......................................................................................................................................................
Oracle Developer: Build Reports 18-5
Lesson 18: Building Reports for Different Environments
......................................................................................................................................................
......................................................................................................................................................
18-6 Oracle Developer: Build Reports
Developing Reports to Run in Different GUIs
......................................................................................................................................................
Example
In the uifont.ali file on Microsoft Windows, map Motif and Mac fonts to
Microsoft Windows:
/* Motif fonts */
lucidatypewriter= ”Courier New”
lucidabright= ”Times New Roman”
fixed = ”Courier New”
/* Mac fonts */
”Avant Garde”= ”Arial”
”New York”= ”Times New Roman”
In the uifont.ali file on UNIX (motif), map Microsoft Windows fonts to Motif:
/* Microsoft Windows fonts */
”Courier New” = lucidatypewriter
”Times New Roman”= lucidabright
......................................................................................................................................................
Oracle Developer: Build Reports 18-7
Lesson 18: Building Reports for Different Environments
......................................................................................................................................................
......................................................................................................................................................
18-8 Oracle Developer: Build Reports
Building Character Mode Reports
......................................................................................................................................................
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.
......................................................................................................................................................
Oracle Developer: Build Reports 18-9
Lesson 18: Building Reports for Different Environments
......................................................................................................................................................
......................................................................................................................................................
18-10 Oracle Developer: Build Reports
Building Character Mode Reports
......................................................................................................................................................
Font
Before creating any layout, choose a font that 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.
......................................................................................................................................................
Oracle Developer: Build Reports 18-11
Lesson 18: Building Reports for Different Environments
......................................................................................................................................................
NLS_LANG=French_France.WE8DEC
NLS_LANG=French_France.WE8DEC
• UNICODE
NLS_LANG=<lang>_<territory>.AL24UTFFSS
NLS_LANG=<lang>_<territory>.AL24UTFFSS
......................................................................................................................................................
18-12 Oracle Developer: Build Reports
Building Reports to Run in Different Languages
......................................................................................................................................................
Example NLS_LANG=French_France.WE8DEC
Syntax
NLS_LANG = <language>_<territory>.AL24UTFFSS
......................................................................................................................................................
Oracle Developer: Build Reports 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
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
18-14 Oracle Developer: Build Reports
Building Reports to Run in Different Languages
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports 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-16 Oracle Developer: Build Reports
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.
- Use the MODE parameter to switch from bitmap to character mode.
• Building reports to run in different languages:
- Oracle Developer provides National Language Support.
- Oracle Developer provides Unicode support to handle multiple character
sets in one application.
- Translation Builder supports and manages translations of extracted text
strings.
......................................................................................................................................................
Oracle Developer: Build Reports 18-17
Lesson 18: Building Reports for Different Environments
......................................................................................................................................................
......................................................................................................................................................
18-18 Oracle Developer: Build Reports
A
................................
Solutions
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-2 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 1
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-3
Appendix A: Solutions
......................................................................................................................................................
Close the Help system and leave the Preferences dialog box.
......................................................................................................................................................
A-4 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 1
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: 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 Oracle Developer: Getting Started in the
Oracle Information Navigator.
Choose Oracle Developer: Index.
Go to Administrative Procedures.
The five topics are:
Building Oracle Developer Database Tables
Using the Database Tables
Granting and Revoking User Access
Deleting the Oracle Developer Database Tables
Upgrading the Oracle Developer Database Tables
c In Designing Portable Applications, what is the purpose of section
6.3?
Expand the node Oracle Developer: Guidelines for Building
Applications in the Oracle Information Navigator.
Choose Designing Portable Applications.
Section 6.3 discusses developing a report for maximum
portability.
d Name the three language environment variables available when
developing multilingual applications.
Choose Oracle Developer: Guidelines for Building Applications
and then choose 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 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 1
......................................................................................................................................................
10 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.
......................................................................................................................................................
Oracle Developer: Build Reports A-7
Appendix A: Solutions
......................................................................................................................................................
Introduction
Before you learn to develop reports in the Builder, you should investigate the run-
time 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 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 2
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-9
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-10 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 2
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-11
Appendix A: Solutions
......................................................................................................................................................
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 do not specify a customer ID.
From the menu choose File—>Run. The File Browse window
opens. Select p2q6.rep and choose Open, then immediately
choose 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.
f Close the Previewer window. You are now back in the Runtime
window.
In the Previewer, choose Close Previewer.
g Run the report again. This time enter Customer ID 999.
From the menu choose File—>Run. The File Browse window
opens. 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.
h Close the Previewer window. You are now back in the Runtime
window.
In the Previewer, choose Close Previewer.
......................................................................................................................................................
A-12 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 2
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-13
Appendix A: Solutions
......................................................................................................................................................
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.
......................................................................................................................................................
A-14 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 3
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-15
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-16 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 3
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-17
Appendix A: Solutions
......................................................................................................................................................
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, keep to the file-naming
conventions that the questions specify. You might need these files in later practices.
In addition, note the field headings and widths. With many reports, you need to
change these to achieve the desired result.
Many of the practice sessions ask you to rename files beforehand; be sure to use
Save As, not Save, so that you do not overwrite the existing file name.
......................................................................................................................................................
A-18 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 4
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-19
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-20 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 4
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-21
Appendix A: Solutions
......................................................................................................................................................
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.
Select a different template and choose Finish.
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 box.
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(total_value) values.
Select Sum(TOTAL_VALUE) and choose Sum.
......................................................................................................................................................
A-22 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 4
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-23
Appendix A: Solutions
......................................................................................................................................................
Introduction
In this practice session you will reuse some of the reports that you created in
the last session.
......................................................................................................................................................
A-24 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 5
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-25
Appendix A: Solutions
......................................................................................................................................................
eMake the total at the end of the report right justified and 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
from the toolbar.
Run the report by selecting it in the Object Navigator and then
selecting Program—> Run Report from the menu or choosing Run
from 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. Do not forget to justify the
column header for the SALARY field accordingly.
Select the column and its header, 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.
......................................................................................................................................................
A-26 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 5
......................................................................................................................................................
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 gray.
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
from the toolbar.
Run the report by selecting it in the Object Navigator and then
selecting Program—> Run Report from the menu or choosing Run
from the toolbar.
a Add a date at the top center of the page. Give it any format you want.
Hint: Choose the font, style, and text color you want before inserting
the date.
Choose Insert Date and Time from 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.
......................................................................................................................................................
Oracle Developer: Build Reports A-27
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-28 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 5
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-29
Appendix A: Solutions
......................................................................................................................................................
Introduction
In this practice session, you open an existing template, which is one of the standard
templates shipped with the Oracle Developer Release 6 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.
......................................................................................................................................................
A-30 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 6
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-31
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-32 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 6
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-33
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-34 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 7
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-35
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-36 Oracle Developer: Build Reports
Practice Session Overview: Lesson 8
......................................................................................................................................................
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.
......................................................................................................................................................
Oracle Developer: Build Reports A-37
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-38 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 8
......................................................................................................................................................
3 Open p8q1.rdf .
In the Data Model link the two queries together on the primary and
a
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, although you do
not need to display it. Restrict the query statement to show those who
have a poor credit rating.
In the Data Model select the query Q_CUSTOMER. Press the
right mouse button to open the SQL Query Statement or open it
from the property palette.
Either enter 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. Enter =
’POOR’ and press Return.
b Run to test.
c Save the report as p8q4.rdf and close it.
......................................................................................................................................................
Oracle Developer: 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. Make sure 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 following table.
Hint: You can change the order of fields in the Report Wizard from
the Fields tab.
e Change the following field attributes:
......................................................................................................................................................
A-40 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 8
......................................................................................................................................................
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
......................................................................................................................................................
Oracle Developer: 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 6.
a Department information should be in the master group.
b Look at the Data Model. Notice that 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: Because 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.
8 Create a new report, using a ref cursor query.
a In the Object navigator, create a package defining a record and a ref
cursor. The record has the following fields:
Name Definition
last_name s_emp.last_name%type
first_name s_emp.first_name%type
salary s_emp.salary%type
......................................................................................................................................................
A-42 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 8
......................................................................................................................................................
PACKAGE RefCur IS
TYPE EmpRec IS RECORD ( last_name s_emp.last_name%TYPE,
first_name s_emp.first_name%TYPE,
salary s_emp.salary%TYPE);
Type EmpCur IS REF CURSOR RETURN EmpRec;
END;
Note: You can import the file p8q8a.txt.
You can also import the text file p8q8a.txt. While the PL/SQL editor is
active and the cursor is in the text area, choose File—>Import Text from
the menu to import the text file.
b In the Data Model create a Ref Cursor Query. The function opens the
cursor for the following select statement:
SELECT last_name, first_name, salary
FROM s_emp
Note: You can import the file p8q8b.txt.
Write the following function or import the text file p8q8b.txt:
FUNCTION QR_1RefCurDS RETURN RefCur.EmpCur IS
V_EmpCur RefCur.EmpCur;
BEGIN
OPEN V_EmpCur
FOR
SELECT last_name, first_name, salary
FROM s_emp;
RETURN V_EmpCur;
END;
Open the Report Wizard to create the layout for the report. Select all
c
the fields and choose a template.
d Run and test the report.
e Save the report as p8q8.rdf and close it.
Do you still have any objects open in the Object Navigator? If you do, close them all.
......................................................................................................................................................
Oracle Developer: Build Reports A-43
Appendix A: Solutions
......................................................................................................................................................
Introduction
In your reports, you may need to include additional columns with summary
functions—or even add summaries, such as break totals and report totals.
This practice gives you the opportunity to create summaries and additional
columns with functionality that cannot be achieved using SQL alone.
......................................................................................................................................................
A-44 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 9
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-45
Appendix A: Solutions
......................................................................................................................................................
c Create the following summaries. Can you use the Report Wizard to
create the summaries?
Because this is a single query report you can use the Report
Wizard.
Column Summary
line_total sum
line_total % Total
......................................................................................................................................................
A-46 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 9
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-47
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-48 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 9
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-49
Appendix A: Solutions
......................................................................................................................................................
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 (although 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.
......................................................................................................................................................
A-50 Oracle Developer: Build Reports
Practice Session Overview: Lesson 10
......................................................................................................................................................
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.
......................................................................................................................................................
Oracle Developer: Build Reports A-51
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-52 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 10
......................................................................................................................................................
Add a trailer section that displays today’s date with the text “End of
c
report run on: ” in the body region. Choose a larger font.
Hint: Copy and paste the date from the Margin Area of the report.
Choose Trailer Section from the horizontal toolbar, or choose
Layout Section—>Trailer Section from the menu. Make sure
that you are editing the Body region.
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 and 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_FILENAME from the body region of the main section
in 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].
......................................................................................................................................................
Oracle Developer: Build Reports A-53
Appendix A: Solutions
......................................................................................................................................................
Property Value
Label Type Text
Text Picture
Type Multimedia Column
Multimedia Column Filename
......................................................................................................................................................
A-54 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 10
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-55
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-56 Oracle Developer: Build Reports
Practice Session Overview: Lesson 11
......................................................................................................................................................
Introduction
Modify a mailing label report to ensure that you fill the printed page with
label records. You then restrict the number of labels that are printed on each
page.
You add a link file to display a company logo by dynamically referencing a
file at run time.
......................................................................................................................................................
Oracle Developer: Build Reports A-57
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-58 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 11
......................................................................................................................................................
Property Value
Name B_logo
Source File Format Image
Source File Name logo.tif
......................................................................................................................................................
Oracle Developer: Build Reports A-59
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-60 Oracle Developer: Build Reports
Practice Session Overview: Lesson 12
......................................................................................................................................................
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.
......................................................................................................................................................
Oracle Developer: Build Reports A-61
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-62 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 12
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-63
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-64 Oracle Developer: Build Reports
Practice Session Overview: Lesson 13
......................................................................................................................................................
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 of a chart.
......................................................................................................................................................
Oracle Developer: Build Reports A-65
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-66 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 13
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: 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
must enable Flex Mode. Do not forget to turn 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
must enable Flex Mode. Do not forget to turn 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 Oracle Developer: Build Reports
Practice Session Overview: Lesson 14
......................................................................................................................................................
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.
......................................................................................................................................................
Oracle Developer: Build Reports A-69
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-70 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 14
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: 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 must expand the
appropriate repeating frame.
Select and expand R_G_MONTH. You must enable Flex Mode.
Do not forget to disable it again when you have finished.
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 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 14
......................................................................................................................................................
Property Value
Name F_SumMonth
Source SumMonth
......................................................................................................................................................
Oracle Developer: Build Reports A-73
Appendix A: Solutions
......................................................................................................................................................
Use the right mouse button to open the Query dialog box.
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 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 Oracle Developer: Build Reports
Practice Session Overview: Lesson 15
......................................................................................................................................................
Introduction
In this practice session, you create a format trigger to conditionally flag 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.
......................................................................................................................................................
Oracle Developer: Build Reports A-75
Appendix A: Solutions
......................................................................................................................................................
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 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 15
......................................................................................................................................................
d Ensure that only the Group Above layout is displayed when you
choose a destination of Screen, and that only the Tabular layout is
displayed when you choose a destination of Preview.
Create a format trigger on the M_G_CUSTOMER_ID_GRPFR
group frame in the first layout or use conditional formatting.
function M_G_CUSTOMER_ID_GRPFRFormatTrigger return BOOLEAN is
begin
if:destype = ’Screen’ then
return(true);
else
return(false);
end if;
end;
Create a format trigger on the M_G_ID_GRPFR1 group frame
in the second layout with the reverse logic or use conditional
formatting:
function M_G_ID_GRPFR1FormatTrigger return BOOLEAN is
begin
if :destype = ’Preview’ then
return(true);
else
return(false);
end if;
end;
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 that 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 run time.
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.
......................................................................................................................................................
Oracle Developer: Build Reports A-77
Appendix A: Solutions
......................................................................................................................................................
Click PL/SQL Formula to open the PL/SQL editor, and call the ASTERISK
function from the formula.
function CF_asteriskFormula return varchar2 is
begin
return(asterisk(:date_ordered,:date_shipped));
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 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 15
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-79
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-80 Oracle Developer: Build Reports
Practice Session Overview: Lesson 16
......................................................................................................................................................
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.
......................................................................................................................................................
Oracle Developer: Build Reports A-81
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-82 Oracle Developer: 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: Check the help system for the SRW.SET <attributes> or use
conditional formatting.
Attribute Suggested Values
Fill pattern Crisscross, sandpaper
Foreground fill color Yellow
Background fill color Green
......................................................................................................................................................
Oracle Developer: Build Reports A-83
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-84 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 16
......................................................................................................................................................
Add a button to this report to display a drill-down report when the button is
chosen at run time. The button should be displayed 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 chosen, 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;
......................................................................................................................................................
Oracle Developer: Build Reports A-85
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-86 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 16
......................................................................................................................................................
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’)
......................................................................................................................................................
Oracle Developer: Build Reports A-87
Appendix A: Solutions
......................................................................................................................................................
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;
......................................................................................................................................................
A-88 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 16
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-89
Appendix A: Solutions
......................................................................................................................................................
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.
......................................................................................................................................................
A-90 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 17
......................................................................................................................................................
Type 7 - ToServerCache
Data Connection User Name Your User Name
Password Your Password
Database Your Database
Output Options Output Driver PDF
......................................................................................................................................................
Oracle Developer: Build Reports A-91
Appendix A: Solutions
......................................................................................................................................................
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.
......................................................................................................................................................
A-92 Oracle Developer: Build Reports
Practice Session Solutions: Lesson 17
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports A-93
Appendix A: Solutions
......................................................................................................................................................
......................................................................................................................................................
A-94 Oracle Developer: Build Reports
B
................................
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
......................................................................................................................................................
B-2 Oracle Developer: 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)
......................................................................................................................................................
Oracle Developer: Build Reports B-3
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
S_CUSTOMER Data
......................................................................................................................................................
B-4 Oracle Developer: Build Reports
S_CUSTOMER Data
.....................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports B-5
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
......................................................................................................................................................
B-6 Oracle Developer: Build Reports
S_CUSTOMER Data
.....................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports B-7
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
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 Oracle Developer: 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)
......................................................................................................................................................
Oracle Developer: Build Reports B-9
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
S_EMP Data
......................................................................................................................................................
B-10 Oracle Developer: Build Reports
S_EMP Data
.....................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports B-11
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
......................................................................................................................................................
B-12 Oracle Developer: 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)
......................................................................................................................................................
Oracle Developer: Build Reports B-13
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
S_ITEM Data
......................................................................................................................................................
B-14 Oracle Developer: Build Reports
S_ITEM Data
.....................................................................................................................................................
62 rows selected.
16 rows selected.
......................................................................................................................................................
B-16 Oracle Developer: Build Reports
S_PRODUCT Description
.....................................................................................................................................................
S_PRODUCT Description
Column Name Null? Datatype
---------------------------------- -----------------
ID NOT NULL NUMBER(7)
NAMENOT 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)
......................................................................................................................................................
Oracle Developer: Build Reports B-17
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
S_PRODUCT Data
......................................................................................................................................................
B-18 Oracle Developer: Build Reports
S_PRODUCT Data
.....................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports B-19
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
......................................................................................................................................................
B-20 Oracle Developer: Build Reports
S_PRODUCT Data
.....................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports B-21
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
ID NAME
--- --------------------------
1 North America
2 South America
3 Africa / Middle East
4 Asia
5 Europe
......................................................................................................................................................
B-22 Oracle Developer: Build Reports
S_TITLE Description and Data
.....................................................................................................................................................
TITLE
------------------------
President
Sales Representative
Stock Clerk
VP, Administration
VP, Finance
VP, Operations
VP, Sales
Warehouse Manager
8 rows selected.
......................................................................................................................................................
Oracle Developer: Build Reports B-23
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
emp_type_RefCol
Name Null? Type
-------------------- ------------- ----------------
ID NUMBER(7)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)
DEPT_ID REF OF DEPT_TYPE
SALARY NUMBER(11,2)
COMMISSION_PCT NUMBER(4,2)
dept_type
--------------------------------- ----------------
ID NUMBER
NAME VARCHAR2(25)
REGION_ID NUMBER(7)
......................................................................................................................................................
B-24 Oracle Developer: Build Reports
Oracle8 Objects: Types, Tables
.....................................................................................................................................................
Tables
oo_emp_Table_ObjCol
Name Null? Type
-------------------- ------------- ----------------
ID NUMBER(7)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)
DEPT_ID DEPT_TYPE
SALARY NUMBER(11,2)
COMMISSION_PCT NUMBER(4,2)
ID LAST_NAME FIRST_NAME USERID
--------- --------------------- --------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
-----------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
1Velasquez Carmencvelasqu
03-MAR-90 President
DEPT_TYPE(50, ’Administration’, 1)
2500
2Ngao LaDorislngao
08-MAR-90 1 VP Operations
DEPT_TYPE(41, ’Operations’, 1)
1450
3Nagayama Midorimnagayam
17-JUN-91 1 VP Sales
DEPT_TYPE(31, ’Sales’, 1)
1400
......................................................................................................................................................
Oracle Developer: Build Reports B-25
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
......................................................................................................................................................
B-26 Oracle Developer: Build Reports
Oracle8 Objects: Types, Tables
.....................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports B-27
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
......................................................................................................................................................
B-28 Oracle Developer: Build Reports
Oracle8 Objects: Types, Tables
.....................................................................................................................................................
oo_emp_Table_RefCol
Name Null? Type
------------------------------ ----------------
ID NUMBER(7)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)
DEPT_ID REF OF DEPT_TYPE
SALARY NUMBER(11,2)
COMMISSION_PCTNUMBER(4,2)
......................................................................................................................................................
Oracle Developer: Build Reports B-29
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
......................................................................................................................................................
B-30 Oracle Developer: Build Reports
Oracle8 Objects: Types, Tables
.....................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports B-31
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
......................................................................................................................................................
B-32 Oracle Developer: Build Reports
Oracle8 Objects: Types, Tables
.....................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports B-33
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
oo_dept_table
Name Null? Type
-------------------- ------------- ----------------
ID NUMBER
NAME VARCHAR2(25)
REGION_ID NUMBER(7)
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
......................................................................................................................................................
B-34 Oracle Developer: Build Reports
Oracle8 Objects: Types, Tables
.....................................................................................................................................................
rel_emp_Table_Objcol
Name Null? Type
-------------------- ------------- ----------------
ID NUMBER(7)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)
DEPT_ID DEPT_TYPE
SALARY NUMBER(11,2)
COMMISSION_PCT NUMBER(4,2)
......................................................................................................................................................
Oracle Developer: Build Reports B-35
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
......................................................................................................................................................
B-36 Oracle Developer: Build Reports
Oracle8 Objects: Types, Tables
.....................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports B-37
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
......................................................................................................................................................
B-38 Oracle Developer: Build Reports
Oracle8 Objects: Types, Tables
.....................................................................................................................................................
rel_emp_Table_RefCol
Name Null? Type
-------------------- ------------- ----------------
ID NUMBER(7)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)
DEPT_ID REF OF DEPT_TYPE
SALARY NUMBER(11,2)
COMMISSION_PCT NUMBER(4,2)
......................................................................................................................................................
Oracle Developer: Build Reports B-39
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
......................................................................................................................................................
B-40 Oracle Developer: Build Reports
Oracle8 Objects: Types, Tables
.....................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports B-41
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
......................................................................................................................................................
B-42 Oracle Developer: Build Reports
Oracle8 Objects: Types, Tables
.....................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports B-43
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
......................................................................................................................................................
B-44 Oracle Developer: Build Reports
C
................................
Frequently Asked
Questions
Appendix C: Frequently Asked Questions
......................................................................................................................................................
......................................................................................................................................................
C-2 Oracle Developer: Build Reports
Frequently Asked Questions and Answers
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports C-3
Appendix C: Frequently Asked Questions
......................................................................................................................................................
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 the 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?
References
<PrSol:2058834.6>
......................................................................................................................................................
C-4 Oracle Developer: Build Reports
Frequently Asked Questions and Answers
......................................................................................................................................................
Answer In Windows, use the barcode font supplied as part of the Report Builder
installation, in the <oracle_home>\tools\devdem60\bin directory, or any third-
party barcode font.
Alternatively, you can use Oracle Developer Graphics Builder.
References
<PrSol:2059321.6>
6 How do I print a character mode report in landscape orientation?
References
<Note:34318.1> Landscape Printing in Reports on Windows
7 How do I send report output to a fax?
References
<PrSol:2083424.6>
......................................................................................................................................................
Oracle Developer: Build Reports C-5
Appendix C: Frequently Asked Questions
......................................................................................................................................................
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 6, a nested matrix style creates a “non-sparse” matrix by default, which
means that 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 box.
In Release 2.0, use SRW.SET_ATTR (PRINTER_INTRAY attribute) to set the
printer tray as desired.
In Release 6, use SRW.SET_PRINTER_TRAY, which provides an easier syntax
similar to Form Builder.
References
• <PrSol:2063840.4>
• <Note:40507.1>
......................................................................................................................................................
C-6 Oracle Developer: Build Reports
Frequently Asked Questions and Answers
......................................................................................................................................................
Answer Running a report to a file from the run-time 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 run-
time Previewer?
......................................................................................................................................................
Oracle Developer: Build Reports C-7
Appendix C: Frequently Asked Questions
......................................................................................................................................................
......................................................................................................................................................
C-8 Oracle Developer: Build Reports
D
................................
Supported Platforms
Oracle Rdb is available on the following computing platforms:
• OpenVMS VAX
• OpenVMS Alpha
• Windows NT Intel and Alpha
......................................................................................................................................................
D-2 Oracle Developer: Build Reports
What Is Oracle Rdb?
......................................................................................................................................................
Other Information
......................................................................................................................................................
Oracle Developer: Build Reports D-3
Appendix D: Oracle Rdb Overview
......................................................................................................................................................
Oracle Rdb Product Information The Rdb website is a resource for finding out the
latest news on the product and its features. Look here for information such as:
• New product releases
• Product interoperability information
• How customers are using Oracle Rdb
• Calendar of product-related events
To access the website, go to the following URL: http://www.oracle.com/rdb
......................................................................................................................................................
D-4 Oracle Developer: Build Reports
E
................................
Introduction to Query
Builder
Appendix E: Introduction to Query Builder
......................................................................................................................................................
......................................................................................................................................................
E-2 Oracle Developer: Build Reports
What Is Query Builder?
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports E-3
Appendix E: Introduction to Query Builder
......................................................................................................................................................
......................................................................................................................................................
E-4 Oracle Developer: Build Reports
What Is Query Builder?
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports E-5
Appendix E: Introduction to Query Builder
......................................................................................................................................................
2 3
1 Toolbar
2 Conditions panel
3 Datasource panel
......................................................................................................................................................
E-6 Oracle Developer: Build Reports
The Query Builder Window
......................................................................................................................................................
Toolbar
The toolbar enables you to issue commands with a click of the mouse. You can create
conditions, add new data sources, or define new columns.
......................................................................................................................................................
Oracle Developer: Build Reports E-7
Appendix E: Introduction to Query Builder
......................................................................................................................................................
......................................................................................................................................................
E-8 Oracle Developer: Build Reports
Building a New Query
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports E-9
Appendix E: Introduction to Query Builder
......................................................................................................................................................
1 5
2
6
3
7
4 8
......................................................................................................................................................
E-10 Oracle Developer: Build Reports
Datasource Components
......................................................................................................................................................
Datasource Components
Tables
A table that has been included in a query is referred to as a datasource. It is displayed
as a rectangular graphic in the Datasource panel of the Query window. The top part of
the rectangle contains the table name and an icon representing its type.
Type Description
Table Stores data in the database.
View Acts like a table when you execute a query, but is really a pointer to either a
subset of a table, a combination of tables, or a join of two or more tables.
Synonym Another name for an object. Sometimes table names can be rather cryptic,
such as emp_em_con_tbl. You can create a synonym that simply calls this
table Contracts.
Alias Query Builder uses an alias name for a table when the table is used more
than once, mostly with self-joins (you can also rename a table).
Columns
The body of the rectangle contains column names listed vertically. To the right of the
column name is an icon representing the datatype.
Columns also provide additional information.
• Primary keys are displayed in bold.
• Foreign keys are displayed in italics.
• Recursive relationships are indicated by a self-relationship icon.
......................................................................................................................................................
Oracle Developer: Build Reports E-11
Appendix E: Introduction to Query Builder
......................................................................................................................................................
Refining a Query
......................................................................................................................................................
E-12 Oracle Developer: Build Reports
Refining a Query
......................................................................................................................................................
Refining a Query
Adding Columns to a Query
There are several methods of adding columns to a query:
• Use the check box to the right of the column name
• Double-click the column name
To include all columns from any single table, double-click the table heading.
......................................................................................................................................................
Oracle Developer: Build Reports E-13
Appendix E: Introduction to Query Builder
......................................................................................................................................................
Sorting Data
......................................................................................................................................................
E-14 Oracle Developer: Build Reports
Refining a Query
......................................................................................................................................................
Sorting Data
By default a query returns the data in no specific order. To sort the data, you must add
an ORDER BY clause to the query.
......................................................................................................................................................
Oracle Developer: Build Reports E-15
Appendix E: Introduction to Query Builder
......................................................................................................................................................
......................................................................................................................................................
E-16 Oracle Developer: Build Reports
Viewing and Saving Queries
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports E-17
Appendix E: Introduction to Query Builder
......................................................................................................................................................
......................................................................................................................................................
E-18 Oracle Developer: Build Reports
Including Additional Tables
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports E-19
Appendix E: Introduction to Query Builder
......................................................................................................................................................
Viewing Comments
......................................................................................................................................................
E-20 Oracle Developer: Build Reports
Including Additional Tables
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports E-21
Appendix E: Introduction to Query Builder
......................................................................................................................................................
......................................................................................................................................................
E-22 Oracle Developer: Build Reports
Relationships
......................................................................................................................................................
Relationships
To combine data from multiple tables into one query, Query Builder enables you to
search for relationships between tables and to create user-defined relationships if they
do not exist. Additionally, you can activate or deactivate relationships to suit your
needs.
......................................................................................................................................................
Oracle Developer: Build Reports E-23
Appendix E: Introduction to Query Builder
......................................................................................................................................................
Creating A User-Defined
Relationship
......................................................................................................................................................
E-24 Oracle Developer: Build Reports
Relationships
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports E-25
Appendix E: Introduction to Query Builder
......................................................................................................................................................
Unmatched Rows
......................................................................................................................................................
E-26 Oracle Developer: Build Reports
Relationships
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports E-27
Appendix E: Introduction to Query Builder
......................................................................................................................................................
Conditions
......................................................................................................................................................
E-28 Oracle Developer: Build Reports
Selecting Rows with Conditions
......................................................................................................................................................
The Toolbar
The logical operators and the Accept and Cancel tools in the toolbar are active
whenever the Condition field is active. You can insert an operator from the Toolbar
into the condition by clicking on it.
......................................................................................................................................................
Oracle Developer: Build Reports E-29
Appendix E: Introduction to Query Builder
......................................................................................................................................................
Operators
Arithmetic
• Perform calculations on numeric and date
columns
• Examples: +, -, x, /
Logical
• Combine conditions
• Examples: AND, OR, NOT
Comparison
• Compare one expression with another
• Examples: =, <>, <, IN, IS NULL,
BETWEEN ... AND
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
E-30 Oracle Developer: Build Reports
Operators
......................................................................................................................................................
Operators
An operator is a character or reserved word that is used to perform some operation in
Query Builder, such as the + operator, which performs addition. Query Builder uses
several types of operators.
Arithmetic Operators
Arithmetic (+, -, x, /) operators are used to perform calculations on numeric and date
columns. In handling calculations, Query Builder first evaluates any multiplication or
division, then evaluates any addition or subtraction.
Logical Operators
Logical operators are used to combine conditions. They include:
• AND Causes the Browser to retrieve only data that meets all conditions
• OR Causes the Browser to retrieve all data that meets at least one of
the conditions
• NOT Used to make a negative condition, such as NOT NULL
Comparison Operators
Comparison operators are used to compare one expression with another, such that the
result will either be true or false. The Browser returns all data for which the result
evaluates true.
Operator Usage
= Equal
<> Not equal
< Less than
<= Less than or equal
> Greater than
>= Greater than or equal
BETWEEN... Between two values
AND...
IN (LIST) Equal to any member of the following list
IS NULL Is a NULL value. A row without a value in one column is said to contain a
NULL value.
......................................................................................................................................................
Oracle Developer: Build Reports E-31
Appendix E: Introduction to Query Builder
......................................................................................................................................................
Multiple Conditions
......................................................................................................................................................
E-32 Oracle Developer: Build Reports
Entering Multiple Conditions
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports E-33
Appendix E: Introduction to Query Builder
......................................................................................................................................................
Deactivating a Condition
......................................................................................................................................................
E-34 Oracle Developer: Build Reports
Changing Conditions
......................................................................................................................................................
Changing Conditions
If you change your mind about including one or more conditions in your query, you
can delete, deactivate, or edit any of them in the Conditions panel.
......................................................................................................................................................
Oracle Developer: Build Reports E-35
Appendix E: Introduction to Query Builder
......................................................................................................................................................
......................................................................................................................................................
E-36 Oracle Developer: Build Reports
Defining Columns Using an Expression
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports E-37
Appendix E: Introduction to Query Builder
......................................................................................................................................................
......................................................................................................................................................
E-38 Oracle Developer: Build Reports
Defining Columns Using a Function
......................................................................................................................................................
What Is a Function?
A function is similar to an operator in that it performs a calculation and returns a
result. Functions consist of a function name followed by parentheses, in which you
indicate the arguments.
An argument is an expression that supplies information for the function to use.
Functions usually include at least one argument, most commonly the name of the
column on which the operation will be performed.
Single-Row Functions
• Return one value for every data row operated on.
• Examples: INITCAP(),SUBSTR(), TRUNC().
Aggregate Functions
• Return a single row based on the input of multiple rows of data.
• Examples: AVG(), COUNT(), SUM().
......................................................................................................................................................
Oracle Developer: Build Reports E-39
Appendix E: Introduction to Query Builder
......................................................................................................................................................
......................................................................................................................................................
E-40 Oracle Developer: Build Reports
F
................................
Object Features in
Oracle Developer
Appendix F: Object Features in Oracle Developer
......................................................................................................................................................
Objectives
At the end of this lesson, you should be
able to do the following:
• Describe the new Oracle8 scalar
datatypes
• Describe object types and objects
• Describe object tables, object columns,
and object views
• Describe the INSTEAD-OF triggers
• Describe object REFs
• Identify the display of objects in Object
Navigator
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
F-2 Oracle Developer: Build Reports
Overview
......................................................................................................................................................
Overview
Introduction
In this lesson you will review certain object features of Oracle8. This lesson also
explains how these objects are displayed in the Object Navigator.
Objectives
At the end of this lesson, you should be able to do the following:
• Describe the new Oracle8 scalar datatypes
• Describe object types and objects
• Describe object tables, object columns, and object views
• Describe the INSTEAD-OF triggers
• Describe object REFs
• Identify the display of objects in Object Navigator
......................................................................................................................................................
Oracle Developer: Build Reports F-3
Appendix F: Object Features in Oracle Developer
......................................................................................................................................................
• NCHAR
• NVARCHAR2
• FLOAT
• NLS types
......................................................................................................................................................
F-4 Oracle Developer: Build Reports
New Oracle8 Datatypes
......................................................................................................................................................
NLS Types
Oracle8 offers extended NLS (National Language Support) including national
character sets and the datatypes NCHAR and NVARCHAR2, which store NLS data.
With NLS, number and date formats adapt automatically to the language conventions
specified for a user session, so that users around the world can interact with Oracle in
their native languages. NLS is discussed in Oracle8 Server Reference Manual.
......................................................................................................................................................
Oracle Developer: Build Reports F-5
Appendix F: Object Features in Oracle Developer
......................................................................................................................................................
Object Types
Attributes
Ship
ORDER
po_no Cancel
Check custinfo
status line_items
amount
Hold
Methods
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
F-6 Oracle Developer: Build Reports
New Oracle8 Datatypes
......................................................................................................................................................
Object Types
An object type is a user-defined composite datatype. Orcale8 requires enough
knowledge of a user-defined datatype to interact with it. Therefore, in some sense an
object type is similar to a record type, and in some sense it is similar to a package.
An object type must have one or more attributes and can contain methods.
......................................................................................................................................................
Oracle Developer: Build Reports F-7
Appendix F: Object Features in Oracle Developer
......................................................................................................................................................
Object Types
Attributes
Ship
ORDER
po_no Cancel
Check custinfo
status line_items
amount
Hold
Methods
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
F-8 Oracle Developer: Build Reports
New Oracle8 Datatypes
......................................................................................................................................................
Methods An object type is also similar to a package. Once an object is declared, its
attributes are similar to package variables. And like packages, objects types can
contain procedures and functions. In object types, these subprograms are known as
methods. A method describes the behavior of an object type.
Like packages, object types can be declared in two parts: a specification and a body.
As with package variables, attributes declared in the object type specification are
public and those declared in the body are private. Also as with package subprograms,
all methods are defined in the package body, but only those whose specification
appears in the object type specification are public methods.
Here is an example of an object type:
CREATE TYPE dept_type AS OBJECT
(dept_idNUMBER(2),
dname VARCHAR2(14),
loc VARCHAR2(3),
MEMBER PROCEDURE set_dept_id (d_id NUMBER),
PRAGMA RESTRICT_REFERENCES (set_dept_id,
RNDS,WNDS,RNPS,WNPS),
MEMBER FUNCTION get_dept_id RETURN NUMBER,
PRAGMA RESTRICT_REFERENCES (get_dept_id,
RNDS,WNDS,RNPS,WNPS));
CREATE TYPE BODY dept_type AS
MEMBER PROCEDURE set_dept_id (d_id NUMBER)
IS
BEGIN
dept_id := d_id;
END;
MEMBER FUNCTION get_dept_id
RETURN NUMBER
IS
BEGIN
RETURN (dept_id);
END;
END;
......................................................................................................................................................
Oracle Developer: Build Reports F-9
Appendix F: Object Features in Oracle Developer
......................................................................................................................................................
Object Tables
......................................................................................................................................................
F-10 Oracle Developer: Build Reports
Creating Oracle8 Objects
......................................................................................................................................................
Object Tables
One way to create an object is to create a table whose rows are objects of that object
type.
Here is an example of an object table declaration:
CREATE TABLE o_dept OF dept_type;
SQL and PL/SQL treat object tables very similarly to relational tables, with the
attribute of the object corresponding to the columns of the table. But there are
significant differences. The most important difference is that rows in an object table
are assigned object IDs (OIDs) and can be referenced using a REF type.
Note: REF types are reviewed later.
......................................................................................................................................................
Oracle Developer: Build Reports F-11
Appendix F: Object Features in Oracle Developer
......................................................................................................................................................
Object Columns
......................................................................................................................................................
F-12 Oracle Developer: Build Reports
Creating Oracle8 Objects
......................................................................................................................................................
Object Columns
Another construct that can be based on an object type is an object column in a
relational table. Here is an example of a relational table creation statement with an
object column:
CREATE TABLE o_customer (
custid NUMBER (6) NOT NULL,
name VARCHAR2 (45),
repid NUMBER (4) NOT NULL,
creditlimit NUMBER (9,2),
address address_type,
phone phone_type);
In the object table, the rows of a table are objects. In a relational table with an object
column, the column is an object. The table will usually have standard columns, as well
as one or more object column.
Object columns are not assigned object IDs, and therefore cannot be referenced using
object REF values.
Note: Object REFs are reviewed later in this section.
......................................................................................................................................................
Oracle Developer: Build Reports F-13
Appendix F: Object Features in Oracle Developer
......................................................................................................................................................
Object Views
Object
Object-Oriented relational
View
Application Table
......................................................................................................................................................
F-14 Oracle Developer: Build Reports
Creating Oracle8 Objects
......................................................................................................................................................
Object Views
Often, the most difficult part of adopting a new technology is the conversion process
itself. For example, a large enterprise might have several applications accessing the
same data stored in relational tables. If such an enterprise decided to start using object-
relational technology, they would not convert all of the applications at once. They
would convert the applications one at a time.
That presents a problem. The applications that have been converted need the data
stored as objects, while the applications that have not been converted need the data
stored in relational tables.
This dilemma is addressed by object views. Like all views, an object view transforms
the way a table appears to a user, without changing the actual structure of the table.
Object views make relational tables look like object tables. This allows the developers
to postpone converting the data from relational structures to object-relational
structures until after all of the applications have been converted. During the
conversion process, the object-relational applications can operate against the object
view, while the relational applications can continue to operate against the relational
tables.
Objects accessed through object views are assigned object IDs, and can be referenced
using Object REFs.
Note: Object REFs are reviewed later in this section.
Here is an example of an object view creation statement:
CREATE VIEW emp_view OF emp_type
WITH OBJECT OID (eno)
AS
SELECT e.empno, e.ename, e.sal, e.job
FROM emp e;
......................................................................................................................................................
Oracle Developer: Build Reports F-15
Appendix F: Object Features in Oracle Developer
......................................................................................................................................................
INSTEAD-OF Triggers
DECLARE
BEGIN
EXCEPTION
END;
......................................................................................................................................................
F-16 Oracle Developer: Build Reports
Creating Oracle8 Objects
......................................................................................................................................................
INSTEAD-OF Triggers
INSTEAD-OF triggers provide a transparent way of modifying views that cannot be
modified directly through SQL DML statements (INSERT, UPDATE, and DELETE).
These triggers are called INSTEAD-OF triggers because, unlike other types of
triggers, Oracle fires the trigger instead of executing the triggering statement. The
trigger performs update, insert, or delete operations directly on the underlying tables.
Users write normal INSERT, DELETE, and UPDATE statements against the view and
the INSTEAD-OF trigger works invisibly in the background to make the right actions
take place.
INSTEAD-OF triggers are activated for each row.
Note: Although INSTEAD-OF triggers can be used with any view, they are typically
needed with Object Views.
......................................................................................................................................................
Oracle Developer: Build Reports F-17
Appendix F: Object Features in Oracle Developer
......................................................................................................................................................
References to Objects
OID
......................................................................................................................................................
F-18 Oracle Developer: Build Reports
Referencing Objects
......................................................................................................................................................
Referencing Objects
Introduction
In relational databases, primary key values are used to uniquely identify records. In
object-relational databases, OIDs provide an alternate method.
When a row in an object table or object view is created, it is automatically assigned a
unique identifier called an object ID.
Object REFs
With relational tables, you can associate two records by storing the primary key of one
record in one of the columns (the foreign key column) of another.
In a similar way, you can associate a row in a relational table to an object by storing
the OID of an object in a column of a relational table.
You can also associate two objects by storing the OID of one object in an attribute of
another. The stored copy of the OID then becomes a pointer, or reference (REF), to the
original object.
The attribute or column that holds the OID is of datatype REF.
Note: Object columns are not assigned OIDs and cannot be pointed to by a REF.
Here is an example of a table declaration that includes a column with a REF datatype:
CREATE TABLE o_emp
( empno NUMBER(4) NOT NULL,
ename VARCHAR2(10),
job VARCHAR2(10),
mgr NUMBER(4),
hiredate DATE,
sal NUMBER(7,2),
comm NUMBER(7,2),
dept REF dept_type SCOPE IS o_dept) ;
Note: The REF is scoped here to restrict the reference to a single table, o_dept. The
object itself is not stored in the table, only the OID value for the object.
......................................................................................................................................................
Oracle Developer: Build Reports F-19
Appendix F: Object Features in Oracle Developer
......................................................................................................................................................
Object Types in
Object Navigator
......................................................................................................................................................
F-20 Oracle Developer: Build Reports
Displaying Oracle8 Objects in the Object Navigator
......................................................................................................................................................
Object Types
Both the attributes and the methods are listed under each type. Also, the nested types
within address_and_phone_type are displayed in an indented sublevel.
This convention is used for nested object and object type displays throughout Oracle
Developer.
......................................................................................................................................................
Oracle Developer: Build Reports F-21
Appendix F: Object Features in Oracle Developer
......................................................................................................................................................
Object Tables in
Object Navigator
Object Columns in
Object Navigator
......................................................................................................................................................
F-22 Oracle Developer: Build Reports
Displaying Oracle8 Objects in the Object Navigator
......................................................................................................................................................
Object Tables
Object tables are displayed like relational tables, with the attributes of the object
displayed like columns in a relational table. Also, the object table type name is
displayed in parentheses after the name of the object table.
Object Columns
Object columns are displayed with the object type in parentheses after the column
name, and with the attributes of the type indented underneath the column name.
......................................................................................................................................................
Oracle Developer: Build Reports F-23
Appendix F: Object Features in Oracle Developer
......................................................................................................................................................
Object Views in
Object Navigator
......................................................................................................................................................
F-24 Oracle Developer: Build Reports
Displaying Oracle8 Objects in the Object Navigator
......................................................................................................................................................
Object Views
Object views are displayed like any other view, except that the object type they are
based on is written in parentheses after the view name.
INSTEAD-OF Triggers
INSTEAD-OF database triggers can now be created through the trigger creation
dialog box, just like any other database trigger.
INSTEAD-OF INSERT, UPDATE, and DELETE triggers allow you to directly insert,
update, and delete against object views. They can also be used with any other type of
view that does not allow direct DML.
When a view has an INSTEAD-OF trigger, the code in the trigger is executed in place
of the triggering DML code.
......................................................................................................................................................
Oracle Developer: Build Reports F-25
Appendix F: Object Features in Oracle Developer
......................................................................................................................................................
Object REFs in
Object Navigator
......................................................................................................................................................
F-26 Oracle Developer: Build Reports
Displaying Oracle8 Objects in the Object Navigator
......................................................................................................................................................
Object REFs
Object types that contain attributes of type REF, and relational tables that have
columns of type REF, display the keyword REF before the name of the object type that
is being referenced.
The attributes of the referenced object type are displayed indented underneath the
column or attribute.
......................................................................................................................................................
Oracle Developer: Build Reports F-27
Appendix F: Object Features in Oracle Developer
......................................................................................................................................................
Summary
• Oracle8 introduced three new scalar
datatypes.
• Objects and object types allow
representation of complex data.
• Three kinds of objects are object tables,
object columns, and object views.
Summary
• INSTEAD-OF triggers allow DML on
object views.
• Object REFs store the Object Identifier
of certain types of objects.
• The Object Navigator can display
certain types of objects.
......................................................................................................................................................
F-28 Oracle Developer: Build Reports
Summary
......................................................................................................................................................
Summary
New Oracle8 Datatypes
Oracle8 introduced three new scalar datatypes and new composite dataypes such as
object types.
Objects
Three kinds of objects are object tables, object columns, and object views.
INSTEAD-OF triggers allow DML on object views.
Object REFs store the object identifier of certain types of objects.
......................................................................................................................................................
Oracle Developer: Build Reports F-29
Appendix F: Object Features in Oracle Developer
......................................................................................................................................................
......................................................................................................................................................
F-30 Oracle Developer: Build Reports
G
................................
Lesson Objectives
......................................................................................................................................................
G-2 Oracle Developer: Build Reports
Overview
......................................................................................................................................................
Overview
Introduction
In this lesson, you learn the graphical features of the Layout editor that are common to
all the Oracle Developer tools. This will help you control the visual arrangement and
appearance of objects in your applications.
Objectives
At the end of this lesson, you should be able to do the following:
• Control the position and size of objects in a layout
• Add lines and geometric shapes
• Define the colors and fonts used for text
• Color the body and boundaries of objects
• Import images onto the layout
......................................................................................................................................................
Oracle Developer: Build Reports G-3
Appendix G: Using the Layout Editor in Oracle Developer
......................................................................................................................................................
Common Features
•Moving and resizing objects and text
•Defining colors and fonts
•Importing and manipulating images
and drawings
•Creating geometric lines and shapes
Layout Types
• Canvas-views in Forms
• Display layers for Graphics
• Report layouts
......................................................................................................................................................
G-4 Oracle Developer: Build Reports
Why Use the Layout Editor?
......................................................................................................................................................
Layout Types
You can use the Layout editor to control the visual layout in each of the main Oracle
Developer Tools. The surfaces include:
• Canvas Views in Forms: A Canvas is the surface on which you arrange a
form’s objects. Its View is the portion of that Canvas that is initially
visible in a window at run time. You can also see Stacked or Tabbed
Canvas Views in the Layout editor; their views might overlay others in
the same window. You can also display stacked views in the Layout
editor.
• Display Layers in Graphics: The layers of a Display can contain charts,
text, and graphical objects. These layers can be overlaid or hidden when
required. Geometric shapes that you create in Graphics can be given
their own functionality.
• Layouts in Reports: Here, the Layout editor lets you plan the format of a
report. This includes the frame structure of the report, as well as buttons,
graphics, and background text (boilerplate).
......................................................................................................................................................
Oracle Developer: Build Reports G-5
Appendix G: Using the Layout Editor in Oracle Developer
......................................................................................................................................................
......................................................................................................................................................
G-6 Oracle Developer: Build Reports
How to Access the Layout Editor
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports G-7
Appendix G: Using the Layout Editor in Oracle Developer
......................................................................................................................................................
......................................................................................................................................................
G-8 Oracle Developer: Build Reports
The Layout Editor Components
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports G-9
Appendix G: Using the Layout Editor in Oracle Developer
......................................................................................................................................................
Tool Palette
1
2 8
3 9
4 10
5 11
6 12
7 13
1 Select 8 Rotate
2 Magnify 9 Reshape
3 Rectangle 10 Line
4 Ellipse 11 Arc
5 Polygon 12 Polyline
6 Rounded Rectangle 13 Freehand
7 Text
......................................................................................................................................................
G-10 Oracle Developer: Build Reports
Creating and Modifying Objects in the Layout
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports G-11
Appendix G: Using the Layout Editor in Oracle Developer
......................................................................................................................................................
Selecting Objects
Manipulating Objects
Expand/Contract
in One Direction
Expand/Contract
Diagonally
......................................................................................................................................................
G-12 Oracle Developer: Build Reports
Creating and Modifying Objects in the Layout
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports G-13
Appendix G: Using the Layout Editor in Oracle Developer
......................................................................................................................................................
......................................................................................................................................................
G-14 Oracle Developer: Build Reports
Creating and Modifying Objects in the Layout
......................................................................................................................................................
Overlapping Objects
You can position objects on top of each other. If they are transparent, then one object
can be seen through another (this is explained in detail later in this lesson).
Change the stacking order of overlapping objects by selecting the object to move and
then choosing the following, as required, from the Arrange menu:
• Bring to Front
• Send to Back
• Move Forward
• Move Backward
......................................................................................................................................................
Oracle Developer: Build Reports G-15
Appendix G: Using the Layout Editor in Oracle Developer
......................................................................................................................................................
......................................................................................................................................................
G-16 Oracle Developer: Build Reports
Creating and Modifying Objects in the Layout
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports G-17
Appendix G: Using the Layout Editor in Oracle Developer
......................................................................................................................................................
Format Menu
......................................................................................................................................................
G-18 Oracle Developer: Build Reports
Formatting Objects in the Layout
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports G-19
Appendix G: Using the Layout Editor in Oracle Developer
......................................................................................................................................................
2
3
4
1 Sample window
2 Fill color/pattern
3 Line color
4 Text color
......................................................................................................................................................
G-20 Oracle Developer: Build Reports
Coloring Objects and Text
......................................................................................................................................................
Coloring Objects
You can separately color the Fill area (body) of an object and its boundary line (a Line
object has no body).
......................................................................................................................................................
Oracle Developer: Build Reports G-21
Appendix G: Using the Layout Editor in Oracle Developer
......................................................................................................................................................
......................................................................................................................................................
G-22 Oracle Developer: Build Reports
Coloring Objects and Text
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Reports G-23
Appendix G: Using the Layout Editor in Oracle Developer
......................................................................................................................................................
Importing Images
......................................................................................................................................................
G-24 Oracle Developer: Build Reports
Importing Images and Drawings
......................................................................................................................................................
Importing Drawings
These are line art files, which you can import onto the layout from either the
filesystem or the database. Select File—>Import—>Drawing from the menu and
specify the source in the Import dialog box. The format can be Oracle or a CGM file.
Importing Images
Select File—>Import—>Image from the menu and set the Import Image options:
Option Description
(Option buttons) File/Database Where to import from
Filename File to be imported
Format Image format (BMP, TIFF, PCX, PICT, GIF, CALS,
RAS, Oracle Format, and PCD [Kodak Photo CD])
Quality Range from Excellent to Poor; this is a tradeoff
between image resolution and memory required
......................................................................................................................................................
Oracle Developer: Build Reports G-25
Appendix G: Using the Layout Editor in Oracle Developer
......................................................................................................................................................
Summary
• Create objects by:
1. Choosing a palette tool
2. Clicking and dragging on layout region
• Color palette tools for fill area, lines, and
text
• View, arrange, and format menus available
for layout
• Objects may be grouped for operations
• Import images and drawings by
File—>Import
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
G-26 Oracle Developer: Build Reports
Summary
......................................................................................................................................................
Summary
• Create objects by:
- Choosing the correct toolbar tool.
- Clicking and dragging the Layout region.
• There are color palette tools for Fill Area, Lines, and Text.
• View, Arrange, and Format menus are available while you are in the
Layout editor.
• You can group objects for operations.
• Import images and drawings by selecting Edit—>Import.
......................................................................................................................................................
Oracle Developer: Build Reports G-27
Appendix G: Using the Layout Editor in Oracle Developer
......................................................................................................................................................
......................................................................................................................................................
G-28 Oracle Developer: Build Reports