+ All Categories
Transcript
Page 1: Oracle Developer: Build Reports

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

43212GC10

Production 1.0

April 1999

M08693

Oracle Developer: Build Reports

Volume 2 • Student Guide

Page 2: Oracle Developer: Build Reports

Authors

Christian Bauwens

Ursula Hovy

Technical Reviewers

Gunnar Boehrs

Jackie Bruce

Ruth Delaney

Laurent Dereac

Astrid Dietrich

Brian Fry

Mary Lee

Stella Misiulis

Paul Narth

Sergiy Pechersky

Raza Siddiqui

John Walsh

Publisher

Sherry Polm

Copyright Oracle Corporation, 1999. All rights reserved.

This documentation contains proprietary information of Oracle Corporation. It isprovided under a license agreement containing restrictions on use and disclosureand is also protected by copyright law. Reverse engineering of the software isprohibited. If this documentation is delivered to a U.S. Government Agency of theDepartment of Defense, then it is delivered with Restricted Rights and thefollowing legend is applicable:

Restricted Rights LegendUse, duplication or disclosure by the Government is subject to restrictions forcommercial computer software and shall be deemed to be Restricted Rightssoftware under Federal law, as set forth in subparagraph (c) (1) (ii) of DFARS252.227-7013, Rights in Technical Data and Computer Software (October 1988).

This material or any portion of it may not be copied in any form or by any meanswithout the express prior written permission of Oracle Corporation. Any othercopying is a violation of copyright law and may result in civil and/or criminalpenalties.

If this documentation is delivered to a U.S. Government Agency not within theDepartment of Defense, then it is delivered with “Restricted Rights,” as defined inFAR 52.227-14, Rights in Data-General, including Alternate III (June 1987).

The information in this document is subject to change without notice. If you findany problems in the documentation, please report them in writing to EducationProducts, Oracle Corporation, 500 Oracle Parkway, Box SB-6, Redwood Shores,CA 94065. Oracle Corporation does not warrant that this document is error-free.

All references to Oracle and Oracle products are trademarks or registeredtrademarks of Oracle Corporation.

All other products or company names are used for identification purposes onlyand may be trademarks of their respective owners.

Page 3: Oracle Developer: Build Reports

.....................................................................................................................................................Oracle Developer: Build Reports iii

.....................................................................................................................................................Contents

PrefaceProfile xv

Related Publications xvi

Typographic Conventions xvii

IntroductionOverview I-3

Course Objectives I-5

Course Content I-7

Lesson 1: Introduction to Oracle ReportsOverview 1-3

What Is Oracle Developer? 1-5

Introducing the Oracle Developer Release 6.0 Components 1-9

Report Builder Components 1-13

Getting Started in the Oracle Reports Interface 1-17

Navigating Around the Oracle Reports Main Menu 1-19

Customizing Your Oracle Reports Session 1-21

Oracle Reports Environment Variables 1-25

Oracle Reports Help Options 1-27

Introducing the Course Application 1-29

Summary 1-31

Practice Session Overview: Lesson 1 1-33

Practice Session: Lesson 1 1-34

Lesson 2: Designing and Running ReportsOverview 2-3

Designing Reports 2-5

Design Considerations 2-7

Retrieving and Sharing Data 2-15

Running a Report 2-17

Viewing the Report Output 2-19

Summary 2-29

Practice Session Overview: Lesson 2 2-31

Practice Session: Lesson 2 2-32

Page 4: Oracle Developer: Build Reports

.....................................................................................................................................................iv Oracle Developer: Build Reports

.....................................................................................................................................................Contents

Lesson 3: Report Builder ConceptsOverview 3-3

Report Executables 3-5

Report Builder Components 3-9

Object Categories 3-13

Summary 3-23

Practice Session Overview: Lesson 3 3-25

Practice Session: Lesson 3 3-26

Lesson 4: Creating Reports Using the Report WizardOverview 4-3

Invoking Report Builder and the Report Wizard 4-5

Creating a Tabular Report Using the Wizard 4-7

Creating Other Report Styles 4-23

Summary 4-33

Practice Session Overview: Lesson 4 4-35

Practice Session: Lesson 4 4-36

Lesson 5: Enhancing Reports in the Live PreviewerOverview 5-3

What Is the Live Previewer? 5-5

Modifying a Report in the Live Previewer 5-7

Summary 5-22

Practice Session Overview: Lesson 5 5-24

Practice Session: Lesson 5 5-25

Lesson 6: Managing Report TemplatesOverview 6-3

Using the Report Templates 6-5

Modifying a Template 6-7

Predefining Your Own Templates 6-13

Summary 6-17

Practice Session Overview: Lesson 6 6-19

Practice Session: Lesson 6 6-20

Page 5: Oracle Developer: Build Reports

.....................................................................................................................................................Oracle Developer: Build Reports v

.....................................................................................................................................................Contents

Lesson 7: Report Storage MethodsOverview 7-3

Storage Methods and Requirements 7-5

Documenting Your Reports 7-9

File Portability 7-11

Converting Report Definitions 7-15

Migrating Reports from Previous Releases 7-17

Summary 7-19

Practice Session Overview: Lesson 7 7-21

Practice Session: Lesson 7 7-22

Lesson 8: Enhancing Reports Using the Data Model: Creating Queries and Groups

Overview 8-3

Describing the Report Data Model 8-5

Modifying Properties of a Query 8-7

Changing the Group Structure 8-13

The Group Hierarchy 8-15

Ordering Data in a Group Hierarchy 8-17

Filtering Data in a Group 8-21

Adding New Data 8-23

8-27

Oracle8 Objects in Report Builder 8-30

Using Data Links to Structure Data 8-36

Efficiency Issues: Multiple- or Single-Query Hierarchy 8-42

Summary 8-44

Practice Session Overview: Lesson 8 8-46

Practice Session: Lesson 8 8-47

Lesson 9: Enhancing Reports Using the Data Model: Creating ColumnsOverview 9-3

The Data Model Column Types 9-5

Maintaining Database Columns 9-7

Using a Database Column to Output Contents of a File 9-9

Page 6: Oracle Developer: Build Reports

.....................................................................................................................................................vi Oracle Developer: Build Reports

.....................................................................................................................................................Contents

Creating a Column 9-11

Creating Summary Columns 9-13

Example Report Displaying Subtotals 9-15

Example Report Displaying Percentages 9-17

Creating Formula Columns 9-21

Creating Placeholder Columns 9-23

Example Report to Populate a Placeholder 9-25

Summary 9-27

Practice Session Overview: Lesson 9 9-29

Practice Session: Lesson 9 9-30

Lesson 10: Enhancing Reports Using the Layout ModelOverview 10-3

Viewing the Layout Model Regions 10-5

Viewing the Report Sections in the Layout Model 10-7

Designing Multipanel Reports 10-9

The Layout Model Layers 10-13

Creating Layout Objects 10-19

The Layout Model Tools 10-21

Creating Additional Layouts in a Report 10-23

Creating Variable Length Lines 10-25

Displaying a Multimedia File from a Button 10-27

Creating Explicit Anchors 10-29

Summary 10-33

Practice Session Overview: Lesson 10 10-35

Practice Session: Lesson 10 10-36

Lesson 11: Modifying PropertiesOverview 11-3

Modifying Layout Object Properties 11-5

Displaying File Contents with a Link File 11-7

Modifying Common Layout Properties 11-13

Sizing Objects 11-15

Layout Object Relationships 11-17

Page 7: Oracle Developer: Build Reports

.....................................................................................................................................................Oracle Developer: Build Reports vii

.....................................................................................................................................................Contents

Modifying Properties of a Field 11-29

Modifying Properties of a Repeating Frame 11-37

Summary 11-43

Practice Session Overview: Lesson 11 11-45

Practice Session: Lesson 11 11-46

Lesson 12: Creating and Using Report ParametersOverview 12-3

Creating User Parameters 12-5

Referencing Parameters in a Report Query 12-7

Hints and Tips for Referencing Parameters 12-13

Creating a List of Values 12-15

Referencing System Parameters 12-19

Building a Parameter Form 12-23

Summary 12-27

Practice Session Overview: Lesson 12 12-29

Practice Session: Lesson 12 12-30

Lesson 13: Embedding a Chart in a ReportOverview 13-3

Creating and Embedding a Graphics Chart in a Report 13-5

Embedding an Existing Chart in a Report 13-9

Summary 13-11

Practice Session Overview: Lesson 13 13-13

Practice Session: Lesson 13 13-14

Lesson 14: Enhancing Matrix ReportsOverview 14-3

The Matrix Data Model 14-5

Matrix Layout 14-7

Creating Matrix Summaries 14-9

Building a Nested Matrix 14-11

Summary 14-19

Practice Session Overview: Lesson 14 14-21

Practice Session: Lesson 14 14-22

Page 8: Oracle Developer: Build Reports

.....................................................................................................................................................viii Oracle Developer: Build Reports

.....................................................................................................................................................Contents

Lesson 15: Coding PL/SQL Triggers in ReportsOverview 15-3

Types of Triggers in Reports 15-5

Using Report Triggers 15-7

Using Data Model Triggers 15-11

Using Layout Model Triggers 15-15

Writing Common Code 15-27

Summary 15-29

Practice Session Overview: Lesson 15 15-31

Practice Session: Lesson 15 15-32

Lesson 16: Using the Report Builder Built-In PackageOverview 16-3

Contents of the Report Builder Built-in Package 16-5

Outputting Messages 16-7

Executing a Nested Report 16-9

Restricting Data 16-15

Initializing Fields 16-17

Performing DDL Statements 16-19

Setting Format Attributes 16-21

Summary 16-25

Practice Session Overview: Lesson 16 16-27

Practice Session: Lesson 16 16-28

Lesson 17: Maximizing Performance Using the Reports ServerOverview 17-3

Why Use a Remote Server? 17-5

Reports Server Architecture and Configuration 17-9

Reports Server Clustering 17-11

Viewing and Scheduling Reports in the Queue Manager 17-25

Summary 17-33

Practice Session Overview: Lesson 17 17-35

Practice Session: Lesson 17 17-36

Page 9: Oracle Developer: Build Reports

.....................................................................................................................................................Oracle Developer: Build Reports ix

.....................................................................................................................................................Contents

Lesson 18: Building Reports for Different EnvironmentsOverview 18-3

Different Development and Run-Time Environments 18-5

Developing Reports to Run in Different GUIs 18-7

Building Character Mode Reports 18-9

Building Reports to Run in Different Languages 18-13

Summary 18-17

Appendix A: SolutionsPractice 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

Page 10: Oracle Developer: Build Reports

.....................................................................................................................................................x Oracle Developer: Build Reports

.....................................................................................................................................................Contents

Practice Session Overview: Lesson 13 A-65

Practice Session Solutions: Lesson 13 A-66

Practice Session Overview: Lesson 14 A-69

Practice Session Solutions: Lesson 14 A-70

Practice Session Overview: Lesson 15 A-75

Practice Session Solutions: Lesson 15 A-76

Practice Session Overview: Lesson 16 A-81

Practice Session Solutions: Lesson 16 A-82

Practice Session Overview: Lesson 17 A-90

Practice Session Solutions: Lesson 17 A-91

Appendix B: Table Descriptions and DataSummit Sporting Goods Database Diagram B-2

S_CUSTOMER Description B-3

S_CUSTOMER Data B-4

S_DEPT Description and Data B-8

S_EMP Description B-9

S_EMP Data B-10

S_ITEM Description B-13

S_ITEM Data B-14

S_ORD Description and Data B-16

S_PRODUCT Description B-17

S_PRODUCT Data B-18

S_REGION Description and Data B-22

S_TITLE Description and Data B-23

Oracle8 Objects: Types, Tables B-24

Appendix C: Frequently Asked QuestionsFrequently Asked Questions C-2

Frequently Asked Questions and Answers C-3

Appendix D: Oracle Rdb OverviewWhat Is Oracle Rdb? D-2

Page 11: Oracle Developer: Build Reports

.....................................................................................................................................................Oracle Developer: Build Reports xi

.....................................................................................................................................................Contents

Appendix E: Introduction to Query BuilderWhat Is Query Builder? E-3

The Query Builder Window E-7

Building a New Query E-9

Datasource Components E-11

Refining a Query E-13

Viewing and Saving Queries E-17

Including Additional Tables E-19

Relationships E-23

Selecting Rows with Conditions E-29

Operators E-31

Entering Multiple Conditions E-33

Changing Conditions E-35

Defining Columns Using an Expression E-37

Defining Columns Using a Function E-39

Appendix F: Object Features in Oracle Developer

Overview F-3

New Oracle8 Datatypes F-5

Creating Oracle8 Objects F-11

Referencing Objects F-19

Displaying Oracle8 Objects in the Object Navigator F-21

Summary F-29

Appendix G: Using the Layout Editor in Oracle DeveloperOverview G-3

Why Use the Layout Editor? G-5

How to Access the Layout Editor G-7

The Layout Editor Components G-9

Creating and Modifying Objects in the Layout G-11

Formatting Objects in the Layout G-19

Coloring Objects and Text G-21

Importing Images and Drawings G-25

Summary G-27

Page 12: Oracle Developer: Build Reports

.....................................................................................................................................................xii Oracle Developer: Build Reports

.....................................................................................................................................................Contents

Page 13: Oracle Developer: Build Reports

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

14

Enhancing Matrix Reports

Page 14: Oracle Developer: Build Reports

14-2 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Objectives

At the end of this lesson, you should beable to do the following:

• Describe the matrix Data Model objects

• Describe the matrix Layout objects

• Create and modify matrix summaries

• Display zeros in cells with no value

Page 15: Oracle Developer: Build Reports

Oracle Developer: Build Reports 14-3......................................................................................................................................................

......................................................................................................................................................Overview

Overview

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

ObjectivesAt 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

Page 16: Oracle Developer: Build Reports

14-4 Oracle Developer: Build Reports......................................................................................................................................................

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

1 Cross product group 4 Cell column is the source of a cross product summary that becomes the cell content

2 Row and Column groups 5 Row and Column summaries

3 Cell group

Copyright Oracle Corporation, 1999. All rights reserved.

The Matrix Data Model

1

2

3

45

Page 17: Oracle Developer: Build Reports

Oracle Developer: Build Reports 14-5......................................................................................................................................................

......................................................................................................................................................The Matrix Data Model

The Matrix Data Model

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

What Does the Wizard Create?The Data Model opposite is the matrix report created in an earlier lesson. It demonstrates the structure of the Matrix and Matrix with Group styles.

Simple Matrix Style The wizard creates three data groups:

• Department records (the rows)

• Job Title records (the columns)

• Salary records (the values used to calculate the matrix cells)

There is an extra group that surrounds the row and column groups. It is called the cross product group and contains the summary column that forms each cell value, SumSalary, as well as the summaries to total the row and column values.

To create a cross product group, use the Cross Product tool in the vertical toolbar.

Matrix with Group The data model is identical, except for the addition of a break group, similar to a master/detail hierarchy.

The break group exists one level above, and outside, the matrix group. The entire cross product group, with its contents, repeats for each record in the break group.

Page 18: Oracle Developer: Build Reports

14-6 Oracle Developer: Build Reports......................................................................................................................................................

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

1 Repeating frame for rows (Down Direction)

3 Matrix object, the intersection of the two repeating frames

2 Repeating frame for columns (Across)

4 Matrix with Group style: Outer repeating frame for break group

Copyright Oracle Corporation, 1999. All rights reserved.

The Matrix Layout

1 2 3 4

Page 19: Oracle Developer: Build Reports

Oracle Developer: Build Reports 14-7......................................................................................................................................................

......................................................................................................................................................Matrix Layout

Matrix Layout

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

What Does the Wizard Create?The layout for a Matrix report is more complex than other styles because of the special relationship between the row and column groups and the cell values.

Simple Matrix Style The wizard creates the following objects:

• One repeating frame with Print Direction of Down to hold the row values

• One repeating framewith Print Direction of Across to hold the column values

• A field for the summary of the cell values; the source is SumSalary, which resides in the cross product group

• Fields for the row and column values, as well as for the row, column, and report summaries if applicable

• A matrix object that corresponds to the cross product group; this object intersects the row and column repeating frames, and contains the cell field

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

Page 20: Oracle Developer: Build Reports

14-8 Oracle Developer: Build Reports......................................................................................................................................................

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

1 Product Order = G_DEPT 3 Product Order = G_DEPT G_TITLE

2 Product Order = G_TITLE

Copyright Oracle Corporation, 1999. All rights reserved.

Creating Matrix Summaries

1 2

3

Page 21: Oracle Developer: Build Reports

Oracle Developer: Build Reports 14-9......................................................................................................................................................

......................................................................................................................................................Creating Matrix Summaries

Creating Matrix Summaries

IntroductionWhen creating row or column summaries, or the summary for the cell values, use the summary tool in the vertical toolbar, but ensure that you create the summaries inside the cross product group (but outside the row and column groups).

This section discusses an extra property that applies only to cross product summaries, the Product Order property.

Setting the Product OrderThe wizard sets a sensible default for this property. You do not need to alter the setting, but you need to understand this property if you create complex matrix reports, or add columns to an existing matrix report.

The product order defines the order in which Report Builder evaluates the groups in the cross product for a summary.

Product Order also defines the frequency of a summary, formula, or placeholder column in a cross product group. That is, the column has one value for each combination of values in its Product Order groups.

The Product Order list of values provides all possible group combinations.

In the matrix report:

• F_SumSalPerDEPT has one value for each department (G_DEPT)

• F_SumSalPerTITLE has one value for each job title (G_TITLE)

• F_SumSALARY, the matrix cell, has one value for each combination of G_DEPT and G_TITLE, so the Product Order is G_DEPT G_TITLE.

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.

Source Column Reset At Product Order

F_SumSALPerDEPT_NAME G_DEPT G_DEPT

F_Sum_SALPerTITLE G_TITLE G_TITLE

F_SumSALARY G_TITLE G_DEPT G_TITLE

Page 22: Oracle Developer: Build Reports

14-10 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Building a Nested Matrix

Page 23: Oracle Developer: Build Reports

Oracle Developer: Build Reports 14-11......................................................................................................................................................

......................................................................................................................................................Building a Nested Matrix

Building a Nested Matrix

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

What Is in the Nested Matrix Data Model?The wizard creates the same objects as for a simple matrix structure. In addition, it creates an additional break group for each level of nesting.

The cross product group encloses the additional break groups as well as the two original dimension groups of the rows and columns.

Creating the Cross Product GroupIf you enhance the existing Data Model to include an additional level of nesting, the existing cross product group does not recognize any newly created group. You must create the cross product group after you create all the groups that you want in the nested matrix.

How to Recreate the Cross Product Group1 Delete the existing cross product group.

Note: The cross product summaries are automatically deleted.

2 Create the new groups that you need.

3 Recreate the cross product group. Use the cross product tool (AxB) to click and drag a region surrounding the break groups and the two dimension groups (rows and columns).

4 Use the reenterable wizard to recreate the summaries.

Differences Between a Nested Matrix and a Matrix with Group• Matrix with Group Data Model: The cross product group is the child of a parent

break group at a level above and outside the cross product.

• Nested Matrix Data Model: The cross product contains three or more groups: one or more levels of break group and two dimensional groups to form rows and columns.

Note: You can mix these styles. That is, you can create a Matrix with Group report where the matrix has several nested levels within it.

Page 24: Oracle Developer: Build Reports

14-12 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Nested Matrix Layout

Page 25: Oracle Developer: Build Reports

Oracle Developer: Build Reports 14-13......................................................................................................................................................

......................................................................................................................................................Building a Nested Matrix

What Is in the Nested Matrix Layout Model?The wizard creates the same objects as for a simple matrix structure. It also creates the following objects:

• One repeating frame for each additional break group, nested within the same overall matrix structure

• One matrix object for each additional break group

The exact appearance depends on whether the extra level is in the Row or in the Column tab. The diagram opposite shows nested rows.

In the Object Navigator, you can see the matrix structure in the Dimension and Frequency nodes. These nodes exist only if there is a matrix. You do not see a node for the matrix object name, but it does have properties. You can open the property palette in the Layout Model only.

Creating a Matrix ObjectWhen possible, use the wizard to create your matrix reports, since the layout consists of many layers and interdependent objects.

If you resize the repeating frames, take care to maintain the intersection between them, otherwise you might destroy the matrix object. Report Builder gives you a warning message if this is likely to happen.

If you destroy the matrix object, or want to create the matrix structure yourself, you must recreate the matrix object. Each matrix object intersects and determines the relationship between two and only two repeating frames.

How to Create the Matrix Object1 Make sure that the two related repeating frames intersect each other correctly.

2 Select both repeating frames (Shift-Select).

Note: if you do not select both frames, you receive an error message:REP-3100: Matrix must include at least 1 Down and 1 Across repeating frame.

3 Choose Insert—>Layout Matrix.

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

Page 26: Oracle Developer: Build Reports

14-14 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Creating Matrix Summaries

F_SumSALARY F_SumSALPerDEPT

F_SumSALPerTITLE

F_Sum_REG_NAME

Page 27: Oracle Developer: Build Reports

Oracle Developer: Build Reports 14-15......................................................................................................................................................

......................................................................................................................................................Building a Nested Matrix

Creating Nested Matrix SummariesThe wizard creates nested summaries in the cross product group.

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

Setting the Product OrderRemember, the Product Order indicates the way in which Report Builder evaluates a summary. Product Order also determines the position (frequency) of the summary if you use the reenterable wizard.

The diagram opposite shows three summary fields created by the wizard:

• F_SumSALperTITLE: Total salary for each column of job title. Displayed once for each title.

• F_SumSALperDEPT: Total salary for each department row nested within a specific region row. Displayed once for each combination of region/department.

• F_SumSALARY: The cell value. Displayed once for each combination of region/department/title.

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.

Field Name Reset At Product Order

F_SumSALPerTITLE G_TITLE G_TITLE

F_SumSALPerDEPT G_DEPT_NAME G_DEPT_NAME

F_SumSALARY G_DEPT_NAME G_REG_NAME G_TITLE G_DEPT_NAME

Field Name Reset At Product Order

F_Sum_REG_NAME G_REG_NAME G_REG_NAME

Page 28: Oracle Developer: Build Reports

14-16 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Displaying Zeros

Page 29: Oracle Developer: Build Reports

Oracle Developer: Build Reports 14-17......................................................................................................................................................

......................................................................................................................................................Building a Nested Matrix

Displaying Zeros in Cells with No ValueThe field that displays each cell of the matrix is sourced to a summary column, such as SumSalary.

If there is no value for a particular row/column combination, the summary column is null and therefore the cells displayed as a blank field.

You can very simply change the blank to zero or any default value you choose.

To display zeros, open the property palette for either the cell field or the SumSalary summary column and set the Value if Null property to zero.

Page 30: Oracle Developer: Build Reports

14-18 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Summary

• Create matrix with the wizard

• Consider creating or modifying atemplate with extra spacing

• Data and layout reflect cross productstructure

• Matrix-specific:

– Cross Product group

– Product Order property

– Matrix layout object

Page 31: Oracle Developer: Build Reports

Oracle Developer: Build Reports 14-19......................................................................................................................................................

......................................................................................................................................................Summary

Summary

Let the Wizard and Template Work for YouUse 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 StructureThe Data Model and Layout Model of a matrix report contain special features, and relationships between objects, to reflect the cross product structure of the report.

Matrix-Specific Objects and PropertiesMatrix reports include special objects, and properties:

• Data Model: Cross Product group; Product Order property

• Layout Model: Matrix object

Page 32: Oracle Developer: Build Reports

14-20 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Practice 14 Overview

• Opening and changing an existingmatrix report

• Building a nested matrix report

• Adding summaries to the nested matrixreport

• Displaying zeros for summary valuesand restricting columns per page

• Displaying more meaningful columninformation and rotating the text

Page 33: Oracle Developer: Build Reports

Oracle Developer: Build Reports 14-21......................................................................................................................................................

......................................................................................................................................................Practice Session Overview: Lesson 14

Practice Session Overview: Lesson 14 This practice session contains:

• Opening and changing an existing matrix report

• Building a nested matrix report

• Adding summaries to the nested matrix report

• Displaying zeros for summary values and restricting the number of columns per page

• Displaying more meaningful column information and rotating the text

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

Page 34: Oracle Developer: Build Reports

14-22 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session: Lesson 141 Open report p4q6.rdf.

a Use the Report wizard to apply a template file to the report. The file corpmat.tdf should be located in your working directory. The new template gives you spaces between the layout objects to make it easier to see the different objects in the Layout editor.

b How many repeating frames do you have?

c Change the properties of the cell object to display zero for a null value.

d Run and test the report.

e Close the report without saving it.

2 Create a new report, importing the external query p4q6.sql from your working directory.

a Choose the following settings:

Report Style Matrix

Query (Import file p4q6.sql)

Matrix Row Fields Level 1 - Month

Level 2 - Name

Matrix Column Fields Product_id

Matrix Cell Fields Sum of total_value

Matrix Totals Sum of the cell field

Page 35: Oracle Developer: Build Reports

Oracle Developer: Build Reports 14-23......................................................................................................................................................

......................................................................................................................................................Practice Session: Lesson 14

b Change the labels and widths for the following fields:

c Run the report.

d Which summaries were created?

e Use the Data Model editor to create summaries for each month and for the level month and product.

f Use the Layout editor to create the fields. You will have to expand the appropriate repeating frame.

g Run and test the report.

h Save the report as p14q2.rdf. Do not close it.

3 Continue with the report from the previous exercise.

a Add zeros for null values in the cells.

b Make sure that the report shows only three product columns on each page.

c Format all numeric data to be right aligned.

d Add commas and two decimal places where appropriate.

e Run and test the report.

f Save the report as p14q3.rdf, and close it.

Field Label Width

NAME Customer 10

PRODUCT_ID Product 5

MONTH Month 4

SUMTOTALVALUE Total 5

All Summaries Total: 5

Page 36: Oracle Developer: Build Reports

14-24 Oracle Developer: Build Reports......................................................................................................................................................

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

If You Have Time4 Open the report as p14q3.rdf.

a Make the necessary changes in the Data Model editor to include the product name.

b In the Layout Model editor delete the product_id field and insert a boilerplate object to display the product name. Rotate this object by 90 degrees.

c Run and test the report.

d Save the report as p14q4.rdf and close it.

Page 37: Oracle Developer: Build Reports

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

15

Coding PL/SQL Triggersin Reports

Page 38: Oracle Developer: Build Reports

15-2 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Objectives

At the end of this lesson, you should beable to do the following:

• Describe the different types of triggers

• Describe sample uses of triggers

• Write and reference common code

• Create a PL/SQL library

Page 39: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-3......................................................................................................................................................

......................................................................................................................................................Overview

Overview

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

ObjectivesAt 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

Page 40: Oracle Developer: Build Reports

15-4 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Types of Triggers in Reports

Report:

• Five triggers

• Report Trigger node in Object Navigator

Data Model:

• Formula (column)

• Filter (group)

• Parameter validation

Layout:

Format trigger on most objects

Copyright Oracle Corporation, 1999. All rights reserved.

Trigger Code

Character

Number

Date

Column

Number

ParameterBoolean:

truefalse

boolean

Page 41: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-5......................................................................................................................................................

......................................................................................................................................................Types of Triggers in Reports

Types of Triggers in Reports

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

The Three Trigger Types• Report:

- A set of five report-level triggers. Each trigger fires at a different stage of the report execution.

- Access report triggers from the Report Triggers node in the Object Navigator.

• Data Model:

- Column formula fires each time the column is processed.

- Group filter fires for each record in the group.

- Parameter validation fires when the run-time parameter form is displayed and when the user leaves the parameter field.

- Access data model triggers in the property palette of a data model object—column, group, or parameter—or the corresponding layout object—field, repeating frame, or parameter field.

• Layout:

- Format triggers on most layout objects (excluding anchors). Each trigger fires as the layout object is processed.

- Access format triggers in the property palette of a layout object.

Note: Report Builder does not allow data manipulation language (DML) commands—INSERT, DELETE, UPDATE—in layout format triggers.

Trigger CodeWhen 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.

Page 42: Oracle Developer: Build Reports

15-6 Oracle Developer: Build Reports......................................................................................................................................................

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

1 If After Parameter Form returns FALSE, the cursor returns to the run-time parameter form. If the run-time parameter form is not displayed, control returns to the calling program.

2 If READONLY=Yes, Report Builder implicitly sets the read-only transaction (SET TRANSACTION READONLY) after the Before Report Trigger fires.

3 If READONLY=Yes, Report Builder implicitly ends the read-only transaction (COMMIT) after the final page and before the After Report Trigger fires.

Copyright Oracle Corporation, 1999. All rights reserved.

Using Report Triggers

AfterParameter

Form

F

BeforeReport

1

BeforeParameter

Form

page1 BetweenPages

page2

if > 1 page

AfterReport

if readonly=yes2 3

F

F F

Page 43: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-7......................................................................................................................................................

......................................................................................................................................................Using Report Triggers

Using Report Triggers

IntroductionReport triggers enable you to execute PL/SQL functions at specific times during the execution and formatting of your report. These triggers enable you to:

• Customize the formatting of your report

• Perform initialization tasks

• Access the database

Report triggers must return a boolean value—true or false.

Accessing the Report TriggersYou can access the report triggers from the Object Navigator. Open the Report Triggers node and double-click on the object icon of the required trigger to open the program unit.

Trigger Fires Use toBefore Parameter Form

Before run-time parameter form is displayed; fires even if parameter form is suppressed

Access and change parameter values (initial or command line), global variables; create temporary tables; insert into tables to be queried

After Parameter Form

After run-time parameter form is displayed; fires even if parameter form is suppressed

Access and change parameter values (initial, command line, or user-entered); create temporary tables; insert into tables to be queried

Before Report Before a report executes: after queries are parsed, but before records are fetched

Carry out initialization procedures

Between Pages Before each page is formatted, except the first page; in Previewer, fires only once for each page, even if you revisit the page

Carry out customized page formatting; insert or update values in tables

After Report After you exit the Previewer, or after report output is sent to its destination; fires on success only

Clean up initial processing, such as deleting temporary tables

Page 44: Oracle Developer: Build Reports

15-8 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Using Report TriggersAfter Parameter Form

• Example: build dynamic WHERE clauseFUNCTION AfterPForm RETURN BOOLEAN ISBEGINIF :p_customer IS NULL THEN

:p_where_clause := ’’;ELSE

:p_where_clause := ’where id >= :p_customer’;END IF;RETURN(TRUE);END;

• Query syntax:SELECT ID, NAMEFROM CUSTOMER

ORDER BY NAME

SELECT ID, NAMEFROM CUSTOMER

ORDER BY NAME&p_where_clause

Page 45: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-9......................................................................................................................................................

......................................................................................................................................................Using Report Triggers

Creating a Dynamic WHERE ClauseUse the After Parameter Form report trigger to build a dynamic WHERE clause depending on the value of a bind parameter that the user enters at run time.

There are two possibilities at run time:

• The bind parameter is NOT NULL:

The WHERE clause restricts the query; therefore the Oracle server makes use of an existing index when retrieving data.

• The bind parameter is NULL:

The WHERE clause is also NULL; therefore the Oracle server uses a full table scan to retrieve all records.

Page 46: Oracle Developer: Build Reports

15-10 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Using Data Model TriggersGroup Filter

• Restrict records in a group

• Perform PL/SQL for each recordFUNCTION G_empGroupFilter RETURN BOOLEAN ISBEGINIF :name = ’Operations’ AND :salary > 3000 THEN

RETURN(my_function);ELSE

RETURN(TRUE);END IF;END;

• PL/SQL filters result in ALL recordsbeing fetched

Page 47: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-11......................................................................................................................................................

......................................................................................................................................................Using Data Model Triggers

Using Data Model Triggers

IntroductionThis section gives examples of:

• Using a PL/SQL group filter

• Validating a parameter value

Using a PL/SQL Group FilterUse a group filter when you want to do the following:

• Restrict records in a specific group, depending on other processing in the report; that is, when a WHERE clause in a query is not applicable

• Perform some PL/SQL processing for each record in a group

A group filter is useful when you want to restrict group values of a lower group in the group hierarchy.

The function must return a boolean value:

• True: the record is included

• False: the record is excluded

Report Builder fetches all records and applies the group filter to each record. Therefore avoid group filters as a method of restricting many records in a group.

Note: You cannot add a filter to a matrix cross product group.

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

Page 48: Oracle Developer: Build Reports

15-12 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Using Data Model Triggers

• You cannot reassign values toparameters or columns in this trigger

FUNCTION DESTYPEValidTrigger RETURN BOOLEAN ISBEGINIF :DESTYPE = ’Printer’ THEN

RETURN(FALSE);ELSE

RETURN(TRUE);END IF;END;

Parameter Validation

• Example: do not allow report output tobe sent directly to a printer

Page 49: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-13......................................................................................................................................................

......................................................................................................................................................Using Data Model Triggers

Validating a Parameter ValueBoth system parameters and user parameters have a Validation Trigger property, in which you can write a PL/SQL function to validate the value of the parameter.

The trigger code must return a boolean value—true or false—depending on whether the validation is successful or not.

If the returned value is false, the cursor remains in the parameter and the user has the following two options:

• Enter a different value

• Cancel the report

You can test the value of a parameter, but you cannot change the value. If you want to assign a new value to the parameter, use the After Parameter Form report trigger.

Example To prevent report output 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.

Page 50: Oracle Developer: Build Reports

15-14 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Using Layout Triggers

Format triggers:

• Exist on most layout objects

• Can suppress an entire layout section(master group frame): no recordsfetched

• Can suppress the display of individualrecords (repeating frame): all recordsfetched

Page 51: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-15......................................................................................................................................................

......................................................................................................................................................Using Layout Model Triggers

Using Layout Model Triggers

IntroductionMost layout objects contain a format trigger; it is one of the common properties of a layout object.

Format triggers enable you to modify the display of objects dynamically at run time or to suppress display altogether.

The trigger must return a boolean value—true or false.

The following pages discuss some examples of format triggers.

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

Suppressing Individual RecordsDo not use format triggers to suppress individual records that you can restrict on the Data Model. For example, a format trigger on a repeating frame does not prevent data from being retrieved, it simply determines whether or not you see it in the output.

Therefore it is more efficient to restrict individual records using the Maximum Records property in a query or a First type of group filter when possible.

Note: Summaries compute against all data fetched by the Data Model. If you suppress records in the layout only, summaries give misleading results.

Page 52: Oracle Developer: Build Reports

15-16 Oracle Developer: Build Reports......................................................................................................................................................

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

1 Boilerplate text: Position behind column heading frame, or position below and create collapsible anchor to column heading

2 Column heading frame does not display; Suppressed by format trigger

Copyright Oracle Corporation, 1999. All rights reserved.

Displaying a Text String in Placeof Column Headings

Dept: f_deptno

No employees inthis department1

Name Salary

Name Salary

Dept: 10

Dept: 40

No employees inthis department

2

Page 53: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-17......................................................................................................................................................

......................................................................................................................................................Using Layout Model Triggers

Coding a Format Trigger on a Frame

Requirement: Display a Text String In Place of Column Headings Display a master-detail report for departments and employees. If a department has no employees, suppress the detail column heading frame and display a piece of text instead.

Example1 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 isbegin

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.

Page 54: Oracle Developer: Build Reports

15-18 Oracle Developer: Build Reports......................................................................................................................................................

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

1 One repeating frame is positioned behind the other or positioned below with collapsing anchor

2 Report output run by payment clerks

3 Report output run by other employees

Copyright Oracle Corporation, 1999. All rights reserved.

Employee Details

1

Dynamically Altering the Displayof Records

f_name f_date f_salary

f_name f_date

Ngao 08-MAR-90 2500

Biri 07-APR-91 1100

Employee Details

Magee 14-MAY-90 1000

2

Ngao 08-MAR-90

Biri 07-APR-91

Employee Details

Magee 14-MAY-90

3

Page 55: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-19......................................................................................................................................................

......................................................................................................................................................Using Layout Model Triggers

Coding a Format Trigger on a Repeating Frame

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

Example1 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 isbegin

if :user_type = ’PAY_CLERK’ thenreturn(true);

elsereturn(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.

Page 56: Oracle Developer: Build Reports

15-20 Oracle Developer: Build Reports......................................................................................................................................................

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

1 Report for payment clerks shows all fields

2 Report for other employees shows gap where salary is hidden

Copyright Oracle Corporation, 1999. All rights reserved.

Dynamically Hiding Fields

Employee Details

f_name f_date f_salaryNgao 08-MAR-90 2500

Biri 07-APR-91 1100

Employee Details

Magee 14-MAY-90 1000

1

Ngao 08-MAR-90

Biri 07-APR-91

Employee Details

Magee14-MAY-90

2

Page 57: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-21......................................................................................................................................................

......................................................................................................................................................Using Layout Model Triggers

Format Trigger on a Field

Requirement: Dynamically Hide Fields Given the same employee details report as before, hide the salary field without rearranging the other fields in the repeating frame. The report contains a gap in the layout when the salary field is not displayed.

Example Place the format trigger on the salary field to display it only when payment clerks run the report. The code is the same as before:

function pay_clerks_see_this return boolean isbegin

if :user_type = ’PAY_CLERK’ thenreturn(true);

elsereturn(false);

end if;

end;

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

Page 58: Oracle Developer: Build Reports

15-22 Oracle Developer: Build Reports......................................................................................................................................................

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

1 Format Trigger on F_Address2 field references the column ADDRESS2

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

Copyright Oracle Corporation, 1999. All rights reserved.

f_name

f_address1

f_address2

f_address3

f_address4

Dear Sir,

We are writing to advise ................

Suppressing Null Fields in aLetter Heading

FUNCTION label_field RETURN BOOLEAN ISBEGINIF :address2 IS NULL THEN

RETURN(FALSE);ELSE

RETURN(TRUE);END IF;END;

FUNCTION label_field RETURN BOOLEAN ISBEGINIF :address2 IS NULL THEN

RETURN(FALSE);ELSE

RETURN(TRUE);END IF;END;

1

2

Page 59: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-23......................................................................................................................................................

......................................................................................................................................................Using Layout Model Triggers

Coding a Format Trigger on a Field

Requirement: Suppress Null Fields in an Address The letter opposite includes a customer address. Address lines in a database often have optional fields to provide for a variable number of lines in an address.

You want to suppress fields that are NULL, so that the address does not contain large spaces between existing lines.

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

Page 60: Oracle Developer: Build Reports

15-24 Oracle Developer: Build Reports......................................................................................................................................................

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

1 Transparent rectangle 3 Summary column name (created in Data Model)

2 Repeating Frame, Vertical Elasticity = Variable

4 Format trigger on transparent rectangle

Copyright Oracle Corporation, 1999. All rights reserved.

f_1 f_2 f_3

Inserting Spacing BetweenGroups of Records

1 2

FUNCTION spacing RETURN BOOLEAN ISBEGINIF MOD(:count_column, 3) = 0 THEN

RETURN(TRUE);ELSE

RETURN(FALSE);END IF;END;

FUNCTION spacing RETURN BOOLEAN ISBEGINIF MOD(:count_column, 3) = 0 THEN

RETURN(TRUE);ELSE

RETURN(FALSE);END IF;END;

3 4

Page 61: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-25......................................................................................................................................................

......................................................................................................................................................Using Layout Model Triggers

Coding a Format Trigger on a Boilerplate Object

Requirement: Insert Spacing Between Groups of Records Display additional spacing between a defined number of records; for example, group every three records together.

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

Page 62: Oracle Developer: Build Reports

15-26 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Writing Common Code

At Report level

• Object Navigator, Program Units

• Menu: Tools—>PL/SQL Editor

In a library

• Object Navigator, PL/SQL Library

• File—>New: create new library

• File—>Open: add to existing library

• Attach library to report

Page 63: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-27......................................................................................................................................................

......................................................................................................................................................Writing Common Code

Writing Common Code

IntroductionIf you use the same program unit in several places in a report, or in multiple reports, consider writing the code once as a report-level program unit, or in a PL/SQL library, and then call the program unit when you require it in your PL/SQL trigger code; this enables you to maintain the code in one place.

Even if you do not use the code many times, consider writing anything other than very simple PL/SQL blocks at report level, to simplify maintenance.

Remember that you can also code stored procedures and functions in the database; you must decide whether server-side or client-side processing is more efficient in each case.

Two Ways to Create Report-Level Program Units• In the Object Navigator, select the Program Units node and create a new

program unit.

• From the menu, select Program—>PL/SQL Editor. Choose New to create a new program unit.

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

Three Ways to Create Library Program Units• In the Object Navigator, select the PL/SQL Libraries node and create a new

library.

• From the menu, select File—>New—>PL/SQL Library.

• From the menu, select File—>Open to open an existing library and create additional program units.

Referencing Code from a PL/SQL LibraryYou can reference library code in a report trigger by attaching one or more libraries to one or more report definitions, which enables you to reference the same code in multiple reports.

To attach a library to a report, open the report definition, select the Attached Libraries node in the Object Navigator, and add each library that you need in the report.

Page 64: Oracle Developer: Build Reports

15-28 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

SummaryTrigger 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

Page 65: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-29......................................................................................................................................................

......................................................................................................................................................Summary

Summary

Using PL/SQL TriggersChoose 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.

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

Objects That Must Return a ValueThe following table is a reminder of the Report Builder triggers that must always return a value, and it shows the values that are acceptable.

Trigger Type Valid Values Result if False

Report trigger True, False Abort execution

Group filter True, False Do not process record

Validation trigger True, False Return to parameter form

Format trigger True, False Do not format object

PL/SQL Formula (column) Computation: Character, Number, Date

N/A

Page 66: Oracle Developer: Build Reports

15-30 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Practice 15 Overview

• Creating a format trigger to displaydifferent layouts conditionally

• Creating and using a report-levelPL/SQL function

• Creating and using an external PL/SQLlibrary

• Creating a PL/SQL group filter

Page 67: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-31......................................................................................................................................................

......................................................................................................................................................Practice Session Overview: Lesson 15

Practice Session Overview: Lesson 15 This practice session contains:

• Creating a format trigger to display different layouts conditionally

• Creating and using a report-level PL/SQL function

• Creating and using an external PL/SQL library

• Creating a PL/SQL group filter

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

Page 68: Oracle Developer: Build Reports

15-32 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session: Lesson 151 Create a new report, using p15q1.sql.

a Display the records in two different layouts, showing different columns in each.

b Create a Group Above layout using the following columns from the query:

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

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.

Group Column

G_CUSTOMER CUSTOMER_ID

G_ID ID

DATE_ORDERED

DATE_SHIPPED

PAYMENT_TYPE

TOTAL

Column

ID

DATE_ORDERED

DATE_SHIPPED

TOTAL

Page 69: Oracle Developer: Build Reports

Oracle Developer: Build Reports 15-33......................................................................................................................................................

......................................................................................................................................................Practice Session: Lesson 15

2 Continue with the previous report.

a Modify the report so that the Tabular (Preview) layout displays an extra column that indicates, with an asterisk, those orders that were shipped more than 15 days after the order date.

b Remember to change destination to Preview during testing.

c Move the function code into a new PL/SQL library, named p15lib.pll.

d Call the external function from your report, instead of calling the report-level function.

e Save the report to p15q2.rdf.

3 Continue with the previous report.

a Modify the same layout to display additional spacing between every two records.

b Save the report as p15q3.rdf and close it.

If You Have Time4 Open report p15q1.rdf.

a Write your own group filter to restrict the number of customers displayed depending on the value of a parameter that you enter at run time.

Hint: You need to create two parameters to keep track of how many records have been processed compared to the cutoff number of records required.

b Test the report several times by changing the cutoff parameter at run time.

c Save the report as p15q4.rdf.

Page 70: Oracle Developer: Build Reports

15-34 Oracle Developer: Build Reports......................................................................................................................................................

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

Page 71: Oracle Developer: Build Reports

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

16

Using the Report BuilderBuilt-In Package

Page 72: Oracle Developer: Build Reports

16-2 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Objectives

At the end of this lesson, you should beable to do the following:

• Describe the package contents

• Output messages at run time

• Execute a drill-down report

• Create and populate temporary tables

• Modify visual attributes dynamically

Page 73: Oracle Developer: Build Reports

Oracle Developer: Build Reports 16-3......................................................................................................................................................

......................................................................................................................................................Overview

Overview

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

ObjectivesAt 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

Page 74: Oracle Developer: Build Reports

16-4 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Contents of the SRW Package

SRW.BREAKSRW.SET_ATTR

SRW.DO_SQLSRW.RUN_REPORT

SRW.REFERENCESRW.USER_EXITSRW.SET_MAXROW

SRW.MESSAGESRW.TRACE

SRW.PROGRAM_ABORT

Page 75: Oracle Developer: Build Reports

Oracle Developer: Build Reports 16-5......................................................................................................................................................

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

Contents of the Report Builder Built-in Package

IntroductionThe Report Builder built-in package, known as the SRW package, contains procedures, functions, and exceptions that can help you to do the following:

• Control report execution

• Output messages at run time

• Initialize layout fields

• Perform DDL statements (create or drop temporary tables)

• Call user exits

• Dynamically set format attributes, such as font style and fill patterns

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

Rules

• You can only call the contents of the SRW package from within Report Builder. Other tools, such as Form Builder, do not recognize this package.

• You must always reference an SRW procedure, function, or exception by preceding it with the package name, SRW; for example, SRW.MESSAGE, SRW.DO_SQL.

Page 76: Oracle Developer: Build Reports

16-6 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Outputting MessagesWarningWHEN <exception> THEN SRW.MESSAGE(999, ’Warning: report continues’);

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

ErrorWHEN <exception> THEN SRW.MESSAGE(999, ’Error: report terminated’);

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

ExceptionsSRW.INTEGER_ERRORSRW.NULL_ARGUMENTS

SRW.INTEGER_ERRORSRW.NULL_ARGUMENTS

Page 77: Oracle Developer: Build Reports

Oracle Developer: Build Reports 16-7......................................................................................................................................................

......................................................................................................................................................Outputting Messages

Outputting Messages

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

Message Code and TextYou can enter a code number from zero up to 10 digits. If you enter a number of fewer than five digits, the code is displayed with leading zeros.

You can enter a text string to a maximum of 190 characters, excluding the code number. You can embed extra spaces to display your message neatly in the message dialog box. Reports does not suppress extra spaces in the message text.

Is It a Warning or an Error?SRW.MESSAGE does not implicitly terminate the report execution. You can choose to issue a warning message that enables the report to continue execution after the user accepts the message.

To force the report to terminate after outputting the message, raise the exception SRW.PROGRAM_ABORT.

Note: You cannot suppress or replace the default message that Report Builder gives if you abort a report. Your own error message augments the existing messages.

Causes of Exceptions

Exception Name CauseSRW.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.

Page 78: Oracle Developer: Build Reports

16-8 Oracle Developer: Build Reports......................................................................................................................................................

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

1 Output from master output

2 Output from detailed report

Copyright Oracle Corporation, 1999. All rights reserved.

Executing a Report

BLOGGS

SMITH

JONES

BLOGGS.LIS

xxx xxxxxxxxxx xxxxxxx

2

SRW.RUN_REPORT

SMITH.LIS

yyy yyyyyyyyyy yyyyyyy

JONES.LIS

zzz zzzzzzzzzz zzzzzzz

1

Page 79: Oracle Developer: Build Reports

Oracle Developer: Build Reports 16-9......................................................................................................................................................

......................................................................................................................................................Executing a Nested Report

Executing a Nested Report

IntroductionUse SRW.RUN_REPORT to execute a second report from within a report process. For example:

• Output parts of a report to different destinations

• Divide a large report into several smaller reports that can be run conditionally

Both Reports Use the Same ProcessSRW.RUN_REPORT starts only one run-time process; it does not start a new process for each report execution.

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

Page 80: Oracle Developer: Build Reports

16-10 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Executing a ReportExampleSRW.RUN_REPORT

(’Report=EMPSDESTYPE=FILEDESNAME=’||:LAST_NAME||’.LISBATCH=YESMGRNO=’||TO_CHAR(:ID));

SRW.RUN_REPORT_FAILURESRW.RUN_REPORT_BATCHNO

SRW.RUN_REPORT_FAILURESRW.RUN_REPORT_BATCHNO

SRW.GETERR_RUNSRW.GETERR_RUN

Exceptions

Function

Page 81: Oracle Developer: Build Reports

Oracle Developer: Build Reports 16-11......................................................................................................................................................

......................................................................................................................................................Executing a Nested Report

Example Function Code

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

Causes of ExceptionsReport Builder raises a specific exception that applies to the SRW.RUN_REPORT procedure in two cases:

Displaying Report Failure MessageIf the detail report fails during execution, you can display information about the cause by using the SRW.GETERR_RUN function.

Assign the function to a local PL/SQL character variable, which you display using the SRW.MESSAGE procedure.

...

msg char(150);...EXCEPTION

WHEN SRW.RUN_REPORT_FAILURE THEN msg := SRW.GETERR_RUN; SRW.MESSAGE (100, msg);

...

FUNCTION MGR_REP RETURN BOOLEAN IS

BEGINSRW.RUN_REPORT

(’REPORT=EMPS DESTYPE=FILEDESNAME=’||:LAST_NAME||’.LISBATCH=YESMGRNO=’||TO_CHAR(:ID));

RETURN(TRUE);EXCEPTIONWHEN SRW.RUN_REPORT_FAILURE THEN

SRW.MESSAGE(100, ’Error executing EMPS report’); RAISE SRW.PROGRAM_ABORT;END;

Exception Name CausesSRW.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.

Page 82: Oracle Developer: Build Reports

16-12 Oracle Developer: Build Reports......................................................................................................................................................

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

1 Output from master output

2 Output from detailed report

Copyright Oracle Corporation, 1999. All rights reserved.

Executing a Drill-Down Report

Details

Details

SRW.RUN_REPORT

2

42

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

1

41

42

43

Details

Page 83: Oracle Developer: Build Reports

Oracle Developer: Build Reports 16-13......................................................................................................................................................

......................................................................................................................................................Executing a Nested Report

Calling a Drill-Down ReportYou can call the SRW.RUN_REPORT procedure from a button in your master report and display the detail report in a second previewer window on the screen.

How to Create a Drill-Down Report1 Create a button in the master report within the repeating frame.

2 Display the button property palette. Under the Button Behavior node, change the Type property to PL/SQL, then select the PL/SQL Trigger property to display the Program Unit editor.

3 Enter the function as described in the previous example. Do not include the BATCH parameter, since you want to display the detail report interactively in a second previewer.

4 Compile and close the Program Unit editor.

5 Run the master report.

For reports that you send to a file, do not include the pathname when coding the DESNAME parameter. Allow the REPORTS60_PATH variable to search the correct path for the report.

Testing Drill-Down Reports During DevelopmentTo test a drill-down report, use the Reports Runtime. Remember that buttons are not active in the Report Builder Live Previewer.

Page 84: Oracle Developer: Build Reports

16-14 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Restricting Data

Before Report triggerSRW.SET_MAXROW(’Q_EMP’,3);

Q_EMP

G_EMP

IDLAST_NAME

ID LAST_NAME

1 BLOGGS2 SMITH3 JONES

Page 85: Oracle Developer: Build Reports

Oracle Developer: Build Reports 16-15......................................................................................................................................................

......................................................................................................................................................Restricting Data

Restricting Data

IntroductionUse 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 QueryAt 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.

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

Page 86: Oracle Developer: Build Reports

16-16 Oracle Developer: Build Reports......................................................................................................................................................

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

1 Create format trigger on f_newpage field

2 Set field value to my_page+3

Copyright Oracle Corporation, 1999. All rights reserved.

Initializing Fields

Page: F_NEWPAGE

Layout editor

FUNCTION F_LOGICAL_PAGEFormatTrigger RETURN BOOLEAN IS

my_page number;BEGIN

SRW.GET_PAGE_NUM(my_page);SRW.SET_FIELD_NUM(0,my_page+3);RETURN(TRUE);

END;

FUNCTION F_LOGICAL_PAGEFormatTrigger RETURN BOOLEAN IS

my_page number;BEGIN

SRW.GET_PAGE_NUM(my_page);SRW.SET_FIELD_NUM(0,my_page+3);RETURN(TRUE);

END;

1

Output: logicalpage no. = 2

Page: 5

2

Page 87: Oracle Developer: Build Reports

Oracle Developer: Build Reports 16-17......................................................................................................................................................

......................................................................................................................................................Initializing Fields

Initializing FieldsYou 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.

Why Use SRW.SET_FIELD?You might want to retrieve the current logical page number and recalculate the value before displaying it.

Example Create a function to display the logical page number + 3 in a field called F_NEWPAGE.

Because the logical page number variable is 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.

Page 88: Oracle Developer: Build Reports

16-18 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Performing DDL StatementsExampleSRW.DO_SQL(’CREATE TABLE SRW_LOG

(RPT_NAME VARCHAR2(40),REC_NUM NUMBER,MSG_TEXT VARCHAR2(80))’);

SRW.DO_SQL(’INSERT INTO SRW_LOG(RPT_NAME, REC_NUM, MSG_TEXT)VALUES(’’PAY_REPORT’’, TO_CHAR(:ID),

:LAST_NAME||’’PAY REPORT RUN’’)’);

SRW.DO_SQL_FAILURESRW.DO_SQL_FAILURE

Exception

Page 89: Oracle Developer: Build Reports

Oracle Developer: Build Reports 16-19......................................................................................................................................................

......................................................................................................................................................Performing DDL Statements

Performing DDL Statements

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

Why Use SRW.DO_SQL?Use SRW.DO_SQL to perform DDL statements dynamically, during run time. For example, create a temporary table and insert rows into it during execution.

You can also perform DML statements using this procedure, but DML statements run faster if you code them directly within a PL/SQL block. Code DML statements in the SRW.DO_SQL procedure only if necessary. For example:

• To insert records into a permanent table in the database, code DML in a PL/SQL block.

• To insert records into a temporary table that does not exist until run time, code DML in SRW.DO_SQL.

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

Page 90: Oracle Developer: Build Reports

16-20 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Setting Format Attributes

Tuesday, 01 Sep

Car Policy

borderwidth

fill pattern

format mask

printer tray control

define a bookmark

Page 91: Oracle Developer: Build Reports

Oracle Developer: Build Reports 16-21......................................................................................................................................................

......................................................................................................................................................Setting Format Attributes

Setting Format Attributes

IntroductionThe SRW.SET_<attributes> packaged procedures apply specified format attributes to the current layout object: frame, repeating frame, field, or boilerplate object.

Why Use a Format Attribute?Some of the reasons that you would want to use format attributes are:

• To change the visual appearance of layout objects conditionally, depending on values in a repeating frame, or on run-time parameter values

• To switch to different printer trays as your report formats

• To place a logo or standard links in an HTML document

• To define a bookmark in an HTML or PDF document

Coding a Format AttributeYou can code the packaged procedure in a function as a local or report-level program unit, or in a PL/SQL library. This is useful if you want a common format attribute in more than one object or more than one report. You can then call the function whenever required, from the format trigger of a specific object.

As an alternative to a PL/SQL library, in the Object Navigator you can drag and drop report-level program units between different reports. However, note that this creates a copy of the program unit in each report, rather than a reference to one piece of code.

Page 92: Oracle Developer: Build Reports

16-22 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Setting Format Attributes

Visual attributes

SRW.SET_FILL_PATTERN(’solid’);SRW.SET_BORDER_WIDTH(250);SRW.SET_FORMAT_MASK(’Day, Month yyyy’);

SRW.SET_PRINTRER_TRAY(’letterhead’);SRW.SET_PRINTRER_TRAY(’letterhead’);

SRW.SET_BOOKMARK(’Car Policy’);SRW.SET_BOOKMARK(’Car Policy’);

Printer tray control

Define a bookmark

Page 93: Oracle Developer: Build Reports

Oracle Developer: Build Reports 16-23......................................................................................................................................................

......................................................................................................................................................Setting Format Attributes

ExampleConditionally set the following attributes if salary equals 2000:

FUNCTION SAL_MASK RETURN BOOLEAN IS

BEGINIF :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;

Using Format Attributes in Character-Mode ReportsSome attributes are applicable to character environments only; some are for bitmapped environments only.

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

Attribute ValueBackground fill color Dark yellowFill pattern SandpaperFont style ItalicFont face HelveticaFont weight Extra boldText color Dark blue

Page 94: Oracle Developer: Build Reports

16-24 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Summary

Package contents

• Procedures

• Functions

• Exceptions:

SRW.PROGRAM_ABORT to exit

Examples

• Drill-down report

• Support for DDL statements

• Conditional layout formatting and display

Page 95: Oracle Developer: Build Reports

Oracle Developer: Build Reports 16-25......................................................................................................................................................

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

Page 96: Oracle Developer: Build Reports

16-26 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Practice 16 Overview

• Building a report containing conditionalhighlighting

• Building a drill-down report

• Writing to a temporary table from areport

Page 97: Oracle Developer: Build Reports

Oracle Developer: Build Reports 16-27......................................................................................................................................................

......................................................................................................................................................Practice Session Overview: Lesson 16

Practice Session Overview: Lesson 16This practice session contains:

• Building a report containing conditional highlighting

• Building a drill-down report

• Writing to a temporary table from a report

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

Page 98: Oracle Developer: Build Reports

16-28 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session: Lesson 161 Open report p8q5.rdf.

a Display the column CUST_TOTAL in the customer group as red bold italics if its value is 10,000 or more.Hint: Check the help system for the SRW.SET_<attributes> or use conditional formatting:

You can import the file p16q1a.txt.

b Alter the pattern and color of those records where the customer total is 5000 or less. Hint: Check the help system for the SRW.SET <attributes> or use conditional formatting.

You can import the file p16q1b.txt.

c Write the necessary format triggers.

d Save the report as p16q1.rdf.

2 Call a drill-down report using a button.

a Continue with the previous report.

b Alter query Q_2 to include the customer ID, but do not display it in the report.

c Add a button to this report to display a drill-down report when the button is chosen at run time. The button should be displayed once for every customer record.

Attribute Suggested ValuesText color RedFont weight SRW.BOLD_WEIGHTFont style SRW.ITALIC_STYLE

Attribute Suggested Values

Fill pattern Crisscross, sandpaper

Foreground fill color Yellow

Background fill color Green

Page 99: Oracle Developer: Build Reports

Oracle Developer: Build Reports 16-29......................................................................................................................................................

......................................................................................................................................................Practice Session: Lesson 16

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

e Save the report as p16q2.rdf.

f Test the report using the run-time executable and then close the run time.

If You Have Time3 Open report p9q1.rdf.

In this report, you use report triggers to create a temporary table at the start of report execution and insert rows into the table at various stages of the execution.

a Write a trigger that creates a temporary table to hold the date and userid each time the report is run. The table should contain three columns: one date column, one character column of width 10, and one character column of width 80.

CREATE TABLE RUNREPORT(DATE_RUN DATE, USER_RUN VARCHAR2(10), COMMENTS VARCHAR2(80))

b The same trigger should also insert the current date, userid, and “Starting Report” into this table.

INSERT INTO RUNREPORT(DATE_RUN, USER_RUN, COMMENTS)VALUES (SYSDATE, USER, ’Starting Report’)

Hint: Think about how you code the single quotes.

c Save the report as p16q3.rdf .

d Compile the PL/SQL and run the report. Make sure that you view more than one page.

e Run and test the report.

f Using SQL*Plus, verify that your table exists and was populated successfully.

g Log on to SQL*Plus (in Microsoft Windows, select the SQL*Plus icon in the Oracle group) using the same userid as you used for Reports.

h Display all records in the RUNREPORT table.SQL> col comments format a40SQL> SELECT * FROM RUNREPORT;

Page 100: Oracle Developer: Build Reports

16-30 Oracle Developer: Build Reports......................................................................................................................................................

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

Page 101: Oracle Developer: Build Reports

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

17

Maximizing PerformanceUsing the Reports Server

Page 102: Oracle Developer: Build Reports

17-2 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Objectives

At the end of this lesson, you should beable to do the following:

• Distinguish between local client andremote server reporting

• Describe the three-tiered architecture ofReport Builder

• View and schedule server-side reportsusing the Queue Manager

Page 103: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-3......................................................................................................................................................

......................................................................................................................................................Overview

Overview

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

ObjectivesAt 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

Page 104: Oracle Developer: Build Reports

17-4 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Why Use a Remote Server?

Client reporting

• All processing andformatting is done on theclient

Suitable for small andmedium size reports

• Everyone runs the samereport again and again,no sharing

DB

Developer/2000Release 1

Page 105: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-5......................................................................................................................................................

......................................................................................................................................................Why Use a Remote Server?

Why Use a Remote Server?

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

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

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

Page 106: Oracle Developer: Build Reports

17-6 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Benefits of the ReportsServer (RWMTS60)

• Formats, printsreports on a powerfulserver

• Eliminates rerunningreports

• Enhances scalabilityand performance

Running Reports on a RemoteServer

Oracle DeveloperRelease 6

RWRUN60 RWRUN60 RWRUN60

RWMTS60

DBDB

Page 107: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-7......................................................................................................................................................

......................................................................................................................................................Why Use a Remote Server?

Running Reports on a Remote ServerOracle Reports Release 6 provides a powerful and intelligent Reports Server that resides on a high performance server machine that is capable of processing and formatting your reports at high speed and can return the completed output to the client machine.

The Reports Server is a single process, and dynamically manages a set of report run-time engines. Each Reports Runtime engine is responsible for executing a single report at any given time; each engine can reside in memory to execute additional report requests over a period of time.

Benefits of the Reports Server• Reports are formatted on a high-performance NT or UNIX server.

• The Reports Server detects duplicate reports. Users can share output without rerunning the report.

• The Reports Server caches the output in a central repository on the server machine.

• You can implement multiple run-time engines for one Reports Server.

• You can implement multiple Reports Servers on one machine.

Page 108: Oracle Developer: Build Reports

17-8 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Reports Server Architecture

RWCLI60

Queue Manager

RWRQM60

(Thin) Client

Application server(Unix/NT)

DBserver

RWRUN60RWRUN60 RWRUN60

RWMTS60

. . .. . .

DB DB

Page 109: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-9......................................................................................................................................................

......................................................................................................................................................Reports Server Architecture and Configuration

Reports Server Architecture and Configuration

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

The Three-Tiered Architecture

Client Tier The client tier is a front-end machine that sends commands to the remote Reports Server.

• Invoke the executable 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.

Page 110: Oracle Developer: Build Reports

17-10 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Reports Server Clustering

Multi Tiered Server

EngineEngineEngineEngine

Master ReportServer

Multi Tiered Server

EngineEngineEngineEngine

Slave ReportServers

Multi Tiered Server

EngineEngineEngineEngine Multi Tiered

Server

EngineEngineEngineEngine

Page 111: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-11......................................................................................................................................................

......................................................................................................................................................Reports Server Clustering

Reports Server Clustering

IntroductionWhile the introduction of a multi-tiered server is a benefit in itself, it still only allows for a single machine to act as the server. In order to scale beyond the bounds of a single machine, Oracle Reports Release 6 introduces the Reports Server Clustering feature.

Scalable Load ManagementReports server clustering works as a master-slave configuration. One reports server is designated to be the master, all other reports servers are slaves. By clustering individual reports servers they act as a single logical, but distributed, report engine.

When you submit jobs to the Reports Server they are automatically routed to an available engine running on any machine within the cluster. If your reporting demands grow to the extent where performance is degrading, it is simply a matter of adding a new machine to the cluster to extend the available processing power.

When you add machines to the cluster, the Report Server automatically recognizes their existence and starts to issue job requests to them. In case one of the machines becomes unavailable due to failure or shutdown, the server automatically ceases to issue requests. If an engine dies while running a job, the job is resubmitted using the retry mechanism—there is no guarantee that it will run on the same slave however.

Optimizing ResourcesThe 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 ReportIn 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.

Page 112: Oracle Developer: Build Reports

17-12 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Parameters for RWCLI60

• SERVER = <master_server>

• MODULE|REPORT = <runfile>

• DESTYPE = FILE, PRINTER, MAIL,CACHE, LOCALFILE, SYSOUT

• DESNAME = <desname>

• DESFORMAT = PDF, DFLT, HTML,HTMLCSS, RTF, DELIMITED

RWCLI60.EXE SERVER=masterserver

MODULE=my_rep.rdf DESTYPE=FILE

DESNAME=my_rep.pdf DESFORMAT=pdf

RWCLI60.EXE SERVER=masterserver

MODULE=my_rep.rdf DESTYPE=FILE

DESNAME=my_rep.pdf DESFORMAT=pdf

Page 113: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-13......................................................................................................................................................

......................................................................................................................................................Reports Server Clustering

Parameters for Running a Remote Report• RWCLI60 sends a request to the Reports (master) server.

• RWCLI60 is invoked by a Common Gateway Interface (CGI) script. There is a CGI version available for Web servers (RWCGI60).

• SERVER=<tnsname>, where <tnsname> is an alias for your Report Server that you create in <oracle_home>\net80\admin\tnsnames.ora. We discuss the Reports Server name and parameters later in this lesson.

• You cannot set DESTYPE to Screen or Preview when using RWCLI60.

• HTMLCSS uses cascading style sheets, available in Netscape 4.0 or higher.

Note: RWCLI60 accepts the same parameters as the Reports Runtime, RWRUN60.

Running a Remote Report from the Command Line

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

Returning Control to the ClientInclude BACKGROUND=yes in your RWCLI60 command line, and then RWCLI60 returns immediately after submitting a job request to the Reports Server.

Page 114: Oracle Developer: Build Reports

17-14 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

The Schedule Parameter

SCHEDULE = [FREQ from] TIME [retry n after LEN]

RWCLI60...

SCHEDULE=monthly_last_weekday_from_17:00_Oct_23,_1999_

retry_3_after_1_hour

FREQ CLOCK DATE

TIME

Page 115: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-15......................................................................................................................................................

......................................................................................................................................................Reports Server Clustering

The Schedule ParameterSCHEDULE is a scheduling parameter that you can include in the RWCLI60 command line to control the time and frequency with which your report runs.

The syntax of the SCHEDULE parameter comes primarily from the syntax of a “cron” job on UNIX. To avoid quoting the schedule string, use underscores (_) instead of spaces.

In default mode the program runs the report immediately.

SyntaxThe 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>

ExampleSCHEDULE=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.

Page 116: Oracle Developer: Build Reports

17-16 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Reports Caching

Cached reports on server:

• Tolerance = n (minutes)

• Tolerance = 0 (default/current behavior)

• Maximum tolerance is 2 32 minutes(approximately 10,000 years)

• Cached output controlled by a serverparameter CACHEDIR

Page 117: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-17......................................................................................................................................................

......................................................................................................................................................Reports Server Clustering

Reports CachingInclude 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 OutputThe Reports Server uses a parameter CACHEDIR to determine where to place the cached output.

The default directory is <oracle_home>\report60\server\cache.

Page 118: Oracle Developer: Build Reports

17-18 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Reports Server ConfigurationParameters

Installing a Reports Server on Windows NT

• Service example (normal)

• Non-service (less common)

Command line values override server.ora file

RWMTS60 -install my_server tcpip

RWMTS60 -listen my_server INITENGINE=2 MINENGINE=1RWMTS60 -listen my_server INITENGINE=2 MINENGINE=1

Page 119: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-19......................................................................................................................................................

......................................................................................................................................................Reports Server Clustering

Reports Server Configuration ParametersWhen you first install a Reports Server, it creates a .ora file with the same name as the server. The file exists in <oracle_home>\report60\server, and you can edit the parameters in the file.

You can start up the Reports Server manually as a nonservice; however, on Windows NT it is more common to install the server as a service.

• Service: All parameters have default values that you can modify in the server .ora file.

• Nonservice: You can initialize some parameters on the command line when you start up the server.

Server File ContentsThe following parameters exist in the <server>.ora file, and are also available on the command line, if installing manually as a nonservice:

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)

Page 120: Oracle Developer: Build Reports

17-20 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Reports Server ConfigurationParameters

server_name.ORA file in<oracle_home>\report60\server

MAXCONNECT=20

CACHEDIR="C:\ORANT\REPORT60\server\cache"

CACHESIZE=50

SOURCEDIR="C:\develop\reports"

INITENGINE=1

MINENGINE=1

MAXENGINE=3

MAXIDLE=30

SECURITY=1

ENGLIFE=200

Page 121: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-21......................................................................................................................................................

......................................................................................................................................................Reports Server Clustering

Reports Server Configuration ParametersAdditional <servername>.ora parameters:

Log File Contents A <servername>.log file in the same directory contains an administrative actions log, which includes the following information:

• Shutdown time

• Startup time

• Engine start and stop time

How Parameters Control Run-Time EnginesTo conserve application server resources, excess or idle report engines remove themselves from memory for one of the four following reasons:

• When an engine is idle for a [MAXIDLE] period of minutes, an engine removes itself from the process table and frees up any associated resources.

• When an engine has run its [ENGLIFE] number of jobs, the reports engine dies gracefully, to be replaced by another engine.

• In response to changes to the maximum number of engines [MAXENGINE], excess engines are removed.

• When the multitiered Reports Server shuts down.

Parameter Description

INTERACTIVE Enable Reports Server to send output to screen/preview (Y or N)

MAXCONNECT Number of Reports Server connections and number of ISV connections

SOURCEDIR Directory that Reports Server initially searches for source (.rdf, .rep) file

CACHEDIR Output directory of cached report

CACHESIZE Size determines how big cache can be

TEMPDIR Directory that Reports Server uses for temporary filespace; if not spec-ified, default = REPORTS30_TMP path

SECURITY Level of access, 0 to 3, for accessing cached output files through Queue Manager; 0 = anyone, 1 = same userid, 2 = same process, 3 = none, default = 1

ENGLIFE Maximum number of reports run before engine shuts down and is replaced; default = 200

Page 122: Oracle Developer: Build Reports

17-22 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Configuring a Clustered ReportsServer: Example

Add to master_name.ora configuration file

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”)”

Page 123: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-23......................................................................................................................................................

......................................................................................................................................................Reports Server Clustering

Configuring a Clustered Reports ServerReports Server clustering works as a master-slave configuration. You designate a server to be the master by adding the following line in the servername.ora configuration file:clusterconfig=”(server=server_name

minengine=minimum number of master engines

maxengine=maximum number of master engines

initengine=initial number of master engines

cachedir=directory for central cache)

Note: You need an entry for each slave server.

The next thing you do is to ensure that the master can see the slaves, and that the slaves can see the master:

• Add a line to the master tnsnames.ora file for each slave:slave_name.world=(ADDRESS=(PROTOCOL=tcp)(HOST=slave_name)(PORT=1949))

• Add a line to the slave tnsnames.ora file to identify the master”master_name.world=(ADDRESS=(PROTOCOL=tcp)(HOST=master_name)(PORT=1949))

Technical NoteThe 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.

Page 124: Oracle Developer: Build Reports

17-24 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Real-time Reports Server status

• View report status and scheduled jobs

• Refresh to see the up-to-date status

• Reprioritize or cancel jobs

• Administrator password encrypted in.ora file

What Is the Queue Manager?

Page 125: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-25......................................................................................................................................................

......................................................................................................................................................Viewing and Scheduling Reports in the Queue Manager

Viewing and Scheduling Reports in the Queue Manager

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

What Is the Queue Manager?The Queue Manager is a facility that enables users and administrators to view the current status of each report.

You can see all the jobs controlled by the master, as well as the server on which each job is running, and the time that each report started and finished and whether it terminated successfully or with an error.

You can also view jobs that are scheduled to run at a future date or time.

You can reprioritize or cancel your own scheduled jobs. Administrators can reprioritize or cancel any scheduled jobs.

Administrator PrivilegeIn 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.

Page 126: Oracle Developer: Build Reports

17-26 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Queue Manager

Past jobs

Current jobsScheduled jobs

Copyright Oracle Corporation, 1999. All rights reserved.

Queue ManagerAll my jobs

All jobs

Refresh

Page 127: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-27......................................................................................................................................................

......................................................................................................................................................Viewing and Scheduling Reports in the Queue Manager

Viewing Report JobsThe Queue Manager status bar enables you to switch between different views of report jobs.

Viewing Different Owners’ JobsThe Queue Manager status bar enables you to restrict the view of jobs by owner.

Displaying Up-to-Date Job StatusChoose Refresh on the status bar to refresh the screen and display the up-to-date status.

The default update interval is 15 seconds. You can alter this interval in the Queue Manager preferences screen:

Options—>Preferences—>Polling Interval

Icon Name Description

Show Past Jobs Displays jobs that have already run for a given Reports Server

Show Current Jobs Displays jobs that are currently running

Show Scheduled Jobs Displays scheduled jobs in order to reprioritize or cancel a job

Icon Name Description

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

Show all Jobs Displays all reports for a given Reports Server

Page 128: Oracle Developer: Build Reports

17-28 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Using the Queue Manager

• Connect to any number of servers

• Administrator can shut down server

• Reports Server restores scheduled jobsafter shutdown

QueueManager

RSVR1

RSVR2

Page 129: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-29......................................................................................................................................................

......................................................................................................................................................Viewing and Scheduling Reports in the Queue Manager

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

Shutting Down a Reports ServerYou can shut down the Reports Server from the Queue Manager menu if you have Administrator privileges:

Queue—>Shutdown

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

Retaining Scheduled Jobs After ShutdownThe Reports Server maintains a list of all scheduled jobs in a file, <oracle_home>/report60/server/<servername>.dat. If the Reports Server shuts down and restarts for any reason, it reads this file at startup and restores all scheduled jobs.

Page 130: Oracle Developer: Build Reports

17-30 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Reports Server ActiveX Control• Embed in any ActiveX container

• Run report with a call to RWRBE60 orRWMTS60

Page 131: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-31......................................................................................................................................................

......................................................................................................................................................Viewing and Scheduling Reports in the Queue Manager

The Reports Server ActiveX ControlThe Oracle Developer installation provides an ActiveX control, which you can use from other Windows applications to invoke the remote Reports Server and schedule your reports.

The ActiveX control is RWSXU60.OCX. This control displays the Queue Manager.

You can embed this control in any ActiveX container.

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

Page 132: Oracle Developer: Build Reports

17-32 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

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

Page 133: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-33......................................................................................................................................................

......................................................................................................................................................Summary

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

Page 134: Oracle Developer: Build Reports

17-34 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Practice 17 Overview

• Running a report on your local machine

• Running reports on a remote serverusing the Queue Manager

• Copying output from a remote server toyour local machine

• Running a report on a remote serverusing the command line

Page 135: Oracle Developer: Build Reports

Oracle Developer: Build Reports 17-35......................................................................................................................................................

......................................................................................................................................................Practice Session Overview: Lesson 17

Practice Session Overview: Lesson 17This practice session contains:

• Running a report on your local machine

• Running reports on a remote server using the Queue Manager

• Copying output from a remote server to your local machine

• Running a report on a remote server using the command line

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

Page 136: Oracle Developer: Build Reports

17-36 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session: Lesson 17 1 Run longrun1.rdf on your local client machine.

a Open longrun1.rdf and run the report. Notice the time it takes for the report to run to completion. If it has not completed within five minutes, note how many pages have been formatted, then cancel the report.Note: Change Destination Type to File in the run-time parameter form when running this report.

2 Run longrun1.rdf and longrun2.rdf by calling the Reports Server from the Queue Manager.

Note: Your instructor will give you specific instructions to complete this exercise. The location of the remote server, directory paths, and so on, might differ for your class.

a Invoke the Queue Manager. Enter repserver1 as your server name. Note if there are any jobs in the queue.

b Schedule a new job to run longrun1.rdf report on the Reports Server. Choose applicable settings from the tab pages of the Queue Manager. For Destination Type, choose ToLocalFile, ToFile, or Cache; the report default is Screen, which is not valid when running a remote report.

c Do the same for longrun2.rdf.

d Display all jobs to see where your jobs are queued in relation to the reports of other students.

e Display all your own jobs only.

f Refresh the screen several times to see how quickly the report pages are formatted.

g Cancel your own longrun2.rdf from the server queue.

3 When the report longrun1.rdf has finished, copy the output to a filename, longrun1.pdf, in your home directory.

If You Have Time4 Run longrun1.rdf by scheduling a new job from the command line.

a Using RWCLI60 from the command line, submit your longrun1.rdf report to the Reports Server.

b Ensure the output is in PDF format and that it is cached.

Page 137: Oracle Developer: Build Reports

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

18

Building Reports forDifferent Environments

Page 138: Oracle Developer: Build Reports

18-2 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Objectives

At the end of this lesson, you should beable to do the following:

• Build reports for different GUIs

• Build character mode reports

• Build reports to run in other languages

Page 139: Oracle Developer: Build Reports

Oracle Developer: Build Reports 18-3......................................................................................................................................................

......................................................................................................................................................Overview

Overview

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

ObjectivesAt 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

Page 140: Oracle Developer: Build Reports

18-4 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Different Development andRuntime Environments

Report Builder development

• Bitmapped only

Report Builder Run-time

• Bitmapped MODE = bitmap

• Character mode MODE = character

Page 141: Oracle Developer: Build Reports

Oracle Developer: Build Reports 18-5......................................................................................................................................................

......................................................................................................................................................Different Development and Run-Time Environments

Different Development and Run-Time Environments

IntroductionAlthough you always develop your reports in a bitmapped environment, the production reports can run in either bitmapped or character mode.

Therefore you can develop a report in a bitmapped environment that is to run in a character mode environment.

Bitmapped EnvironmentThis environment has a unit of pixel and typically supports a mouse. Interaction with the host computer is continuous.

The bitmapped Designer allows you, as a developer, to take advantage of the graphical user interface.

Character Mode EnvironmentThis environment has a unit of character, typically 80x24, and rarely supports a mouse. Interaction with the host computer is at field level; that is, when the user navigates from the field.

A report that runs in character mode cannot display any graphics features, such as images, drawings, or multimedia objects.

Running a Character Mode Report from the BuilderYou can test your character mode reports very easily in the bitmapped Report Builder and view the report output in the Previewer.

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

Page 142: Oracle Developer: Build Reports

18-6 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Developing Reports to Run inDifferent GUIs

• Use common fonts or map fonts inuifont.ali

• Use common colors

• Beware of DPI (dots per inch)

Page 143: Oracle Developer: Build Reports

Oracle Developer: Build Reports 18-7......................................................................................................................................................

......................................................................................................................................................Developing Reports to Run in Different GUIs

Developing Reports to Run in Different GUIs

IntroductionThere are a few points that you should consider when moving a report from one GUI to another, because the following GUI differences may affect the report output.

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

ExampleIn 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

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

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

Page 144: Oracle Developer: Build Reports

18-8 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Building Character ModeReports

• Use predefined character modetemplate

• Modify report properties

• Avoid GUI objects: graphics, buttons,OLE2

• Avoid borders

Page 145: Oracle Developer: Build Reports

Oracle Developer: Build Reports 18-9......................................................................................................................................................

......................................................................................................................................................Building Character Mode Reports

Building Character Mode Reports

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

Set Report-Level PropertiesDefine character mode settings before creating any part of your report layout, in preparation for running in character mode. There are two methods:

• Select the character mode template in the Report wizard. This is the simplest method. You can copy and modify the template to create character-mode templates with different settings.

• Open the report property palette and modify the character mode settings. Always select Use Character Units in Designer when developing character reports.

Avoid Graphics, Buttons, and OLEAvoid using graphic objects. When executing a report in character mode, Report Builder converts all boilerplate objects (except rectangles, lines, and text) to rectangles, as well as any field with a nontext source (for example, a file column referencing a multimedia file) and any Graphics Display.

To include graphics, you can choose to show the area that contains a graphic object by selecting the Convert Bitmapped Objects to Boxes check box in the Character Mode tab of report properties. This option displays an empty rectangle with a border in place of the graphic object.

Avoid BordersBorder 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.

Page 146: Oracle Developer: Build Reports

18-10 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Building Character ModeReports

Also consider:

• Font

• Color

• Fill patterns

• Format attributes

• Printer codes

Page 147: Oracle Developer: Build Reports

Oracle Developer: Build Reports 18-11......................................................................................................................................................

......................................................................................................................................................Building Character Mode Reports

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

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

Fill PatternsAvoid 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 AttributesOnly 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 CodesYou 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.

Page 148: Oracle Developer: Build Reports

18-12 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Setting NLS LanguageEnvironment Variables

• NLS_LANG

• DEVELOPER_NLS_LANG,USER_NLS_LANG

• UNICODE

NLS_LANG=French_France.WE8DECNLS_LANG=French_France.WE8DEC

NLS_LANG=<lang>_<territory>.AL24UTFFSSNLS_LANG=<lang>_<territory>.AL24UTFFSS

Page 149: Oracle Developer: Build Reports

Oracle Developer: Build Reports 18-13......................................................................................................................................................

......................................................................................................................................................Building Reports to Run in Different Languages

Building Reports to Run in Different Languages

IntroductionThis section gives a brief overview of the features in Oracle and Oracle Developer that provide support for building multilingual applications:

• Switching languages using Oracle’s National Language Support (NLS)

• Translating an application using Translation Builder

Setting NLS Language Environment VariablesThree language environment variables are available:

• NLS_LANG

• DEVELOPER_NLS_LANG

• USER_NLS_LANG

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

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

• Language: Language conventions for displaying messages and day and month names

• Territory: Conventions for default date format, and for displaying currency, decimal, and thousands symbols

• Character_set: Character set in which data is displayed

Example NLS_LANG=French_France.WE8DEC

Using Unicode in Oracle DeveloperUnicode (UCS-2) is a fixed-length two-byte character set that represents up to 65,536 characters.

Using Unicode in Oracle Developer enables you to display multiple languages in one application without switching character sets.

SyntaxNLS_LANG = <language>_<territory>.AL24UTFFSS

Page 150: Oracle Developer: Build Reports

18-14 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Translating a Developer/2000Application

Use Translation Builder to:

• Extract strings; import into repository

• Execute translation

• Merge back into original resource

Consider:

• Format masks

• Hardcoded strings

• Multiple character sets

Page 151: Oracle Developer: Build Reports

Oracle Developer: Build Reports 18-15......................................................................................................................................................

......................................................................................................................................................Building Reports to Run in Different Languages

Translating an Oracle Developer ApplicationTranslation Builder is a component of Oracle Developer that supports and manages translations of text extracted from both Oracle resource files, such as OracleDeveloper applications, and non-Oracle resource files such as Microsoft Windows (.rc) and HTML files.

You can translate a report from any language to any other language. Once a translation is complete, you can use that translation as a base for further translations.

Translations are portable across multiple platforms.

How to Translate a Resource1 Use the Project Navigator to extract translatable strings from Oracle or

non-Oracle resources and import them into the translation repository.

2 Add a translation by indicating the language.

3 Execute the translation using the Translation editor.

4 Preview the translation by performing appearance checking and tuning to preserve an acceptable look and feel.

5 Extract the translated strings and merge them back into the original resource.

Considerations When Designing Multilingual Applications• Format masks: Make sure to provide extra space for translation of date and

numeric format masks.

• Text strings: Avoid hardcoding a string containing language-specific words such as a month name.

• Character sets: If using an application that will run with multiple character sets, determine the one that is most frequently used and generate the application files with the relevant NLS language settings.

Page 152: Oracle Developer: Build Reports

18-16 Oracle Developer: Build Reports......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Summary

• GUIs:

Colors, uifont.ali

• Character mode:

Templates, report properties, MODEparameter

• Languages:

NLS, Unicode, Translation Builder

Page 153: Oracle Developer: Build Reports

Oracle Developer: Build Reports 18-17......................................................................................................................................................

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

Page 154: Oracle Developer: Build Reports

18-18 Oracle Developer: Build Reports......................................................................................................................................................

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

Page 155: Oracle Developer: Build Reports

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

A

Solutions

Page 156: Oracle Developer: Build Reports

A-2 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Overview: Lesson 1

IntroductionThis practice familiarizes you with Oracle Developer by asking you a number of questions that you answer by navigating through the interface and by investigating Help Topics.

After each question, space is provided for you to write the answer. Or, if you prefer, use a separate sheet of paper.

Depending on the size of your group, the instructor might ask you to answer some of the questions and share your answers with the rest of the class.

Depending on the environment you are using in this course, the instructor might ask you to compile some reports from the Project Builder.

Page 157: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-3......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 1

Practice Session Solutions: Lesson 11 Launch Report Builder and then choose Cancel in the wizard.

Choose Report Builder in the launcher.When Report Builder is up, choose Cancel in the wizard.

2 Change your preferences so that a newly opened report is not immediately executed. To do this you must suppress the Report editor on Open.Select Tools—>Preferences from the menu. On the General tab, select the option Suppress Report Editor on Open and then choose OK.

3 Open the report named p2q2.rdf.Choose Open from the toolbar or File—>Open from the menu and then select the file named p2q2.rdf.

4 Change your preferences so that you can work with a report definition either in a file or the database. Ensure that the default list shows only reports.Select Tools—>Preferences from the menu. On the Access tab select the option File/Database and check Reports. Notice that the select in All is cleared. Choose OK to accept your preferences.

5 Open another report: p2q3.rdf. Notice the additional dialog box.Choose Open from the toolbar or File—>Open from the menu. Accept the dialog box. In the File Browse dialog box, select the file named p2q3.rdf and choose OK.

6 Reset your preferences to work with files only. Enable a report to be run automatically on open.Select Tools—>Preferences from the menu. On the General tab clear the option Suppress Report Editor on Open. On the Access tab select the option File. Choose OK to accept your preferences.

Page 158: Oracle Developer: Build Reports

A-4 Oracle Developer: Build Reports......................................................................................................................................................

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

7 Use the context-sensitive Help to discover more about preferences.Select Tools—>Preferences from the menu. Choose Help or press the Help key (F1 on Windows systems).General:

a What setting must you choose for color mode if you want to alter the color palette for a specific report? Choose the General tab in the Help system. In the dialog box, select Color Mode and choose Display.You must set the color mode to Editable.

b What menu option do you use to alter the color palette?Format—>Layout Options—>Color Palette.Close the Help system.

Run-time values:Go back into the Tools—>Preferences Help system.c What is the purpose of the Runtime Values?

Choose the Runtime Values tab in the Help system.Run-time values are values used if you run your report in the current session.

d When do they take effect? Immediately

e What must you do to change the default setting in your report?You must update the Initial Value of the appropriate parameter in the report definition.

f What are the names of the three run-time values that affect the report destination, and what are the three related report parameters?

Close the Help system and leave the Preferences dialog box.

Destination Format DESFORMAT

Destination Name DESNAME

Destination Type DESTYPE

Page 159: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-5......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 1

8 Use Help Topics to discover more about the functionality of Oracle Developer Report Builder:Choose Help—>Report Builder Help Topics from the menu.a What is MAPI?

Use the index to look for MAPI. Choose MAPI, about.MAPI is the Microsoft Messaging Application Program Interface used to send reports to an e-mail system.

b What are the prerequisites for sending a report as an e-mail attachment?You must have an appropriate MAPI mail client.

c The report is sent as what type of attachment format?Bitmapped reports are sent as PostScript files, character mode reports as ASCII text.

d What are the three steps to install Oracle Developer demonstrations?Use the index to look for Demos, Installing.The three steps are:1. Install the demo database objects.2. Install Report Builder Demo fonts.3. Install Java classes for the Java Reports demo.

9 Use Help on Manuals to answer the following questions in the Oracle Information Navigator:

Note: In the Information Navigator, choose Tools—>Preferences to initialize your Web browser. Your instructor will tell you which browser to use.

Choose Help—>Manuals from the menu.a What are the three top-level folder names for the online manuals?

Oracle Developer: Guidelines for Building Applications 6.0Oracle Developer: Getting Started 6.0Configuring the Oracle Developer Server 6.0I

Page 160: Oracle Developer: Build Reports

A-6 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................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 TablesUsing the Database TablesGranting and Revoking User AccessDeleting the Oracle Developer Database TablesUpgrading 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_LANGNLS_LANGUSER_NLS_LANG

Page 161: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-7......................................................................................................................................................

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

Page 162: Oracle Developer: Build Reports

A-8 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Overview: Lesson 2This practice session contains:

• Invoking the Reports Runtime executable from the Program Manager

• Executing a number of different reports. For each report, answer some questions

Introduction Before you learn to develop reports in the Builder, you should investigate the 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.

Page 163: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-9......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 2

Practice Session Solutions: Lesson 21 Invoke the Reports Runtime executable.

Choose Reports Runtime from the Oracle Developer menu.This may differ according to the classroom setup.

2 Run the report called p2q2.rep. From the menu choose File—>Run. The File Browse window opens. Select p2q2.rep and choose Open. a Examine the report in the Previewer window. Among the styles

discussed in this lesson as a reference, what style of report is it? Tabular report

b How many groups of data are there in this report?One group of data, each row being displayed once within the group.

c In the Previewer window, use the scroll bars to move up and down the report to see all of the data.Use the scroll bar on the right side of the Previewer to scroll up and down the report data.

d Close the Previewer window. You are now back in the Runtime window.In the Previewer, choose Close Previewer.

3 From the Runtime window, run report p2q3.rep. From the menu choose File—>Run.The file Browse window opens. Select p2q3.rep and then choose Open.a In the Previewer window, move to the next page. Notice that this

report has a header page with text. Notice that the Previewer also has many more buttons highlighted. This is because there are more available actions, such as Next Page, Previous Page, Last Page, and First Page.Choose Next Page to navigate from one page to another.

b What style of report is this?Tabular report

Page 164: Oracle Developer: Build Reports

A-10 Oracle Developer: Build Reports......................................................................................................................................................

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

c In the Previewer window, experiment with the horizontal and vertical split screen features.To split the Previewer horizontally: Choose the small gray area at the top of the right scroll bar. Keep the left mouse button down and drag the gray area. As you do this, you see that a thick dotted line is dragged down the Previewer. Release the left mouse button when you have reached the desired split point. Now you have two windows, which work independently from each other.Move the split bar back to its original position.To split the Previewer vertically: Choose the small gray area at the left of the horizontal scroll bar at the bottom of the window. Keep the left mouse button down and drag the gray area. As you do this, you see that a thick dotted line is dragged right across the Previewer. Release the left mouse button when you have reached the desired split point. Now you have two windows, which work independently from each other

d Close the Previewer window. You are now back in the Runtime window.In the Previewer choose Close Previewer.

4 From the Runtime window, run report p2q4.rep. From the menu choose File—>Run. The File Browse window opens. Select p2q4.rep and then choose Open.a What style of report is this?

It is a Master/Detail report.b How many groups of data are in this report?

There are two groups of data.c How many pages are there in this report?

There are three pages. Choose Last Page to navigate to the last page.

d Close the Previewer window. You are now back in the Runtime window.In the Previewer, choose Close Previewer.

Page 165: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-11......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 2

5 From the Runtime window, run report p2q5.repFrom the menu choose File—>Run.The File Browse window opens. Select p2q5.rep and choose Open.a What style of report is this?

It is a Matrix report.b How many groups of data are in this report?

There are four groups of data:YearDepartment Job TitleSalaryThere actually is an additional, invisible “cross product” group around Year, Department, and Job; this special group defines the matrix structure and is explained in the lesson on matrix reports.

c Close the Previewer window. You are now back in the Runtime window.In the Previewer choose Close Previewer.

6 From the Runtime window, run report p2q6.rep.From the menu choose File—>Run. The File Browse window opens. Select p2q6.rep and choose Open.a Notice the Parameter Form. You are requested to input a customer

ID. The report will display order information based on your input.

b Specify a valid customer ID and run the report. Valid values include 201, 210, and 213; choose one of these and then choose Run Report.Click in the Customer ID field and enter one of the suggested numbers. Choose Run Report.

c What do you think would be a better method of providing valid values to a user?It would be more user-friendly to display a list of values for the Customer IDs. You could even make the list more meaningful by adding the customer names. This can be built into the report. In later lessons you will see how this can be implemented.

Page 166: Oracle Developer: Build Reports

A-12 Oracle Developer: Build Reports......................................................................................................................................................

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

Page 167: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-13......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 2

7 From the Runtime window, run report p2q7.rep.From the menu choose File—>Run. The File Browse window opens. Select p2q7.rep and choose Open.a In the Parameter Form notice the list of values for the Customer

information. The report displays order information based on your input.

b Select a valid customer name and run the report.Select a customer name from the list of values for customer.Close the Previewer window. You are now back in the Runtime window.In the Previewer, choose Close Previewer.

8 From the Runtime window, run report p2q8.rep.From the menu choose File—>Run. The File Browse window opens. Select p2q8.rep and choose Open.a What do you notice that is different about this report?

A button is displayed to the right of the customer information.b Choose Details. Another report is called to display information about

the orders the customer has placed with the company. This is called a Drill-Down report.

c Close the Orders Report Previewer window and then close the Customer Report Previewer window. You are now back in the Runtime window.In the Orders Report Previewer choose Close Previewer.In the Customer Report Previewer choose Close Previewer.

d Exit Reports Runtime.From the menu choose File—>Exit.

Page 168: Oracle Developer: Build Reports

A-14 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Overview: Lesson 3This practice session contains:

• Invoking Report Builder

• Opening an existing report

• Switching views in the Report editor

• Accessing the Help system

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

Page 169: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-15......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 3

Practice Session Solutions: Lesson 31 If you closed Project Builder in Practice 1, invoke Project Builder and

then invoke Report Builder from the Project Builder Launcher toolbar. If it is still open, go to Report Builder.If you need to reopen Report Builder, choose Project Builder from the Oracle Developer menu. Do not open an existing project. Choose Cancel.In the Launcher choose Report Builder.

2 Open an run an existing report: p3q2.rdf.In the Welcome dialog box of Report Builder select the Open an Existing Report option and choose OK.Open p3q2.rdf from the file system and run the report.If prompted, connect to the database using the login information your instructor gives to you.When the parameter form comes up, choose Run Report, accepting all the defaults.

3 In the Report editor, switch to the Data Model view.In the Object Navigator, select Q_1. Hint: Use the Find field at the top of the Object Navigator.Notice the object that is selected in the Data Model view.While the Report Editor window is active, choose View—>Data Model from the menu.Activate the Object Navigator window. Click in the Find field and enter Q_. The Navigator expands the appropriate node and highlights the first object that meets the entered value.In the Data Model editor, the query object Q_1 is selected.

Page 170: Oracle Developer: Build Reports

A-16 Oracle Developer: Build Reports......................................................................................................................................................

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

4 In the Report editor, switch to the Layout Model.In the Object Navigator, select F_ID. Hint: Use the Find field at the top of the Object Navigator.Notice the object that is selected in the Layout Model view.Fully expand the Layout Model node and select R_G_ORD_ID.Notice the object that is selected in the Layout Model view.While the Report Editor window is active, choose View—>Layout Model from the menu.Activate the Object Navigator window. Click in the Find field and enter F_. The Navigator expands the appropriate node and highlights the first object that meets the entered value.In the Layout Model editor the field F_ID is selected.In the Object Navigator window, select the Layout Model node and choose Expand All in the toolbar; or choose Navigator—>Layout Model editor. Choose Expand All from the menu. Select R_G_ORD_ID.In the Layout Model editor, the repeating frame R_G_ORD_ID is selected.

5 In the Report editor, switch to the Parameter Form view.In the Object Navigator, expand the Parameter Form node. Select PF_DESTYPE. Notice the object that is selected in the Parameter Form.Use the Find field at the top of the Object Navigator to select P_CUSTID. Is any object selected in the Parameter Form? What is the reason?While the Report Editor window is active, choose View—> Parameter Form from the menu.In the Object Navigator select the Parameter Form node and choose Expand All from the toolbar or choose Navigator—>Expand All from the menu. Select PF_DESTYPE.In the Parameter Form editor the object PF_DESTYPE is selected.In the Object Navigator window, click in the Find field and enter P_. The Navigator expands the appropriate node and highlights P_CUSTID.In the Parameter Form editor the object PF_DESTYPE is not selected, because P_CUSTID is a parameter and not a parameter field. Parameters are part of the Data Model, not the Parameter Form.

Page 171: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-17......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 3

6 Use Help Topics to answer the following questions:From the menu, choose Help—>Report Builder Help Topics. In the Index tab, enter Executables in the selection field; select Invoking from the index entry list below and choose Display. Choose Related Topics.a What is RWMTS60?

Choose RWMTS60 from the dialog box.b What is RWCLI60?

Choose RWCLI60 from the text.c Close the Help system.

Page 172: Oracle Developer: Build Reports

A-18 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Overview: Lesson 4This practice session contains:

• Creating and saving a Tabular report

• Modifying the report to create and save a Group Above break report

• Creating and saving a form letter

• Creating and saving a Matrix report

• Creating and saving a Matrix with Group report

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

Page 173: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-19......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 4

Practice Session Solutions: Lesson 4

Invoking Report Builder and the WizardIf Report Builder is not open, launch it from Project Builder and create a new report using the Report Wizard.Select Project Builder from the Oracle Developer menu. Do not open an existing project. Choose Cancel.In the Launcher, choose Report Builder.In the Welcome dialog box of Report Builder, select the Use the Report Wizard option and choose OK.If Report Builder is open after the previous practice session:

• Close any reports currently in the Object Navigator.

• Create a new report by selecting the Report node and choosing Create Object.

Note: There is an alternative method. If no reports are open in the Object Navigator, you can double-click the Report node.

1 Create a tabular report containing the following data. Use Query Builder to build the query.S_DEPT: NAME

S_EMP: FIRST_NAME, LAST_NAME, TITLE, SALARY, COMMISSION_PCT

Display all fields. Do not make any changes to the other wizard pages.In the Select Data Tables dialog box, highlight the S_DEPT and S_EMP tables, choose Include, and close the dialog box.In the Query Builder window, select the columns from the tables and choose OK.Choose Next.Copy all fields from the Available Fields area to the Displayed Fields area.Choose Next on all other wizard pages and choose Finish on the last page.

Page 174: Oracle Developer: Build Reports

A-20 Oracle Developer: Build Reports......................................................................................................................................................

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

2 Using the reentrant Report Wizard, make the following modifications (test your report frequently).Select Tools—>Report Wizard from the menu or choose Report Wizard from the horizontal toolbar.Modify the query to sort the data in descending order of salary.On the Data tab choose Query Builder.In the Query Builder window choose Sort. Copy the SALARY column to the Sorted Columns, select it, and choose Sorting Order Descending. Close the Sort dialog box and the Query Builder.Choose Finish to test your report.Add a summary to show the total salary value.Reenter the Report wizard by choosing Report Wizard from the toolbar.On the Totals tab select SALARY and choose Sum.Reduce the width of SALARY and TOTAL to 6.Change the COMMISSION_PCT label to Comm and reduce the width to 4.Make the necessary changes on the Labels tab and choose Finish to test your report.Save the report to a file named p4q2.rdf.Select File—>Save As from the menu and save the file to disk.

3 Using the reentrant wizard, modify the report to create a break report.

Choose report style Group Above.Choose the report style on the Style tab.Group the report by the department name.On the Groups tab copy NAME to the Group Fields area.Choose the template called Bright 1.Choose the template on the Template tab. Choose Finish to close the Wizard.Save the report as p4q3.rdf.Select File—>Save As from the menu and save the file to disk.

Page 175: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-21......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 4

4 Create a new report containing the following data:Use the Report Wizard.Choose Mailing Labels style.Use Query Builder to build the query.

Create a new report by selecting the Report node in the Object Navigator and choosing Create Object.As an alternative you can also select File—>New—>Report from the menu.Choose Mailing Label style. For the query type, accept the default selection of SQL statement.Choose Query Builder.In the Select Data Tables highlight the S_CUSTOMER and S_ORD tables, choose Include, and close the dialog box.In the Query Builder window select the necessary columns from the tables and choose OK.S_CUSTOMER: NAME, ADDRESS, CITY, STATE

S_ORD: ID, DATE_SHIPPED, TOTAL

In the text area, include all four customer fields, each field on a new line.Copy NAME, CITY, ADDRESS, and STATE to the Mailing Label Text area. To enter the line feeds you can either use the button or simply press the [Return] key.Select the template Draft and choose Finish.Select the template on the next page.Save the report to a file named p4q4.rdf.Select File—>Save As from the menu and save the file to disk.

Page 176: Oracle Developer: Build Reports

A-22 Oracle Developer: Build Reports......................................................................................................................................................

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

Page 177: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-23......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 4

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

If You Have Time7 Modify the matrix report to create a Matrix with Group.

Reenter the Report wizard by choosing Report Wizard from the toolbar or Tools—>Report Wizard from the menu.On the Style tab choose Matrix with Group.Choose Month as the group and check that all totals have a width of 7.Go to the Group tab and copy MONTH to the Matrix Group Fields area.Check on the Labels tab that all fields with a label Total: have a width of 7.Save the report as p4q7.rdf.Select File—>Save As from the menu and save the file to disk.

Note: The query for the matrix reports above has been restricted to display only products beginning with “4,” so that you can see and understand the complete matrix more easily.

Page 178: Oracle Developer: Build Reports

A-24 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Overview: Lesson 5This practice session involves modifying reports by applying changes in the Live Previewer

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

Page 179: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-25......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 5

Practice Session Solutions: Lesson 51 Open report p4q2.rdf. Make the following changes in the Live

Previewer:To open the file select File—>Open from the menu or choose Open on the toolbar.Run the report by selecting it in the Object Navigator and then selecting Program—> Run Report from the menu or choosing Run in the toolbar.a Make the columns SALARY and COMM right justified. Do not

forget to justify the column header accordingly.Select the columns SALARY and COMM and their labels. Then choose End Justify from the style bar or select Format—> Justify—>End from the menu.

b Add commas and a currency symbol to SALARY. Add two decimal places.While the column is selected choose Commas from the style bar. This adds the group separators. Then choose Add Decimal Place from the style bar to add one decimal place. Repeat the action for the second decimal place. You can also select the commas and decimal places options from the Format menu.

c Add one decimal place and a percent sign to COMM.While the column is selected choose Percent and then Add Decimal Place from the style bar. You can also select the percent and decimal places options from the Format menu.

d Edit the heading of the COMM field. Change the text to Comm Pct.Select the label of the COMM field, then click it again to get into Change mode. Enter your text, then click outside the label to make your changes permanent.

Page 180: Oracle Developer: Build Reports

A-26 Oracle Developer: Build Reports......................................................................................................................................................

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

e Make 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.

Page 181: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-27......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 5

c Make the same changes to the total at the end of the report. Move the grand total so that it aligns with the SALARY field (you must do this manually; use the ruler guides to help you).Select the column, then choose 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.

Page 182: Oracle Developer: Build Reports

A-28 Oracle Developer: Build Reports......................................................................................................................................................

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

4 Open report p4q6.rdf. Make the following changes in the Live Previewer:To open the file select File—>Open from the menu or choose Open 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 Right justify the Product ID field.

Select the Product ID field, then choose End Justify from the style bar or choose Format—>Justify—>End from the menu.

b Remove the border around the cell values and the parent frame.Select the column, hold down the [Shift] key, and choose Select Parent Frame from the style bar.Then hold down the [Shift] key and select the column again. Choose Line Color from the vertical toolbar. Choose No Line to remove the line color from both the column and the parent frame.

c Add commas and two decimal places to the cells and summaries and make them right justified.Select the columns and choose End Justify from the style bar or select Format—>Justify—>End from the menu.While the columns are selected choose Commas and then Add Decimal Place from the style bar. You can also select the options from the Format menu.

d Add a gray line color to the parent frames of NAME and PRODUCT ID.Select the column NAME and choose Select Parent Frame from the style bar. Choose Line Color from the vertical toolbar. Repeat for the column PRODUCT.

e Save the report to a file named p5q4.rdf and close it.

Page 183: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-29......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 5

If You Have Time5 Open the file p5q2.rdf and conditionally highlight the SALARY field.

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 If the salary is less than 1000, then print the field in italics.

Select the SALARY field, then choose Format—>Conditional Formatting from the menu or use the right mouse button to open the pop-up menu and choose Conditional Formatting from the pop-up menu.The Conditional Formatting dialog box opens. Choose New and enter the condition and formatting as required. Choose OK to return to the first page but do not close the dialog box.

b If the salary is more than 2000, then print the field in italics and make the text color red.Choose New again and enter the second condition and formatting as required. Choose OK to return to the first page of the dialog box and then OK again to close the dialog box.

6 Save the report to a file named p5q5.rdf and close it.

Page 184: Oracle Developer: Build Reports

A-30 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Overview: Lesson 6This practice session contains:

• Customizing an existing template

• Applying the modified template to an existing report

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

Page 185: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-31......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 6

Practice Session Solutions: Lesson 61 Customize an existing template, adding a company logo and report title

to the report margin, and modify the report body.

a Open corp1.tdf. This file should exist in your home directory; it is a copy of the Corporate 1 predefined template.Select the Templates node in the Object Navigator.Choose Open and select the file named corp1.tdf.

b Display the margin region. (This usually appears by default when you open a template.)

c Delete the Oracle buildings logo. Import summitlo.tif and place in the top left corner of the margin; this file should exist in your home directory. Select the Oracle buildings logo and press the [Delete] key.Choose File—>Import—>Image from the menu.From the File Browse window choose the file name summitlo.tif.Resize it to fit into the margin region.

d Modify the report title line: change 21st Century Products to Summit Report.Choose the Text tool from the vertical toolbar.Select the text 21st Century Products and change it to Summit Report.

e Display the body region to view the changes you will make in the next steps. Choose the Margin/Body toggle button from the toolbar in the Template editor.

f Change the foreground color (fill color) of the section frame to white. Make these changes general, not specific to a particular layout.In the Template editor select the Section Frame. Select any of the objects and use the Select Parent Frame tool to select the outermost frame.Use the Fill Color palette or the property palette to change the color.Alternative solution:In the Object Navigator expand the Body node, the Default node, and the Frames node. Open the property palette for the body of the section frame.

Page 186: Oracle Developer: Build Reports

A-32 Oracle Developer: Build Reports......................................................................................................................................................

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

Under the heading Style, change the Foreground Color property to White.

g Change the justification of number fields to End. Do not forget to change the justification of labels for number fields to End.Select the number field and the number heading in the Template editor and choose the End justify tool from the stylebar.Alterative solution:Open the Field Labels/Headings and the Fields nodes in the Object Navigator. Select Number in both nodes.Open the property palette for your selections.Choose Union (the button is a toggle and the tooltip says Intersection at this point) from the property palette toolbar to display all properties. Under the headings Label and Fields, change the number justification to End.Change the justification of number summary fields to End.Select Summaries in the Object Navigator.In the property palette change the number justifications for fields to Right.

h Save the template as summit.tdf.

2 Apply the modified template to an existing report.

Hint: you must search for the template file; it does not appear in the list of predefined templates.

a Open p4q3.rdf.

b Apply summit.tdf to the report.Invoke the Report Wizard. On the Template tab select the option Template File. Choose Browse to enter the name of the file in the field below.

c The report shows some changes but not all. Which template changes have been applied and which have not?Changes applied: Logo, report title, color of section frame regionChanges not applied: Number justification

d To apply all changes to your report you will have to create the layout again. From the menu choose Edit—>Select All to select all layout objects. Now delete them. Invoke the Report Wizard and reapply your template.

e Save the report as p6q2.rdf.

Page 187: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-33......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 6

3 Continue to modify the template and test it using a new report.

a Change the text color of the master group fields to red for the Group Left style only.Hint: In the Template editor, use the Report Style list to switch to a Group Left style. This way you can select the correct group. You may also want to use the Zoom Out tool, so that you can see the entire template layout structure, and recognize the difference between the master group fields and the detail group fields.Select the Character, Number, and Date fields and change the text color with the Text color palette.Alternative solution:In the Object Navigator, expand the Override node, then the Group Left, the Section (Level1), and the Fields nodes.Bring up the property palette for all the fieldsChange the text color to red.

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

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

d Save the report as p6q3.rdf and close it.

Page 188: Oracle Developer: Build Reports

A-34 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Overview: Lesson 7This practice session contains:

• Using the Help system to find comprehensive information on storage types and executables

• Converting the storage type of a report using the Convert utility

• Documenting a report using the Report on Reports utility

Because the Report Builder tables are optional in Oracle Developer, your classroom might not have the tables available for you to save your report. Your instructor will advise you whether to attempt this question.

Page 189: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-35......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 7

Practice Session Solutions: Lesson 71 Search in the Help system for information on the RWCON60 executable.

From the menu, choose Help—>Report Builder Help Topics. Enter RWCON60 in the Find tab.What is this executable used for?RWCON60 enables you to convert one or more report definitions or PL/SQL libraries from one storage format to another.Can you compile more than one report with this utility?YesWhat other tool could you use to compile several reports?Hint: You may want to refer to Lesson 1.Project BuilderWhen converting a report to a template, what is converted and what is not?Only objects in the header and trailer pages and in the margin area are used in the template. Objects in the body are ignored.

2 Use the Convert utility in Report Builder to convert a report from .rdf to .rep.

a Open p6q3.rdf, if it is not already open.

b Convert it to a .rep file.Choose File—>Administration—>Convert from the menu.Document Type: ReportSource Type: Report Binary File (RDF)Source: Enter the filename, including the path, or choose Browse.Destination Type: Report Binary Run-only File (REP)Leave Destination empty.

c What other methods could you use to compile a report?File—>Administration—>Compile report or Ctrl TWhat is the difference?The Compile option from the menu compiles the presently selected report; the Convert utility enables you to choose which report or reports to compile. It also enables you to convert to other storage types.

Page 190: Oracle Developer: Build Reports

A-36 Oracle Developer: Build Reports......................................................................................................................................................

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

d Convert the same report to a .rex file.Choose File—>Administration—>Convert from the menu.Document Type: ReportSource Type: Report Binary File (RDF)Source: Enter the filename, including the path, or choose Browse.Destination Type: Report ASCII File (REX)Leave Destination empty.

e Open a system editor to look at the .rex file.No formal solution.

If You Have Time3 If the database product tables are installed, document a report definition

that is saved in the database.

a Save report p6q3 to the database.Either change your preferences to be able to save to the database (Tools—>Preferences—>Object tab)or use the convert utility (File—>Administration—>Convert).

b Run the Report on Reports utility to produce documentation on the report p6q3. Set the run-time parameters to output to a file in PDF format.Choose File—>Administration—>Report on Reports.Select report name P6Q3.Destination Type: FileDestination Name: p6q3.pdfDestination Format: PDF

c Open the PDF file and scroll through the documentation.

Page 191: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-37......................................................................................................................................................

......................................................................................................................................................Practice Session Overview: Lesson 8

Practice Session Overview: Lesson 8This practice session contains:

• Creating a second query in an existing report

• Restricting records in a query

• Restricting records with a packaged filter

• Creating a data link

• Creating a report containing a master group with two detail groups

• Creating an external query file and referencing the file in a new report

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

Page 192: Oracle Developer: Build Reports

A-38 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Solutions: Lesson 81 Open report p8q1_a.rdf, which contains a single-query report showing

customer information.

a In the Data Model create a new query. Either use the Query Builder or import filename p8q1.sql. Change the group_name to G_ORD.QUERY: Q_ORD:

SELECT customer_id, id, date_shipped, totalFROM s_ord

b Open the Report Wizard and choose a Tabular layout.

c Copy group G_ORD to the Displayed Groups area.

d Copy all remaining fields to the Displayed Fields area.

e Choose Finish.

f Note how the data appears in the Live Previewer. The Q_CUSTOMER data appears before the Q_ORD data. Remember that you can alter the order in which the data is printed by modifying query order in the Data Model. You may want to try that.

Note: If you do adjust the order of the queries, put them back in the original order and save before the next question.

g Save the report as p8q1.rdf. Do not close the report.

2 Modify the previous report to restrict the number of customer records processed by the group.

a Place a filter on the G_CUSTOMER group to display only the first four customers. Run to test.Select the group G_CUSTOMER in the Data Model and open the property palette. Set the property Filter Type to First and enter the number of records.

b Save the report as p8q2.rdf and close it.

c Close the report and any others you still have open in the Object Navigator.

Page 193: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-39......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 8

3 Open p8q1.rdf.

a In the Data Model link the two queries together on the primary and foreign keys.

Hint: To create the link, select the Link tool. Click and drag from the Primary Key field in the Customer group to the Foreign Key field in the Ord group.

b Redo the layout by opening the Report Wizard. Choose Group Above style. Do not display CUSTOMER_ID.

c Run to test.

d Save the report as p8q3.rdf.

4 Modify p8q3.rdf to show and restrict customers’ credit rating. You need to modify the query properties.

a Include CREDIT_RATING in the query statement, 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.

Page 194: Oracle Developer: Build Reports

A-40 Oracle Developer: Build Reports......................................................................................................................................................

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

f Use the template file summit.tdf

g Run and test your report.

h Now you need to show not only which products the sales representatives have sold but also who are the customers they have done business with.Go to the Data Model and add a new query, importing the file p8q5_b.sql. This query returns the customer names, their IDs, and the total sales per customer for each sales representative.

i Rename the group G_CUSTOMER.

j Link the second query to the correct group.Click and drag from ID in G_NAME to SALES_REP_ID in G_CUSTOMER.

k Use the Report Wizard to display the new group. Do not display SALES_REP_ID or ID.

Column Label Width

NAME Name 20

PRODUCT Product 10

PRODUCT_ID ID 4

QUANTITY Quantity 4

PROD_TOTAL Total 6

Page 195: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-41......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 8

l Change the following field attributes:

m Run and test your report.

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

If You Have Time6 Create an External Query module that selects the following data:

Select the External SQL Queries node in the Object Navigator and choose Create.

a Remember to include a join condition.

b Give the columns meaningful names.Write the following query:SELECT S_DEPT.ID DEPT_ID

, S_DEPT.NAME DEPARTMENT

, S_EMP.ID EMP_ID

, S_EMP.FIRST_NAME ||’ ’|| S_EMP.LAST_NAME EMPLOYEE

, S_EMP.TITLE

, S_EMP.SALARY

FROM S_DEPT, S_EMP

WHERE S_EMP.DEPT_ID=S_DEPT.ID

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

Column Label Width

CUSTOMER Customer 10

CUSTOMER_ID ID 4

CUST_TOTAL Total 6

Columns Tableid, name s_deptid, first_name||’ ’||last_name, title, salarys_emp

Page 196: Oracle Developer: Build Reports

A-42 Oracle Developer: Build Reports......................................................................................................................................................

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

Select the Program Units node in the Object Navigator and choose Create.In the New Program Unit dialog box enter a name for the package and choose Package Spec.Enter the code for the package specification.

Name Definition

last_name s_emp.last_name%type

first_name s_emp.first_name%type

salary s_emp.salary%type

Page 197: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-43......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 8

PACKAGE RefCur ISTYPE 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, salaryFROM 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 ISV_EmpCur RefCur.EmpCur;

BEGINOPEN V_EmpCur FOR SELECT last_name, first_name, salaryFROM s_emp;RETURN V_EmpCur;

END;

c Open the Report Wizard to create the layout for the report. Select all 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.

Page 198: Oracle Developer: Build Reports

A-44 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Overview: Lesson 9This practice session contains:

• Creating a new report with summaries

• Opening an existing report to add summary calculations to the columns

• Creating a report that displays the contents of a file in a column

• Creating a new report with ranking summary columns(Use an ORDER BY clause to create the ranking effect.)

• Opening an existing report to add placeholders for the highest and lowest values in the report

Introduction In your reports, you may need to include additional columns with summary functions—or even add summaries, such as break totals and report totals. This practice gives you the opportunity to create summaries and additional columns with functionality that cannot be achieved using SQL alone.

Page 199: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-45......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 9

Practice Session Solutions: Lesson 91 Create a new report using the Report Wizard. Choose a Group Above

report style.

a Display the following data:

b Do you need a formula column to calculate the line_total?No, it is a much better solution to do the calculation directly in the query.Enter the formula price*quantity_shipped into the query text and give it an alias name of line_total.You can also use the Query Builder to create expressions in the query.Select the table S_ITEM.Choose Define Column. Click inside the Defined Columns box.Enter Line_Total.Click inside the Defined As box.Enter the expression price*quantity_shipped.Choose OK.

Table Column Definition Group Label Width

s_ord id G_ord Ord. No. 4

date_ordered Order Date 9

s_item item_id G_item No. 2

product_id Product No. 5

price Price 4

quantity_shipped Quantity 4

line_total price*quantity_shipped Total 4

Page 200: Oracle Developer: Build Reports

A-46 Oracle Developer: Build Reports......................................................................................................................................................

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

d Use the summit.tdf template file from the file system.In the Template tab choose and apply the template. Finish and run the report.

e In the Data Model, rename the groups to G_ORD for the break group and G_ITEM for the detail group. Alter the position of columns in the G_ORD group so that DATE_ORDERED is above ID, and change the break order on DATE_ORDERED so that it is sorted in descending order.Open the property palettes for each group and change the names.Click on DATE_ORDERED and drag it above ID; be careful not to drag it outside the group. Open the property palette for DATE_ORDERED and change the Break Order property to Descending.

f Run and test the report (do not reenter the wizard).

g Save the report as p9q1.rdf and close it.

2 Open report p8q5.rdf. a Add a summary to total PROD_TOTAL for each employee master.

Can you use the Report Wizard?Because this is a multiquery report, you have to create all summaries manually unless you created them with the first query.Select Summary Column in the vertical toolbar and click inside the group G_NAME. This creates a new summary. Open the property palette for the new column and name it REP_TOTAL.In the Summary section select the function Sum.The Source is PROD_TOTAL.Reset at G_NAME.

Column Summary

line_total sum

line_total % Total

Page 201: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-47......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 9

b Create columns to show the percentage of the total per sales representative for PROD_TOTAL and CUST_TOTAL.Select Summary Column in the vertical toolbar and click inside the group G_PRODUCT. This creates a new summary. Open the property palette for the new column and name it PCT_PROD.In the Summary section select the function % of Total.The Source is PROD_TOTAL.Reset at G_PRODUCT.Compute at G_NAME.Select Summary Column in the vertical toolbar and click inside the group G_CUSTOMER. This creates a new summary. Open the property palette for the new column and name it PCT_CUST.In the Summary section select the function % of Total.The Source is CUST_TOTAL.Reset at G_CUSTOMER.Compute at G_NAME.

c Make all the new summaries four characters wide.

d Run and test the report.

e Save the report as p9q2.rdf and close it.

3 Create a new report using the Report Wizard.

a Choose a Tabular report style and display the following information:

Table Column Label

s_product id Id

name Name

short_desc Description

s_image filename picture

Page 202: Oracle Developer: Build Reports

A-48 Oracle Developer: Build Reports......................................................................................................................................................

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

b Restrict the query to return only products with ID beginning with 10 or 30 because you do not have picture files for all products.Enter the following:WHERE S_PRODUCT.ID LIKE ’10%’OR S_PRODUCT.ID LIKE ’30%’into the query.You can also use the Query Builder to create complex WHERE clauses.Click in the condition fields in the Conditions panel. Then select the column ID from the S_PRODUCT table. This copies the name of the column into the condition field.Enter LIKE ’10%’ into the condition field and press Return.Enter S_PRODUCT.ID LIKE ’30%’ and press Return.You will see AND in the box to the left.To put an OR between the two conditions select AND, then choose Or from the toolbar.

c Run the report.

d In the Data Model change the properties for the column “filename” to read from file, file format image.

e Use the Report Wizard to redo the layout.

f In the Live Previewer resize the picture column to about 3x3 inches. Hint: You need to enable Flex Mode. Use the last image on the page to resize the picture column

g Save the report as p9q3.rdf and close it.

4 Open report p9q1.rdf to list the orders ranked by their total.

a In the Data Model add a new column s_ord.total to the query.Hint: You will have to move the new column TOTAL to the G_ORD group.Any new column is added in the lowest group, so you must move it up to G_ORD.

b Because you want to list the highest total first, set the break order for TOTAL accordingly, and move the TOTAL column so that it is first in the G_ORD group. Set the break order for TOTAL to Descending. Click and drag TOTAL to be the first column in the group G_ORD.

Page 203: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-49......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 9

c To display the ranking add another column called RANK in the group G_ORD.Create a summary column in the group G_ORD.Name it Rank. Select the function Count.The Source is ID.Reset at Report.

d Use the Report Wizard to display the rank, giving it a width of 2. You do not need to display the total, because there is already a total on the G_ITEM group.

e Run the report to test.

f Save the report as p9q4.rdf and close it

If You Have Time5 Open report p9q1.rdf to display the highest and lowest orders at the end

of the report.

a In the Data Model add the columns necessary to list the maximum order total and the corresponding ID as well as the minimum order total and the corresponding ID.Hint: You need one formula column and some summaries and placeholders. You can import the code for the formula column from the file p9q5.txt.

At report level create two summary columns:

Name Function Source Reset At

CS_Max Maximum SumLine_totalPerID Report

CS_Min Minimum SumLine_totalPerID Report

Page 204: Oracle Developer: Build Reports

A-50 Oracle Developer: Build Reports......................................................................................................................................................

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

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.

Page 205: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-51......................................................................................................................................................

......................................................................................................................................................Practice Session Overview: Lesson 10

Practice Session Overview: Lesson 10This practice session contains:

• Opening an existing report to add header and trailer pages

• Modifying an existing report to add a button to display a multimedia column

• Modifying an existing report to add a repeating frame to the header section displaying order information.

• Opening an existing report and adding flexible lines

• Modifying an existing report to anchor a boilerplate object to an outer frame

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

Page 206: Oracle Developer: Build Reports

A-52 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Solutions: Lesson 101 Open report p9q4.rdf. Modify the report as follows:

a Create a header section. Open the Layout Model editor. Choose Header Section from the horizontal toolbar or choose Layout Section—>Header Section from the menu. Make sure that you are editing the Body region.Display the summitlo.tif file as fixed boilerplate in the Body region. Choose File—>Import—>Image from the menu to import the file. Move and resize it.Add a rectangle boilerplate object. Give it fill color.Choose the Rectangle tool from the vertical toolbar. Make the rectangle large enough to fit the logo inside. Choose Fill Color from the vertical toolbar.Place the logo on top of the rectangle. Center the two objects.Select the rectangle and choose Arrange—>Send To Back from the menu.Select the logo, press the [Shift] key, and select the rectangle.Choose Arrange—>Align Objects from the menu. In the dialog box select Align to Each Other and then Align Center both horizontally and vertically. Choose OK.Hint: Use the Arrange option from the menu.

b Add a report title in the body region.Use font Arial, size 18 bold.Choose the Text tool from the vertical toolbar and click in the layout area. Enter the text and click outside the text object.While the text object is selected, choose font and size from the stylebar.

Page 207: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-53......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 10

c Add a trailer section that displays today’s date with the text “End of 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].

Page 208: Oracle Developer: Build Reports

A-54 Oracle Developer: Build Reports......................................................................................................................................................

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

b Add a button to display the picture from the multimedia column.Give it a meaningful label. In the Object Navigator, change the name to PICTURE_BUTTONChoose the button tool from the vertical toolbar and create a button in place of the f_filename field.Make the following changes in the property palette:

c Resize the other layout fields to 1/4 inch in height.Hint: Use the Arrange option on the menu.Select all the layout fields by shift-clicking them.Choose Arrange—>Size Objects from the menu.Select Custom for height and enter .25.

d Make the button the same size.Hint: Use the Arrange option on the menu.

e Give all fields and the button the same vertical alignment.Hint: Use the Arrange option on the menu.Align the fields and the button using Arrange—>Align Objects from the menu.

f Resize the repeating frame and all enclosing frames to be just large enough to fit the fields inside.Hint: Think of Flex Mode.Enable Flex Mode and resize the repeating frame.

g Save the report as p10q2.rdf and close it.h Run and test your report. Do not use the Live Previewer; use Reports

Runtime.

i Choose File—>Administration—>Convert to convert the .rdf file into a .rep file. Now invoke the Reports Runtime and test your report.

Property Value

Label Type Text

Text Picture

Type Multimedia Column

Multimedia Column Filename

Page 209: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-55......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 10

3 Open report p9q1.rdf.

a Modify the report to list all orders and order dates contained in the report in the Body region of the Header section. Open the Layout Model editor. Choose Header Section from the horizontal toolbar, or choose View —>Layout Section—>Header Section from the menu. Make sure that you are editing the Body region.Choose the Additional Default layout tool from the vertical toolbar and click in the Layout area. In the Report Wizard choose a tabular layout.Select the group G_ORD and give a print direction down.Select the fields ID and DATE_ORDERED.

b Save the report as p10q3.rdf and close it.4 Open report p5q3.rdf.

a Use the Report Wizard to give last_name and first_name a width of 6 (you can also do it directly in the Layout Model or from the Live Previewer).

b Add flexible lines vertically between the fields.Choose the line tool from the vertical toolbar. Create lines between the fields. If you want to ensure that the lines are vertical, press the [Shift] key while drawing. Make the lines the same height as the fields using the Arrange—>Size Objects menu option.In the property palette, set Line Stretch with Frame to R_G_LAST_NAME.

c Run and test the report.

d Save the report as p10q4.rdf.

Page 210: Oracle Developer: Build Reports

A-56 Oracle Developer: Build Reports......................................................................................................................................................

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

If You Have Time5 Continue with report p10q4.rdf.

a Add boilerplate and anchor it to halfway down the right side of the Report Group frame.Hint: To ensure that you get the right frame, select the frame M_G_LAST_NAME_GRPFR. You can use either the Object Navigator or the Select Parent Frame tool. Pull the frame out slightly to the right. After you have fastened your anchor, you can make it smaller again.Choose the Text tool from the vertical toolbar and click to the right of the layout objects. Enter the text and click outside the text object.Give it a line color. This makes it easier to click on the edge.Click on a field and choose Select Parent Frame from the style bar twice to select the group frame. Drag the right edge a little to the right to make the frame larger.Select the Anchor tool from the vertical toolbar and click the left edge of the boilerplate text object. Then click the right edge of the group frame. You can press the [Shift] key while you create the anchor to anchor it at 50% of the edges or you can make the adjustments later in the property palette of the anchor.Move the boilerplate so that the anchor is a straight horizontal line.Resize the group frame to its original size.

b Run and check that the text is in fact halfway down the data output.

c Rerun the report, this time displaying only 10 rows. The boilerplate should still be halfway down the data output.Create a group filter in the Data Model editor to restrict the number of records.

d Save the report as p10q5.rdf and close it.

Page 211: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-57......................................................................................................................................................

......................................................................................................................................................Practice Session Overview: Lesson 11

Practice Session Overview: Lesson 11This practice session contains:

• Modifying the printing of a mailing label report

• Controlling the number of records on a page

• Adding a link file to a report

• Ensuring that all details of a master print on the same page

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

Page 212: Oracle Developer: Build Reports

A-58 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Solutions: Lesson 111 Open report p4q4.rdf.

a Modify the layout so that the mailing labels are 2 inches wide and 1 inch high. Use the Arrange option on the menu. Ensure that the company names are printed in alphabetical order across the page.Open the Layout Model editor. Select the repeating frame: either select the boilerplate object in the Layout Model editor and then choose Select Parent Frame from the style bar,or select the repeating frame in the Object Navigator.While the Layout Model editor is the active window, choose Arrange—>Size Objects from the menu. Select Custom for both width and height and enter the width and height in the fields below.You can also drag the repeating frame in the Layout Model editor to the desired width and height.Add an ORDER BY clause to the query.

b Give each label a solid fill.Choose Fill Color from the vertical toolbar and select a color.

c Make the boilerplate object 1.8 inches wide and center it horizontally and vertically in the repeating frame.Select the boilerplate object in the Layout Model editor and choose Arrange—>Size Objects from the menu. Select Custom for the width and No Change for the height. Enter the width in the field below.Select both the boilerplate object and the repeating frame and choose Arrange—>Align Objects from the menu.

d Add spacing between the labels: .25 inch between each column of labels across the page; .5 inch between each row of labels down the page.Select the repeating frame and open the property palette. Set Horizontal Space Between Frames to .25 and Vertical Space Between Frames to .5.

e Save the report as p11q1.rdf.

Page 213: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-59......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 11

2 Continue with report p11q1.rdf.

a Modify the report so that only six labels are printed on each page.Select the repeating frame and open the property palette. Set Maximum Records per Page to 6.

b Save the report as p11q2.rdf and close it.

3 Open p9q1.rdf.

a On the operating system copy the file summitlo.tif to a file logo.tif.Ask your instructor for help, because this is operating-system specific.

b Delete the logo in the margin area and create a link file in its place to display the contents of logo.tif.Choose Margin from the horizontal toolbar, or choose Layout Section—>Margin View from the menu.Select the logo boilerplate object and press [Delete].Choose the Link File tool from the vertical toolbar and create an external boilerplate object in the margin region where the logo was.Set the following properties:

c Run the report.

d On the operating system copy any other .tif file to logo.tif.Ask your instructor for help, because this is operating-system specific.

e Rerun your report.

f Save the report as p11q3.rdf.

Property Value

Name B_logo

Source File Format Image

Source File Name logo.tif

Page 214: Oracle Developer: Build Reports

A-60 Oracle Developer: Build Reports......................................................................................................................................................

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

4 Continue with report p11q3.rdf.

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

b Save the report as p11q4.rdf and close it.

Page 215: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-61......................................................................................................................................................

......................................................................................................................................................Practice Session Overview: Lesson 12

Practice Session Overview: Lesson 12This practice session contains:

• Modifying an existing report to use a bind parameter

• Adding a dynamic list of values

• Adding a lexical parameter

• Adding a static list of values

• Creating a customized parameter form

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

Page 216: Oracle Developer: Build Reports

A-62 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Solutions: Lesson 121 Open report p11q3.rdf.

a In the Report Wizard add the following columns from the S_CUSTOMER table. Create a new group for the customer information above the Order group.

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

AND s_customer.id =:p_customer

b Run and test the report with valid customer IDs.Choose any number in the range 201 to 215.

c Save the report as p12q1.rdf. Do not close it.

2 Continue with report p12q1.rdf.

Add a list of values to select any valid customer ID in the S_CUSTOMER table. Do not allow users to enter any other value. The list should display customer names, not ID numbers.In the Object Navigator, expand the Data Model node and the User Parameter node. Open the property palette for the P_CUSTOMER parameter and make sure that the datatype is Number.In the parameter property palette, choose List of Values.In the dialog box, choose Select Statement.Make sure that the Restrict List to Predetermined Values check box is selected.

Column Label Width

NAME 30

ADDRESS 30

CITY 30

Page 217: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-63......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 12

Select the Hide First Value check box.Enter the following statement in the Enter Query area:SELECT id, name FROM s_customerORDER BY name

d Run and test the report with different values.

e Save the report as p12q2.rdf. Do not close it for the moment.

3 Open report p5q3.rdf.

a Create a lexical parameter to enable users to order the data by different columns (or not at all) at run time. Replace the ORDER BY clause in the query with a lexical reference to the parameter. Type in an initial value for the parameter to order by the employee’s last name.In the Object Navigator, expand the Data Model node. Double-click the User Parameter node to create a parameter.Select the parameter name P_1 and change it to P_ORDER.Open the parameter property palette. Make sure that the datatype is Character and increase the width to 50. Enter an Initial Value: ORDER BY s_emp.last_name

In the Data Model, open the query property palette and add the following lexical reference to the end of the query:&P_ORDER

b Add a static list of values. Code two or three alternative ORDER BY clauses. Allow any clause to be entered at run time.In the parameter property palette choose List of Values.In the dialog box choose Static Values and enter other ORDER BY clauses in the Value field; for example:ORDER BY s_emp.last_name

ORDER BY s_emp.title

For each value, remember to choose Add>> to add the value to the list.Clear the Restrict List to Predetermined Values check box.

Page 218: Oracle Developer: Build Reports

A-64 Oracle Developer: Build Reports......................................................................................................................................................

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

c Run the report to test.Select an ORDER BY clause from the list.Enter your own ORDER BY clause.Delete the default parameter value.

d Save the report as p12q3.rdf and close it.

4 Continue with report p12q2.rdf.

a Create a default parameter form.Include a Title message but not a Hint message.Display the parameters DESNAME and P_CUSTOMER.Select Tools—>Parameter Form Builder from the menu.Enter your own Title message. Delete the Hint message.Select DESNAME.P_ORDER is already selected.

b Use your imagination to customize the form in the Parameter Form editor.Make sure that the parameter P_CUSTOMER is placed in a prominent position for user entry.Add some graphics; modify colors and fill patterns.No formal solution.

c Run the report to test.

d Save the report as p12q4.rdf and close it.

Page 219: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-65......................................................................................................................................................

......................................................................................................................................................Practice Session Overview: Lesson 13

Practice Session Overview: Lesson 13This practice session contains:

• Using the Chart Wizard to create a chart in an existing report

• Altering the chart with the Chart Wizard

• Creating charts in an existing report that will be printed once for each record of a group

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

Page 220: Oracle Developer: Build Reports

A-66 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Solutions: Lesson 131 Open report p12q1.rdf.

a Remove all reference to the parameter P_CUSTOMER from the query.Open the Data Model editor.Use the right mouse button to open the Query dialog box.Delete the row:AND S_CUSTOMER.ID = :P_CUSTOMER

b Rename SumLine_totalPerNAME to Total (a shorter name looks better in a chart).Open the property palette for SumLine_totalPerNAME to change the name, or make the change in the Object Navigator.

c Use the Chart Wizard to create a line chart.Choose Tools—>Chart Wizard from the menu and enter the following properties in the wizard pages:

d Run report to test. Resize the chart if necessary.

e Close the Graphics Batch.

f Save report to p13q1.rdf.

Chart Type Line

Chart Subtype Plain

Category NAME

Value TOTAL

Position At the beginning of the report

File Name p13q1.ogd

Page 221: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-67......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 13

2 Reenter the Chart Wizard to change the characteristics of the chart created in the previous exercise.Make sure that the chart is selected; otherwise you will create a new chart.Choose Chart Wizard from the horizontal toolbar or Tools—> Chart Wizard from the menu.a Give the chart the following characteristics:

Enter the following properties in the wizard pages:

b Run the report to test.

c Close the Graphics Batch.

d Save report to p13q2.rdf and close it.3 Open report p8q5.rdf.

a Use the Chart Wizard to create a pie chart for the data group G_PRODUCT.Choose Chart Wizard from the horizontal toolbar or Tools—> Chart Wizard from the menu, and enter the following properties in the wizard pages:

Title Ordertotal per Customer

Chart Style Column

Chart Subtype Depth

Chart Type Pie

Chart Subtype Plain

Data Group G_product

Category PRODUCT_ID

Value PROD_TOTAL

Chart Frequency Once per Name

File Name p13q3a.ogd

Page 222: Oracle Developer: Build Reports

A-68 Oracle Developer: Build Reports......................................................................................................................................................

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

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.

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

Page 223: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-69......................................................................................................................................................

......................................................................................................................................................Practice Session Overview: Lesson 14

Practice Session Overview: Lesson 14This practice session contains:

• Opening and changing an existing matrix report

• Building a nested matrix report

• Adding summaries to the nested matrix report

• Displaying zeros for summary values and restricting the number of columns per page

• Displaying more meaningful column information and rotating the text

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

Page 224: Oracle Developer: Build Reports

A-70 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Solutions: Lesson 141 Open report p4q6.rdf.

a Use the Report Wizard to apply a template file to the report. The file corpmat.tdf should be located in your working directory. The new template gives you spaces between the layout objects to make it easier to see the different objects in the Layout editor.

b How many repeating frames do you have?There are two repeating frames, R_G_NAME and R_G_PRODUCT_ID.

c Change the properties of the cell object to display zero for a null value.Open the property palette for F_SumTOTAL_VALUE and set Value if Null to 0.

d Run and test the report.All cells without a value now display 0.

e Close the report without saving it.

2 Create a new report, importing the external query p4q6.sql from your working directory.Choose File—>New—Report from the menu, or open a new report in the Object Navigator. Use the Report Wizard.a Choose the following settings:

Report Style Matrix

Query Import file p4q6.sql

Matrix Row Fields Level 1 - Month

Level 2 - Name

Matrix Column Fields Product_id

Matrix Cell Fields Sum of total_value

Matrix Totals Sum of the cell field

Page 225: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-71......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 14

b Change the labels and widths for the following fields:

c Run the report.

d Which summaries were created?SumTOTAL_VALUEPerName SumTOTAL_VALUEPerPRODUCT_ID SumTOTAL_VALUEPerReportThese are the row, the column, and the report summaries.

Field Label Width

NAME Customer 10

PRODUCT_ID Product 5

MONTH Month 4

SUMTOTALVALUE Total 5

All Summaries Total: 5

Page 226: Oracle Developer: Build Reports

A-72 Oracle Developer: Build Reports......................................................................................................................................................

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

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

Property Value

Name F_SumMonthProduct

Source SumMonthProduct

Page 227: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-73......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 14

Choose the Field tool from the vertical toolbar.Create a field below F_SumSumTOTAL_VALUEPerNAME. Position the field in the R_G_MONTH repeating frame but outside any other repeating frames.Set the following properties:

g Run and test the report.

h Save the report as p14q2.rdf. Do not close it.

3 Continue with the report from the previous exercise.

a Add zeros for null values in the cells.Open the property palette for F_SumTOTAL_VALUE and set Value if Null to 0.

b Ensure that the report shows only three product columns on each page.Open the property palette for R_G_PRODUCT_ID and set Maximum Records per Page to 3.

c Format all numeric data to be right aligned.Use the style bar.

d Add commas and two decimal places where appropriate.Use the style bar.

e Run and test the report.

f Save the report as p14q3.rdf and close it.

If You Have Time4 Open the report as p14q3.rdf.

a Make the necessary changes in the Data Model editor to include the product name.

Property Value

Name F_SumMonth

Source SumMonth

Page 228: Oracle Developer: Build Reports

A-74 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................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 PRODUCTFROM S_CUSTOMER, S_ITEM, S_ORD, S_PRODUCTWHERE S_ITEM.PRODUCT_ID LIKE ’4%’ AND S_ITEM.ORD_ID=S_ORD.IDAND S_PRODUCT.ID=S_ITEM.PRODUCT_IDAND S_ORD.CUSTOMER_ID=S_CUSTOMER.IDGROUP 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.

Page 229: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-75......................................................................................................................................................

......................................................................................................................................................Practice Session Overview: Lesson 15

Practice Session Overview: Lesson 15This practice session contains:

• Creating a format trigger to conditionally display different layouts

• Creating and use a report-level PL/SQL function

• Creating and use an external PL/SQL library

• Creating a PL/SQL group filter

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

Page 230: Oracle Developer: Build Reports

A-76 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Solutions: Lesson 151 Create a new report, using p15q1.sql.

a Display the records in two different layouts, showing different columns in each.

b Create a Group Above layout using the following columns from the query:Create a new report, using the Report Wizard. Import the SQL Query from file p15q1.sql.Display the following fields. Choose Labels and other properties as you wish.

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.

Group Column

G_CUSTOMER CUSTOMER_ID

G_ID ID

DATE_ORDERED

DATE_SHIPPED

PAYMENT_TYPE

TOTAL

Column

ID

DATE_ORDERED

DATE_SHIPPED

TOTAL

Page 231: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-77......................................................................................................................................................

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

Page 232: Oracle Developer: Build Reports

A-78 Oracle Developer: Build Reports......................................................................................................................................................

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

2 Continue with the previous report.

a Modify the report so that the Tabular (Preview) layout displays an extra column that indicates, with an asterisk, those orders that were shipped more than 15 days after the order date.Create a new Program Unit, either from the Tools menu or in the Object Navigator. Create a function called ASTERISK:function asterisk(odate date, sdate date)

return varchar2 isbegin if odate + 15 < sdate then return(’*’); else return(’’); end if;

end;

In the Data Model editor, create a formula column in the detail group G_ORD. Open the property palette and alter the following properties for the column CF_ASTERISK:

Click PL/SQL Formula to open the PL/SQL editor, and call the ASTERISK function from the formula.function CF_asteriskFormula return varchar2 isbegin 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.

Name Datatype Width

CF_ASTERISK Character 1

Page 233: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-79......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 15

c Move the function code into a new PL/SQL library named p15lib.pll.In the Object Navigator, create a new library.Open the Library node and click and drag the ASTERISK function into the Program Unit node below the library.Delete the report-level ASTERISK function. Attach the library to the report.

d Call the external function from your report instead of calling the report-level function.

e Save the report to p15q2.rdf.

3 Continue with the previous report.

a Modify the same layout to display additional spacing between every two records.

b Save the report as p15q3.rdf and close it.

Page 234: Oracle Developer: Build Reports

A-80 Oracle Developer: Build Reports......................................................................................................................................................

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

If You Have Time4 Open report p15q1.rdf.

a Write your own group filter to restrict the number of customers displayed depending on the value of a parameter that you enter at runtime.Hint: You need to create two parameters, to keep track of how many records have been processed compared to the cutoff number of records required.In the Object Navigator, open the Data Model node, and double-click the User Parameters node to create the first parameter.Choose the Create tool to create a second parameter.Rename the parameters P_COUNT_CUST and P_CUTOFF.Give P_COUNT_CUST an initial value of 0.Open the G_CUSTOMER_ID group property palette.Set Filter Type to PL/SQLChoose PL/SQL Filter to open the PL/SQL editor. Enter the following code:

function G_CUSTOMER_IDGroupFilter return boolean isbegin

:p_count_cust := :p_count_cust + 1; if :p_count_cust <= nvl(:p_cutoff, :p_count_cust) then return(TRUE); else return(FALSE); end if;

end;

b Test the report several times by changing the cutoff parameter at runtime.

c Save the report as p15q4.rdf.

Page 235: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-81......................................................................................................................................................

......................................................................................................................................................Practice Session Overview: Lesson 16

Practice Session Overview: Lesson 16This practice session contains:

• Building a report containing conditional highlighting

• Building a drill-down report

• Writing to a temporary table from a report

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

Page 236: Oracle Developer: Build Reports

A-82 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Solutions: Lesson 161 Open report p8q5.rdf.

a Display the column CUST_TOTAL in the customer group as red, bold italics if its value is 10,000 or more.Hint: Check the Help system for the SRW.SET <attributes> or use conditional formatting.

You can import the file p16q1a.txt.Open the PL/SQL editor and create a function to apply the format attributes.function FIELD_MASK return boolean isbegin

srw.set_text_color(’red’); srw.set_font_weight(srw.bold_weight);

srw.set_font_style(srw.italic_style);

return(TRUE);end;

Mask Attribute Suggested ValueSRW.SET_TEXT_COLOR RedSRW.SET_FONT_WEIGHT SRW.BOLD_WEIGHTSRW.SET_FONT_STYLE SRW.ITALIC_STYLE

Page 237: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-83......................................................................................................................................................

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

You can import the file p16q1b.txt.Open the PL/SQL editor and create a function to apply the format attributes.

function RECORD_MASK return boolean isbegin

srw.set_foreground_fill_color(‘yellow’);srw.set_background_fill_color(‘green’);srw.set_fill_pattern(‘crisscross’);

return(TRUE);end;

Attribute Suggested Values

Fill pattern Crisscross, sandpaper

Foreground fill color Yellow

Background fill color Green

Page 238: Oracle Developer: Build Reports

A-84 Oracle Developer: Build Reports......................................................................................................................................................

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

c Write the necessary format triggers.Create a format trigger on the F_CUST_TOTAL field to call the function.

function F_CUST_TOTALFormatTrigger return boolean isbegin

if :cust_total >= 10000 then return(field_mask); else return(TRUE); end if;

end;

Create a format trigger on the R_G_CUSTOMER repeating frame to call the function.

d Save the report as p16q1.rdf.

function R_G_CUSTOMERFormatTrigger return boolean isbegin if :cust_total <= 5000 then return(record_mask); else return(TRUE); end if;end;

Page 239: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-85......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 16

2 Call a drill-down report using a button.

a Continue with the previous report.

b Alter query Q_2 to include the customer ID, but do not display it in the report.Use the right mouse button to open the Query dialog box.The query should read:

SELECT S_ORD.SALES_REP_ID, S_CUSTOMER.NAME CUSTOMER, SUM(S_ORD.TOTAL) CUST_TOTAL, S_ORD.CUSTOMER_IDFROM S_ORD, S_CUSTOMERWHERE S_ORD.CUSTOMER_ID=S_CUSTOMER.IDGROUP BY S_ORD.SALES_REP_ID, S_CUSTOMER.NAME, S_ORD.CUSTOMER_ID

Add a button to this report to display a drill-down report when the button is 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 isbeginsrw.run_report(’report=s12q1.rdfp_customer=’||to_char(:customer_id)||’ paramform=no’);end;

Page 240: Oracle Developer: Build Reports

A-86 Oracle Developer: Build Reports......................................................................................................................................................

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

d Save the report as p16q2.rdf.

e Test the report using the run time executable and then close the run time.

If You Have Time3 Open report p9q1.rdf.

In this report, you use report triggers to create a temporary table at the start of report execution, and you insert rows into the table at various stages of the execution.

a Write a trigger that creates a temporary table to hold the date and userid each time the report is run. The table should contain three columns: one date column, one character column of width 10, and one character column of width 80.CREATE TABLE RUNREPORT(DATE_RUN DATE, USER_RUN VARCHAR2(10), COMMENTS VARCHAR2(80)

In the Object Navigator, expand the Report Triggers node, and double-click the Before Report PL/SQL icon to open the PL/SQL editor. Create the following function: function BeforeReport return boolean isbegin

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;

Page 241: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-87......................................................................................................................................................

......................................................................................................................................................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’)

Hint: Think about how you code the single quotes.Add the following code:function BeforeReport return boolean isbeginsrw.do_sql(’CREATE TABLE RUNREPORT (DATE_RUN DATE, USER_RUN VARCHAR2(10), COMMENTS VARCHAR2(80))’);srw.do_sql(’INSERT INTO RUNREPORT (DATE_RUN, USER_RUN, COMMENTS) VALUES (SYSDATE, USER, ’’Starting Report’’)’);return(TRUE);end;

c Save the report as p16q3.rdf.

d Compile the PL/SQL and run the report. Be sure to view more than one page.

e Run and test the report.

f Using SQL*Plus, verify that your table exists and was populated successfully.

g Log on to SQL*Plus (in Microsoft Windows, select the SQL*Plus icon in the Oracle group) using the same userid as you used for Reports.

h Display all records in the RUNREPORT table.SQL> col comments format a40SQL> SELECT * FROM RUNREPORT;

Page 242: Oracle Developer: Build Reports

A-88 Oracle Developer: Build Reports......................................................................................................................................................

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

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;

Page 243: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-89......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 16

j Write a trigger that inserts a record with the comment “Printing another page” whenever it begins a new page.In the Object Navigator, expand the Report Triggers node, and double-click the Between Pages PL/SQL icon to open the PL/SQL editor. Or, if the editor is already open, change the Name to Between Pages. Create the following function.

function BetweenPage return boolean isbegin

srw.do_sql(’INSERT INTO RUNREPORT (DATE_RUN, USER_RUN, COMMENTS) VALUES (SYSDATE, USER, ’’Printing another page’’)’); return(TRUE);

end;

k Write a trigger that inserts a record with the comment “Report completed” when the report finishes. Save and run the report. In the Object Navigator, expand the Report Triggers node and double-click the After Report PL/SQL icon to open the PL/SQL editor. Or, if the editor is already open, change the Name to After Pages. Report the following function:

function AfterReport return boolean isbegin

srw.do_sql(’INSERT INTO RUNREPORT (DATE_RUN, USER_RUN, COMMENTS) VALUES (SYSDATE, USER, ’’Report Completed’’)’); return(TRUE);

end;

l Verify the results in SQL*Plus.

Page 244: Oracle Developer: Build Reports

A-90 Oracle Developer: Build Reports......................................................................................................................................................

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

Practice Session Overview: Lesson 17This practice session contains:

• Running a report on your local machine

• Running reports on a remote server using the report Queue Manager

• Copying output from remote server to your local machine

• Running a report on a remote server using the command line

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

Page 245: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-91......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 17

Practice Session Solutions: Lesson 17 1 Run longrun1.rdf on your local client machine.

a Open longrun1.rdf and run the report. Notice the time it takes for the report to run to completion. If it has not completed within five minutes, note how many pages have been formatted, then cancel the report.Note: Make sure that DESTYPE=FILE is set in the Parameter Form when running this report.

2 Run longrun1.rdf and longrun2.rdf by calling the Reports Server from the Queue Manager.Note: Your instructor will give you specific instructions to complete this exercise. The location of the remote server, directory paths, and so on might differ for your class.

a Invoke the Queue Manager. Enter repserver1 as your server name. Note if there are any jobs in the queue.

b Schedule a new job to run longrun1.rdf report on the Reports Server. Choose applicable settings from the tab pages of the Queue Manager. For Destination Type choose ToLocalFile, ToFile, or Cache; the report default is Screen, which is not valid when running a remote report.Choose Job—>New from the menu, then choose Set Options.In the dialog box enter the following information:

Tab Parameter Value

General Report Name longrun1.rdf

Type 7 - ToServerCache

Data Connection User Name Your User Name

Password Your Password

Database Your Database

Output Options Output Driver PDF

Page 246: Oracle Developer: Build Reports

A-92 Oracle Developer: Build Reports......................................................................................................................................................

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

c Do the same for longrun2.rdf.Choose Job—>New from the menu, then choose Set Options. In the dialog box enter the following information:

d Display 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.

Tab Parameter Value

General Report Name longrun2.rdf

Type 7 - ToServerCache

Data Connection User Name Your User Name

Password Your Password

Database Your Database

Output Options Output Driver PDF

Page 247: Oracle Developer: Build Reports

Oracle Developer: Build Reports A-93......................................................................................................................................................

......................................................................................................................................................Practice Session Solutions: Lesson 17

If You Have Time4 Run longrun1.rdf by scheduling a new job from the command line.

a Using RWCLI60 from the command line, submit your longrun1.rdf report to the Reports Server.Your instructor will give you specific instructions to complete this exercise because this is operating-system specific.

b Make sure that the output is in PDF format and that it is cached.On Windows platforms enter the following command:RWCLI60 LONGRUN1.RDF USERID=<userid>/<password> @<alias> SERVER=repserver1 DESTYPE=CACHE DESFORMAT=PDF

Page 248: Oracle Developer: Build Reports

A-94 Oracle Developer: Build Reports......................................................................................................................................................

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

Page 249: Oracle Developer: Build Reports

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

Table Descriptions andData

B

Page 250: Oracle Developer: Build Reports

B-2 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

Summit Sporting Goods Database Diagram

*Unique occurrences are identified by PRODUCT_ID and WAREHOUSE_ID.

S_ITEM

S_INVENTORY

S_ORD

S_CUSTOMER

S_EMP

S_DEPT

S_IMAGE

S_PRODUCT

ORD_IDID

SALES_REP_ID

PRODUCT_ID

CUSTOMER_ID

SALES_REP_ID

DEPT_ID

IMAGE_ID

PRODUCT_ID

ID

ID

ID

IDID

ID

*

ID

Page 251: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-3......................................................................................................................................................

.....................................................................................................................................................S_CUSTOMER Description

S_CUSTOMER DescriptionColumn 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)

Page 252: Oracle Developer: Build Reports

B-4 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_CUSTOMER Data

SQL> SELECT * FROM s_customer;

Id Name Phone Address

------ ------------------ ------------ -----------

City State Country

------------------ ---------------- -----------

Zip_code Credit_ra Sales_rep_id Region_id

---------- --------- ------------ ---------

Comments

--------------------------------------------------

201 Unisports 55-2066101 72 Via Bahia

Sao Paolo Brazil

Excellent 12 2

Customer Usually Orders Large Amounts And Has A High Order Total. This Is Okay As Long As The Credit Rating Remains Excellent.

202 Oj Atheletics 81-20101 6741 Takashi Blvd.

Osaka Japan

Poor 14 4

Customer Should Always Pay By Cash Until His Credit Rating Improves.

203 Delhi Sports 91-10351 11368 Chanakya

New Delhi India

Good 14 4

Customer Specializes In Baseball Equipment And Is The Largest Retailer In India.

Page 253: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-5......................................................................................................................................................

.....................................................................................................................................................S_CUSTOMER Data

S_CUSTOMER Data (continued)

Id Name Phone Address

------ ------------------ ------------ -----------

City State Country

------------------ ---------------- -----------

Zip_code Credit_ra Sales_rep_id Region_id

---------- --------- ------------ ---------

Comments

--------------------------------------------------

204 Womansport 1-206-104-0103 281 King Street

Seattle Washington USA

98101 EXCELLENT 11 1

205 Kam’s Sporting Goods 852-3692888 15 Henessey Road

Hong Kong EXCELLENT 15 4

206 Sportique 33-2257201 172 Rue de Rivoli

Cannes France

EXCELLENT 15 5

Customer specializes in Soccer. Likes to order accessories in bright colors.

207 Sweet Rock Sports 234-603620 6 Saint Antoine

Lagos Nigeria

Page 254: Oracle Developer: Build Reports

B-6 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_CUSTOMER Data (continued)

Id Name Phone Address

------ ------------------ ------------ -----------

City State Country

------------------ ---------------- -----------

Zip_code Credit_ra Sales_rep_id Region_id

---------- --------- ------------ ---------

Comments

--------------------------------------------------

208 Muench Sports 49-527454 435 Gruenestrasse

Stuttgart Germany

GOOD 15 5

Customer usually pays small orders by cash and large orders on credit.

209 Beisbol Si! 809-352689 789 Playa Del Mar

San Pedro de Macon’s Dominican Republic

EXCELLENT 11 1

210 Futbol Sonora 52-404562 3 Via Saguaro Nogales

EXCELLENT 12 2

Customer is difficult to reach by phone. Try mail.

211 Kuhn’s Sports 42-111292 7 Modrany

Prague Czechoslovakia

EXCELLENT 15 5

Page 255: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-7......................................................................................................................................................

.....................................................................................................................................................S_CUSTOMER Data

S_CUSTOMER Data (continued)

Note: This display has been formatted.

Id Name Phone Address

------ ------------------ ------------ -----------

City State Country

------------------ ---------------- -----------

Zip_code Credit_ra Sales_rep_id Region_id

---------- --------- ------------ ---------

Comments

--------------------------------------------------

212 Hamada Sport 20-1209211 57A CornicheAlexandria Egypt

EXCELLENT 13 3

Customer orders sea and water equipment.

213 Big John’s Sports 1-415-555-6281 4783 18th Street Emporium

San Francisco CA USA

94117 EXCELLENT 11 1

Customer has a dependable credit record.

214 Ojibway Retail 1-716-555-7171 415 Main Street

Buffalo NY USA

14202 POOR 11 1

215 Sporta Russia 7-3892456 6000 Yekatamina

St. Petersburg Russia

POOR 15 5

This customer is very friendly, but has difficulty paying bills. Insist upon cash.

Page 256: Oracle Developer: Build Reports

B-8 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_DEPT Description and DataColumn Name Null? Datatype---------------------- ------------- --------------ID NOT NULL NUMBER(7)NAME NOT NULL VARCHAR2(25)REGION_ID NUMBER(7)

SQL> SELECT * FROM s_dept;

ID NAME REGION_ID

------ ---------------- -----------------

10 Finance 1

31 Sales 132 Sales 233 Sales 334 Sales 435 Sales 541 Operations 142 Operations 243 Operations 344 Operations 445 Operations 550 Administration 1

12 rows selected.

Page 257: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-9......................................................................................................................................................

.....................................................................................................................................................S_EMP Description

S_EMP DescriptionColumn Name Null? Datatype------------------------ -------------- --------------ID NOT NULL NUMBER(7)LAST_NAME NOT NULL VARCHAR2(25)FIRST_NAME VARCHAR2(25)USERID VARCHAR2(8)START_DATE DATECOMMENT VARCHAR2(255)MANAGER_ID NUMBER(7) TITLE VARCHAR2(25)DEPT_ID NUMBER(7)SALARY NUMBER(11,2)COMMISSION_PCT NUMBER(4,2)

Page 258: Oracle Developer: Build Reports

B-10 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_EMP Data

SQL> SELECT * FROM s_emp;

ID LAST_NAME FIRST_NAME USERID START_DAT

---- ----------------- ---------------- -------- ---------

COMMENTS

--------------------------------------------------------------

MANAGER_ID TITLE DEPT_ID SALARY

---------- ---------------------------- ------- ------

COMMISSION_PCT

---------------

1 Velasquez Carmen cvelasqu 03-MAR-90

President 50 2500

2 Ngao LaDoris lngao 08-MAR-90

1 VP, Operations 41 1450

3 Nagayama Midori mnagayam 17-JUN-91

1 VP, Sales 31 1400

4 Quick-To-See Mark mquickto 07-APR-90

1 VP, Finance 10 1450

5 Ropeburn Audry aropebur 04-MAR-90

1 VP, Administration 50 1550

6 Urguhart Molly murguhar 18-JAN-91

2 Warehouse Manager 41 1200

7 Menchu Roberta rmenchu 14-MAY-90

2 Warehouse Manager 42 1250

8 Biri Ben bbiri 07-APR-90

2 Warehouse Manager 43 1100

9 Catchpole Antoinette acatchpo 09-FEB-92

2 Warehouse Manager 44 1300

Page 259: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-11......................................................................................................................................................

.....................................................................................................................................................S_EMP Data

S_EMP Data (continued)

ID LAST_NAME FIRST_NAME USERID START_DAT

---- ----------------- ---------------- -------- ---------

COMMENTS

--------------------------------------------------------------

MANAGER_ID TITLE DEPT_ID SALARY

---------- ---------------------------- ------- ------

COMMISSION_PCT

---------------

10 Havel Marta mhavel 27-FEB-91

2 Warehouse Manager 45 1307

11 Magee Colin cmagee 14-MAY-90

3 Sales Representative 31 1400

10

12 Giljum Henry hgiljum 18-JAN-92

3 Sales Representative 32 1490

12.5

13 Sedeghi Yasmin ysedeghi 18-FEB-91

3 Sales Representative 33 1515

10

14 Nguyen Mai mnguyen 22-JAN-92

3 Sales Representative 34 1525

15

15 Dumas Andre adumas 09-OCT-91

3 Sales Representative 35 1450

17.5

16 Maduro Elena emaduro 07-FEB-92

6 Stock Clerk 41 1400

Page 260: Oracle Developer: Build Reports

B-12 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_EMP Data (continued)

Note: This display has been formatted.

ID LAST_NAME FIRST_NAME USERID START_DAT

---- ----------------- ---------------- -------- ---------

COMMENTS

--------------------------------------------------------------

MANAGER_ID TITLE DEPT_ID SALARY

---------- ---------------------------- ------- ------

COMMISSION_PCT

---------------

17 Smith George gsmith 08-MAR-90

6 Stock Clerk 41 940

18 Nozaki Akira anozaki 09-FEB-91

7 Stock Clerk 42 1200

19 Patel Vikram vpatel 06-AUG-91

7 Stock Clerk 42 795

20 Newman Chad cnewman 21-JUL-91

8 Stock Clerk 43 750

21 Markarian Alexander amarkari 26-MAY-91

8 Stock Clerk 43 850

22 Chang Eddie echang 30-NOV-90

9 Stock Clerk 44 800

23 Patel Radha rpatel 17-OCT-90

9 Stock Clerk 34 795

24 Dancs Bela bdancs 17-MAR-91

10 Stock Clerk 45 860

25 Schwartz Sylvie sschwart 09-MAY-91

10 Stock Clerk 45 1100

Page 261: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-13......................................................................................................................................................

.....................................................................................................................................................S_ITEM Description

S_ITEM DescriptionColumn 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)

Page 262: Oracle Developer: Build Reports

B-14 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_ITEM Data

SQL> SELECT * FROM s_item;

ORD_ID ITEM_ID PRODUCT_ID PRICE QUANTITY QUANTITY_SHIPPED

------ -------- ----------- ------ -------- -----------------

100 1 10011 135 500 500100 2 10013 380 400 400100 3 10021 14 500 500100 5 30326 582 600 600100 7 41010 8 250 250100 6 30433 20 450 450100 4 10023 36 400 400101 1 30421 16 15 15101 3 41010 8 20 20101 5 50169 4.29 40 40101 6 50417 80 27 27101 7 50530 45 50 50101 4 41100 45 35 35101 2 40422 50 30 30102 1 20108 28 100 100102 2 202011 23 45 45103 1 30433 20 15 15103 2 32779 7 11 11104 1 20510 9 7 7104 4 30421 16 35 35104 2 20512 8 12 12104 3 30321 1669 19 19105 1 50273 22.8 16 16105 3 50532 47 28 28105 2 50419 80 13 13

Page 263: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-15......................................................................................................................................................

.....................................................................................................................................................S_ITEM Data

S_ITEM Data (continued)

Note: This display has been formatted.

ORD_ID ITEM_ID PRODUCT_ID PRICE QUANTITY QUANTITY_SHIPPED

------- ------- ----------- ------ -------- -----------------

106 1 20108 28 46 46106 4 50273 22.89 75 75106 5 50418 75 98 98106 6 50419 80 27 27106 2 20201 123 21 21106 3 50169 4.29 125 125107 1 20106 11 50 50107 3 20201 115 130 130107 5 30421 16 55 55107 4 30321 1669 75 75107 2 20108 28 22 22108 1 20510 9 9 9108 6 41080 35 50 50108 7 41100 45 42 42108 5 32861 60 57 57108 2 20512 8 18 18108 4 32779 7 60 60108 3 30321 1669 85 85109 1 10011 140 150 150109 5 30426 18.25 500 500109 7 50418 75 43 43109 6 32861 60 50 50109 4 30326 582 1500 1500109 2 10012 175 600 600109 3 10022 21.95 300 300110 1 50273 22.89 17 17110 2 50536 50 23 23111 1 40421 65 27 27111 2 41080 35 29 2997 1 20106 9 1000 100097 2 303211 500 50 5098 1 404218 5 7 799 1 20510 9 18 1899 2 20512 8 25 2599 3 50417 80 53 5399 4 50530 45 69 69112 1 20106 11 50 50

62 rows selected.

Page 264: Oracle Developer: Build Reports

B-16 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_ORD Description and DataColumn Name Null? Datatype

------------------------ ------ ---------------------ID NOT NULL NUMBER(7)CUSTOMER_ID NOT NULL NUMBER(7)DATE_ORDERED DATEDATE_SHIPPED DATESALES_REP_ID NUMBER(7)TOTAL NUMBER(11,2)PAYMENT_TYPE VARCHAR2(6)ORDER_FILLED VARCHAR2(1)

SQL> SELECT * FROM s_ord;

ID CUSTOMER_ID DATE_ORDE DATE_SHIPSALES_REP_IDTOTAL PAYMEN ORDER_F

--- ----------- --------- ---------------------------------- ------

100 204 31-AUG92 10-SEP-9211 601100 CREDIT Y101 205 31-AUG-92 15-SEP-9214 8056.6 CREDIT Y102 206 01-SEP-92 08-SEP-9215 8335 CREDIT Y103 208 02-SEP-92 22-SEP-9215 377 CASH Y104 208 03-SEP-92 23-SEP-9215 32430 CREDIT Y105 209 04-SEP-92 18-SEP-9211 2722.24 CREDIT Y106 210 07-SEP-92 15-SEP-9212 15634 CREDIT Y107 211 07-SEP-92 21-SEP-9215 142171 CREDIT Y108 212 07-SEP-92 10-SEP-9213 149570 CREDIT Y109 213 08-SEP-92 28-SEP-9211 1020935 CREDIT Y110 214 09-SEP-92 21-SEP-9211 1539.13 CASH Y111 204 09-SEP-92 21-SEP-9211 2770 CASH Y97 201 28-AUG-92 17-SEP-9212 84000 CREDIT Y98 202 31-AUG-92 10-SEP-9214 595 CASH Y99 203 31-AUG-92 18-SEP-9214 7707 CREDIT Y112 210 31-AUG-92 10-SEP-9212 550 CREDIT Y

16 rows selected.

Page 265: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-17......................................................................................................................................................

.....................................................................................................................................................S_PRODUCT Description

S_PRODUCT DescriptionColumn 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)

Page 266: Oracle Developer: Build Reports

B-18 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_PRODUCT Data

SQL> SELECT * FROM s_product;

ID NAME SHORT_DESC LONGTEXT_ID---- -------------------------- -----------IMAGE_ID SUGGESTED_WHLSL_PRICEWHLSL_UNITS-------- --------------------------------10011 Boot Beginner’s ski boot 5181001 150

10012 Ace Ski BootIntermediate ski boot5191002 200

10013 Pro Ski BootAdvanced ski boot 5201003 410

10021 Bunny Ski PoleBeginner’s ski pole5281011 16.25

10022 Ace Ski PoleIntermediate ski pole5291012 21.95

10023 Pro Ski PoleAdvanced ski pole 5301013 40.95

20106 Junior Soccer BallJunior soccer ball61311

20108 World Cup Soccer BallWorld cup soccer ball61528

20201 World Cup NetWorld cup net 708123

Page 267: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-19......................................................................................................................................................

.....................................................................................................................................................S_PRODUCT Data

S_PRODUCT Data (continued)

ID NAME SHORT_DESC LONGTEXT_ID---- ---------------------------------------IMAGE_IDSUGGESTED_WHLSL_PRICEWHLSL_UNITS----------------------------------------20510 Black Hawk Knee pads, pair 1017

Knee Pads 9

20512Black Hawk Elbow pads, pair 1019Elbow Pads 8

30321 Grand Prix Bicycle Road bicycle828 1291 1669

30326 Himalaya BicycleMountain bicycle8331296 582

30421 Grand Prix Road bicycle tires927Bicycle Tires16

30426 Himalaya TiresMountain bicycle tires93318.25

30433New Air PumpTire pump 94020

32779 Slaker Water Water bottle 1286Bottle 7

32861 Safe-T HelmetBicycle helmet 13681829 60

40421 Alexeyer ProStraight bar 928Lifting Bar

1381 65

40422 Pro Curling BarCurling bar 9291382 50

Page 268: Oracle Developer: Build Reports

B-20 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_PRODUCT Data (continued)

ID NAME SHORT_DESC LONGTEXT_ID---- ---------------------------------------IMAGE_ID SUGGESTED_WHLSL_PRICEWHLSL_UNITS-------- --------------------------------40421 Alexeyer ProStraight bar 928

Lifting Bar1381 65

40422 Pro Curling BarCurling bar 9291382 50

41010 Prostar 10 Ten pound weight 517Pound Weight

8

41020 Prostar 20 Twenty pound weight527Pound Weight

12

41050 Prostar 50 Fifty pound weight557Pound Weight

25

41080 Prostar 80 Eighty pound weight587Pound Weight

35

41100 Prostar 100 One hundred pound 607Pound Weightweight

45

50169 Major League Baseball 676Baseball

1119 4.29

Page 269: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-21......................................................................................................................................................

.....................................................................................................................................................S_PRODUCT Data

S_PRODUCT Data (continued)

Note: This display has been formatted.

ID NAME SHORT_DESC LONGTEXT_ID---- -----------------------------------------IMAGE_IDSUGGESTED_WHLSL_PRICEWHLSL_UNITS---------------------------------------- 50273Chapman HelmetBatting helmet 7801223 22.89

50417 Griffey GloveOutfielder’s glove 9241367 80

50418 Alomar GloveInfielder’s glove 9251368 75

50419 Steinbach GloveCatcher’s glove 9261369 80

50530Cabrera Bat Thirty inch bat 10371480 45

50532 Puckett Bat Thirty-two inch bat 10391482 47

50536 Winfield BatThirty-six inch bat 10431486 50

Page 270: Oracle Developer: Build Reports

B-22 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_REGION Description and DataColumn Name Null? Datatype------------------------------ ----------------ID NOT NULL NUMBER(7)NAME NOT NULL VARCHAR2(50)

SQL> SELECT * FROM s_region;

ID NAME--- --------------------------1 North America2 South America3 Africa / Middle East4 Asia5 Europe

Page 271: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-23......................................................................................................................................................

.....................................................................................................................................................S_TITLE Description and Data

S_TITLE Description and DataColumn Name Null? Datatype---------------------------------- ----------------TITLE NOT NULL VARCHAR2(25)

SQL> SELECT * FROM s_title;

TITLE------------------------PresidentSales RepresentativeStock ClerkVP, AdministrationVP, FinanceVP, OperationsVP, SalesWarehouse Manager

8 rows selected.

Page 272: Oracle Developer: Build Reports

B-24 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

Oracle8 Objects: Types, Tables

emp_type_ObjColName 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)

emp_type_RefColName 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)

Page 273: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-25......................................................................................................................................................

.....................................................................................................................................................Oracle8 Objects: Types, Tables

Tables

oo_emp_Table_ObjColName 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

Page 274: Oracle Developer: Build Reports

B-26 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

ID LAST_NAME FIRST_NAME USERID

---------- ----------------------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

4 Quick-To-See Mark mquickto

07-APR-90 1 VP Finance

DEPT_TYPE(10, ’Finance’, 1)

1450

5 Ropeburn Audry aropebur

04-MAR-90 1 VP Administration

DEPT_TYPE(50, ’Administration’, 1)

1550

6 Urguhart Molly murguhar

18-JAN-91 2 Warehouse Manager

DEPT_TYPE(41, ’Operations’, 1)

1200

7 Menchu Roberta rmenchu

14-MAY-90 2 Warehouse Manager

DEPT_TYPE(42, ’Operations’, 2)

1250

8 Biri Ben bbiri

07-APR-90 2 Warehouse Manager

DEPT_TYPE(43, ’Operations’, 3)

1100

9 Catchpole Antoinette acatchpo

09-FEB-92 2 Warehouse Manager

DEPT_TYPE(44, ’Operations’, 4)

1300

Page 275: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-27......................................................................................................................................................

.....................................................................................................................................................Oracle8 Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

---------- ------------------------------ --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

10 Havel Marta mhavel

27-FEB-91 2 Warehouse Manager

DEPT_TYPE(45, ’Operations’, 5)

1307

11 Magee Colin cmagee

14-MAY-90 3 Sales Representative

DEPT_TYPE(31, ’Sales’, 1)

1400 10

12 Giljum Henry hgiljum

18-JAN-92 3 Sales Representative

DEPT_TYPE(32, ’Sales’, 2)

1490 13

13 Sedeghi Yasmin ysedeghi

18-FEB-91 3 Sales Representative

DEPT_TYPE(33, ’Sales’, 3)

1515 10

14 Nguyen Mai mnguyen

22-JAN-92 3 Sales Representative

DEPT_TYPE(34, ’Sales’, 4)

1525 15

15 Dumas Andre adumas

09-OCT-91 3 Sales Representative

DEPT_TYPE(35, ’Sales’, 5)

145018

Page 276: Oracle Developer: Build Reports

B-28 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

ID LAST_NAME FIRST_NAME USERID

---------- -------------- --------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

16 Maduro Elena emaduro

07-FEB-92 6 Stock Clerk

DEPT_TYPE(41, ’Operations’, 1)

1400

17 Smith George gsmith

08-MAR-90 6 Stock Clerk

DEPT_TYPE(41, ’Operations’, 1)

940

18 Nozaki Akira anozaki

09-FEB-91 7 Stock Clerk

DEPT_TYPE(42, ’Operations’, 2)

1200

19 Patel Vikram vpatel

06-AUG-91 7 Stock Clerk

DEPT_TYPE(42, ’Operations’, 2)

795

20 Newman Chad cnewman

21-JUL-91 8 Stock Clerk

DEPT_TYPE(43, ’Operations’, 3)

750

21 Markarian Alexander amarkari

26-MAY-91 8 Stock Clerk

DEPT_TYPE(43, ’Operations’, 3)

850

Page 277: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-29......................................................................................................................................................

.....................................................................................................................................................Oracle8 Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

---------- ------------------------------ --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

22 Chang Eddie echang

30-NOV-90 9 Stock Clerk

DEPT_TYPE(44, ’Operations’, 4)

800

23 Patel Radha rpatel

17-OCT-90 9 Stock Clerk

DEPT_TYPE(34, ’Sales’, 4)

795

24 Dancs Bela bdancs

17-MAR-91 10 Stock Clerk

DEPT_TYPE(45, ’Operations’, 5)

860

25 Schwartz Sylvie sschwart

09-MAY-91 10 Stock Clerk

DEPT_TYPE(45, ’Operations’, 5)

1100

oo_emp_Table_RefColName 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)

Page 278: Oracle Developer: Build Reports

B-30 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

ID LAST_NAME FIRST_NAME USERID

---------- --------------------------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

1 Velasquez Carmen cvelasqu

03-MAR-90 President

0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408002072C15B

2500

2 Ngao LaDoris lngao

08-MAR-90 1 VP Operations

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1450

3 Nagayama Midori mnagayam

17-JUN-91 1 VP Sales

0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1400

4 Quick-To-See Mark mquickto

07-APR-90 1 VP Finance

0000220208447F54A9ED59676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1450

5 Ropeburn Audry aropebur

04-MAR-90 1 VP Administration

0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1550

Page 279: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-31......................................................................................................................................................

.....................................................................................................................................................Oracle8 Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

---------- ------------------ --------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

6 Urguhart Molly murguhar

18-JAN-91 2 Warehouse Manager

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1200

9 Catchpole Antoinette acatchpo

09-FEB-92 2 Warehouse Manager

0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1300

10 Havel Marta mhavel

27-FEB-91 2 Warehouse Manager

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1307

11 Magee Colin cmagee

14-MAY-90 3 Sales Representative

0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1400 10

13 Sedeghi Yasmin ysedeghi

18-FEB-91 3 Sales Representative

0000220208447F54A9ED5C676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1515 10

Page 280: Oracle Developer: Build Reports

B-32 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

ID LAST_NAME FIRST_NAME USERID

---------- ------------------ --------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

14 Nguyen Mai mnguyen

22-JAN-92 3 Sales Representative

0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1525 15

15 Dumas Andre adumas

09-OCT-91 3 Sales Representative

0000220208447F54A9ED5E676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1450 18

16 Maduro Elena emaduro

07-FEB-92 6 Stock Clerk

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1400

17 Smith George gsmith

08-MAR-90 6 Stock Clerk

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

940

18 Nozaki Akira anozaki

09-FEB-91 7 Stock Clerk

0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1200

Page 281: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-33......................................................................................................................................................

.....................................................................................................................................................Oracle8 Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

---------- --------------------------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

19 Patel Vikram vpatel

06-AUG-91 7 Stock Clerk

0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408002072C15B

795

20 Newman Chad cnewman

21-JUL-91 8 Stock Clerk

0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408002072C15B

750

21 Markarian Alexander amarkari

26-MAY-91 8 Stock Clerk

0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408002072C15B

850

22 Chang Eddie echang

30-NOV-90 9 Stock Clerk

0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408002072C15B

800

23 Patel Radha rpatel

17-OCT-90 9 Stock Clerk

0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408002072C15B

795

Page 282: Oracle Developer: Build Reports

B-34 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

ID LAST_NAME FIRST_NAME USERID

---------- --------------------------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

24 Dancs Bela bdancs

17-MAR-91 10 Stock Clerk

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

860

25 Schwartz Sylvie sschwart

09-MAY-91 10 Stock Clerk

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1100

oo_dept_tableName 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

Page 283: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-35......................................................................................................................................................

.....................................................................................................................................................Oracle8 Objects: Types, Tables

rel_emp_Table_ObjcolName 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

---------- --------------

1 Velasquez Carmen cvelasqu

03-MAR-90 President

DEPT_TYPE(50, ’Administration’, 1)

2500

2 Ngao LaDoris lngao

08-MAR-90 1 VP Operations

DEPT_TYPE(41, ’Operations’, 1)

1450

3 Nagayama Midori mnagayam

17-JUN-91 1 VP Sales

DEPT_TYPE(31, ’Sales’, 1)

1400

Page 284: Oracle Developer: Build Reports

B-36 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

ID LAST_NAME FIRST_NAME USERID

---------- --------------------------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

4 Quick-To-See Mark mquickto

07-APR-90 1 VP Finance

DEPT_TYPE(10, ’Finance’, 1)

1450

5 Ropeburn Audry aropebur

04-MAR-90 1 VP Administration

DEPT_TYPE(50, ’Administration’, 1)

1550

6 Urguhart Molly murguhar

18-JAN-91 2 Warehouse Manager

DEPT_TYPE(41, ’Operations’, 1)

1200

7 Menchu Roberta rmenchu

14-MAY-90 2 Warehouse Manager

DEPT_TYPE(42, ’Operations’, 2)

1250

8 Biri Ben bbiri

07-APR-90 2 Warehouse Manager

DEPT_TYPE(43, ’Operations’, 3)

1100

9 Catchpole Antoinette acatchpo

09-FEB-92 2 Warehouse Manager

DEPT_TYPE(44, ’Operations’, 4)

1300

Page 285: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-37......................................................................................................................................................

.....................................................................................................................................................Oracle8 Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

---------- --------------------------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

10 Havel Marta mhavel

27-FEB-91 2 Warehouse Manager

DEPT_TYPE(45, ’Operations’, 5)

1307

11 Magee Colin cmagee

14-MAY-90 3 Sales Representative

DEPT_TYPE(31, ’Sales’, 1)

1400 10

12 Giljum Henry hgiljum

18-JAN-92 3 Sales Representative

DEPT_TYPE(32, ’Sales’, 2)

1490 13

13 Sedeghi Yasmin ysedeghi

18-FEB-91 3 Sales Representative

DEPT_TYPE(33, ’Sales’, 3)

1515 10

14 Nguyen Mai mnguyen

22-JAN-92 3 Sales Representative

DEPT_TYPE(34, ’Sales’, 4)

1525 15

15 Dumas Andre adumas

09-OCT-91 3 Sales Representative

DEPT_TYPE(35, ’Sales’, 5)

1450 18

Page 286: Oracle Developer: Build Reports

B-38 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

ID LAST_NAME FIRST_NAME USERID

---------- --------------------------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

16 Maduro Elena emaduro

07-FEB-92 6 Stock Clerk

DEPT_TYPE(41, ’Operations’, 1)

1400

17 Smith George gsmith

08-MAR-90 6 Stock Clerk

DEPT_TYPE(41, ’Operations’, 1)

940

18 Nozaki Akira anozaki

09-FEB-91 7 Stock Clerk

DEPT_TYPE(42, ’Operations’, 2)

1200

19 Patel Vikram vpatel

06-AUG-91 7 Stock Clerk

DEPT_TYPE(42, ’Operations’, 2)

795

20 Newman Chad cnewman

21-JUL-91 8 Stock Clerk

DEPT_TYPE(43, ’Operations’, 3)

750

21 Markarian Alexander amarkari

26-MAY-91 8 Stock Clerk

DEPT_TYPE(43, ’Operations’, 3)

850

Page 287: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-39......................................................................................................................................................

.....................................................................................................................................................Oracle8 Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

---------- --------------------------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

22 Chang Eddie echang

30-NOV-90 9 Stock Clerk

DEPT_TYPE(44, ’Operations’, 4)

800

23 Patel Radha rpatel

17-OCT-90 9 Stock Clerk

DEPT_TYPE(34, ’Sales’, 4)

795

24 Dancs Bela bdancs

17-MAR-91 10 Stock Clerk

DEPT_TYPE(45, ’Operations’, 5)

860

25 Schwartz Sylvie sschwart

09-MAY-91 10 Stock Clerk

DEPT_TYPE(45, ’Operations’, 5)

1100

rel_emp_Table_RefColName 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)

Page 288: Oracle Developer: Build Reports

B-40 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

ID LAST_NAME FIRST_NAME USERID

---------- --------------------------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

1 Velasquez Carmen cvelasqu

03-MAR-90 President

0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408002072C15B

2500

2 Ngao LaDoris lngao

08-MAR-90 1 VP Operations

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1450

3 Nagayama Midori mnagayam

17-JUN-91 1 VP Sales

0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1400

4 Quick-To-See Mark mquickto

07-APR-90 1 VP Finance

0000220208447F54A9ED59676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1450

5 Ropeburn Audry aropebur

04-MAR-90 1 VP Administration

0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1550

Page 289: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-41......................................................................................................................................................

.....................................................................................................................................................Oracle8 Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

---------- --------------------------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

6 Urguhart Molly murguhar

18-JAN-91 2 Warehouse Manager

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1200

9 Catchpole Antoinette acatchpo

09-FEB-92 2 Warehouse Manager

0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1300

10 Havel Marta mhavel

27-FEB-91 2 Warehouse Manager

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1307

11 Magee Colin cmagee

14-MAY-90 3 Sales Representative

0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1400 10

13 Sedeghi Yasmin ysedeghi

18-FEB-91 3 Sales Representative

0000220208447F54A9ED5C676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1515 10

Page 290: Oracle Developer: Build Reports

B-42 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

ID LAST_NAME FIRST_NAME USERID

---------- --------------------------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

14 Nguyen Mai mnguyen

22-JAN-92 3 Sales Representative

0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1525 15

15 Dumas Andre adumas

09-OCT-91 3 Sales Representative

0000220208447F54A9ED5E676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1450 18

16 Maduro Elena emaduro

07-FEB-92 6 Stock Clerk

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1400

17 Smith George gsmith

08-MAR-90 6 Stock Clerk

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

940

18 Nozaki Akira anozaki

09-FEB-91 7 Stock Clerk

0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1200

Page 291: Oracle Developer: Build Reports

Oracle Developer: Build Reports B-43......................................................................................................................................................

.....................................................................................................................................................Oracle8 Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

---------- --------------------------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

19 Patel Vikram vpatel

06-AUG-91 7 Stock Clerk

0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408002072C15B

795

20 Newman Chad cnewman

21-JUL-91 8 Stock Clerk

0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408002072C15B

750

21 Markarian Alexander amarkari

26-MAY-91 8 Stock Clerk

0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408002072C15B

850

22 Chang Eddie echang

30-NOV-90 9 Stock Clerk

0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408002072C15B

800

23 Patel Radha rpatel

17-OCT-90 9 Stock Clerk

0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408002072C15B

795

Page 292: Oracle Developer: Build Reports

B-44 Oracle Developer: Build Reports......................................................................................................................................................

.....................................................................................................................................................Appendix B: Table Descriptions and Data

ID LAST_NAME FIRST_NAME USERID

---------- --------------------------------- --------

START_DAT MANAGER_ID TITLE

--------- ---------- -------------------------

DEPT_ID(ID, NAME, REGION_ID)

------------------------------------------------------------

SALARY COMMISSION_PCT

---------- --------------

24 Dancs Bela bdancs

17-MAR-91 10 Stock Clerk

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

860

25 Schwartz Sylvie sschwart

09-MAY-91 10 Stock Clerk

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1100

Page 293: Oracle Developer: Build Reports

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

C

Frequently AskedQuestions

Page 294: Oracle Developer: Build Reports

C-2 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix C: Frequently Asked Questions

Frequently Asked Questions

Contents1 How do I set up and run my reports on a remote server?

2 How can the Report Builder Background Engine be shut down programmatically from another Oracle Developer application?

3 How do I pass parameters with spaces from the command line or from the Form Builder built-in RUN_REPORT_OBJECT or RUN_PRODUCT?

4 How do I print a report to an ASCII file with no page breaks or control characters?

5 How do I create a report containing barcodes in Report Builder?

6 How do I print a character mode report in landscape orientation?

7 How do I send report output to a fax?

8 How do I suppress rows or columns in a Matrix report?

9 How can I print to the second printer tray using Report Builder?

10 What Registry parameter is used in Windows to redirect where temporary files are created?

11 How do I automatically delete temporary files created when running Report Builder?

12 Is there any way to programmatically disable the Print button in the run-time Previewer?

Page 295: Oracle Developer: Build Reports

Oracle Developer: Build Reports C-3......................................................................................................................................................

......................................................................................................................................................Frequently Asked Questions and Answers

Frequently Asked Questions and Answers

Accessing Reference MaterialThe reference numbers given in these answers are the index numbers that enable you to search for a document in Metalink if you are a member of the Oracle Metals Program; that is, support levels Bronze, Silver, and Gold. If you do not currently have one of these metal support services, you can call your sales representative to upgrade your support service level.

You can use these numbers for an exact match, or you can search on full words pertaining to the problem you are having, such as BOILERPLATE.

From http://support.oracle.com/metalink choose the TOOLS option and then choose Oracle Developer reports. From there choose Top Product Articles and enter the text for your search. Click the Advanced button and choose ConText Syntax before starting the search.

Oracle allows access to published bulletins only from Metalink. If you do not find the topic you need, call the support center for help. Material is constantly being added to this site in an effort to give customers fast access to the information they need.

Note: These documents can also be obtained by calling the customer support hotline.

1 How do I set up and run my reports on a remote server?

Answer The Multitiered Reports Server, which is part of Oracle Developer Release 6.0, enables you to run reports on a remote application server. When used in conjunction with the Reports Web CGI or Web Cartridge, it also enables you to run reports from a Web browser using standard URL syntax. The server can be installed on Windows NT, Windows95, or UNIX. It handles client requests to run reports by entering all requests into a job queue.

For Further Information• Oracle Developer R6.0 Documentation: Online Manuals

• Oracle Developer: Guidelines for Building Applications

• 2: Deploying Applications on the Web

• 2.2.3: Configuring Reports for the Web

• 2.2.3.1: Setting up the Reports Server

Page 296: Oracle Developer: Build Reports

C-4 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix C: Frequently Asked Questions

2 How can the Report Builder Background Engine be shut down programmatically from another Oracle Developer application?

Answer In your Form application, use ORACLE_SHUTDOWN = Yes as a parameter in a parameter list that you pass to the Form Builder built-in, RUN_PRODUCT.

The parameter value, Yes, must have initial capitals.

References<PrSol:2067466.6>

3 How do I pass parameters with spaces from command line or from the Form Builder built-ins RUN_REPORT_OBJECT or RUN_PRODUCT?

Answer• Use a CMDFILE for passing parameters with spaces from 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?

Answer Remove "CONTROL(L)" from the "AFTER PAGE{S} CONTROL(L)" line in dflt.prt or use DESFORMAT=no_ff (A no_ff.prt printer definition file is supplied as part of the Report Builder installation in the <oracle_home>\report60\printers directory.)

References<PrSol:2058834.6>

Page 297: Oracle Developer: Build Reports

Oracle Developer: Build Reports C-5......................................................................................................................................................

......................................................................................................................................................Frequently Asked Questions and Answers

5 How do I create a report containing barcodes in Report Builder?

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?

Answer Manually edit escape sequences into a .prt file.

References<Note:34318.1> Landscape Printing in Reports on Windows

7 How do I send report output to a fax?

Answer Install a third-party software—for example Winfax—and make that a printer.

In order to programmatically fax a report without any user interaction through Microsoft Exchange Fax driver, look up bulletin BUL 13000147.6 (CR 159472).

References<PrSol:2083424.6>

Page 298: Oracle Developer: Build Reports

C-6 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix C: Frequently Asked Questions

8 How do I suppress blank rows or columns in a Matrix report?

Answer In Release 2.0 or earlier, create a summary column in the cross product group to count the number of cells that hold a NOT NULL value. Use a format trigger to suppress the row or column if this value is zero.

In Release 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>

Page 299: Oracle Developer: Build Reports

Oracle Developer: Build Reports C-7......................................................................................................................................................

......................................................................................................................................................Frequently Asked Questions and Answers

10 What Registry parameter is used in Windows to redirect where temporary files are created?

Answer Report Builder uses the REPORTS60_TMP parameter in the Registry. If this is not set, then it uses the working directory instead.

11 How do I automatically delete temporary files created when running reports using Reports Runtime?

Answer Running a report to a file from the 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?

Answer Include the DISABLEPRINT=YES argument in your command line. Release 2.1 also provides a DISABLEMAIL argument.

Page 300: Oracle Developer: Build Reports

C-8 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix C: Frequently Asked Questions

Page 301: Oracle Developer: Build Reports

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

D

Oracle Rdb Overview

Page 302: Oracle Developer: Build Reports

D-2 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix D: Oracle Rdb Overview

What Is Oracle Rdb?Oracle Rdb is a multiuser relational database management system designed and developed by Oracle Corporation for high availability, high performance, and ease of use in large-scale, mission-critical applications. It includes a full set of utilities for database maintenance and an industry-standard version of SQL that allows you to easily create applications and maintain your Oracle Rdb databases.

Oracle Rdb is currently running on over 45 thousand servers at more than 15 thousand sites worldwide. It is used in many large online transaction processing (OLTP) systems and its customer list comprises some of the worlds’ leading corporations. Oracle continues to enhance the functionality of Rdb by adding new features and strengthening integration with other Oracle technology and tools.

Supported PlatformsOracle Rdb is available on the following computing platforms:

• OpenVMS VAX

• OpenVMS Alpha

• Windows NT Intel and Alpha

Oracle Rdb FeaturesThese are some of the features that Oracle Rdb offers:

• Disaster tolerance

The Hot Standby option is ideal where very high performance and continuous (7 by 365) availability is essential. It provides disaster tolerance across geographically dispersed systems using the existing network with no change in applications or material increment in system overhead. The Hot Standby system can be accessed simultaneously for read-only transactions.

• High performance

Rdb is optimized to meet enterprise OLTP requirements for the highest levels of performance on OpenVMS Alpha and VAX. Features include full support for 64-bit Very Large Memory on OpenVMS Alpha, mixed-clusters, patented Record Caching; pinning tables in memory for rapid access, a patented Dynamic Query Optimizer, and Query Outlines for repeatable query performance.

• Ease of management

Rdb provides comprehensive, simple management of Rdb databases. Default database settings provide great performance for Rdb out of the box. The Enterprise Manager DBAPack for Rdb provides a complete set of management tools for Rdb that can be run from the Oracle Enterprise Manager console. The TRACE/Expert option provides performance monitoring and expert database design for Rdb. Rdb8 integration with Oracle Enterprise Manager provides common graphical interfaces to manage Rdb and Oracle RDBMS from the same Windows console.

Page 303: Oracle Developer: Build Reports

Oracle Developer: Build Reports D-3......................................................................................................................................................

......................................................................................................................................................What Is Oracle Rdb?

Oracle Rdb Features (continued) • Support for Windows NT Intel and Alpha

Compaq customers can extend their OpenVMS environment to include NT and run Rdb applications on commodity Intel platforms. Rdb8 on NT is a native, multi-threaded, complete implementation of Rdb.

• Integration with other Oracle technologies

Rdb customers can leverage their investment in Rdb by enhancing existing applications and developing new ones with the latest Oracle tools for Web and client-server application development, and powerful business intelligence analysis. Customers can make a single investment in products and training that is completely portable across Rdb and Oracle RDBMS. Rdb supports Oracle Application Server, Oracle Developer, Oracle Designer, Oracle Discoverer, and Oracle Express Server.

• Support for SQL*Net for Rdb

This enables integration with the Oracle technologies listed above. Customers and application partners can use standard Oracle APIs to build applications that run on Rdb and Oracle RDBMS. Data sharing between Rdb and Oracle RDBMS is enabled without the use of gateways. Rdb includes support for the Oracle Call Level Interface (OCI), Oracle network protocols, and DB Links.

Other Information

Oracle Rdb Education Oracle Education offers a comprehensive series of Oracle Rdb courses. The course titles include:

• Introduction to Rdb: Technical Overview and SQL Language

• Rdb for the Database Administrator

• Rdb for the Database Designer

• Rdb 3GL Programming

• Rdb Performance and Tuning

• Rdb Internals

To receive the Oracle Education U.S. schedule and catalog, which contains complete course descriptions, pricing, and enrollment information, call 1.800.633.0575 within the continental U.S. or 650.633.5019 from outside the U.S. For international course information, contact the Oracle site nearest to you. You can also get Oracle Education information and order catalogs from the following website: http://www.oracle.com.

Page 304: Oracle Developer: Build Reports

D-4 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix D: Oracle Rdb Overview

Other Information (continued)

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

Oracle Rdb Demonstration CD-ROM To receive a free Oracle Rdb product demonstration CD-ROM, send an e-mail including your name, address, and company to: [email protected].

Specify that you’d like to receive the free Oracle Rdb CD-ROM.

Page 305: Oracle Developer: Build Reports

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

E

Introduction to QueryBuilder

Page 306: Oracle Developer: Build Reports

E-2 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

Query Builder Features

• Easy-to-use data access tool• Point-and-click graphical user interface• Distributed data access• Powerful query building

Page 307: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-3......................................................................................................................................................

......................................................................................................................................................What Is Query Builder?

What Is Query Builder?

Easy-to-Use Data Access ToolQuery Builder is an easy-to-use data access tool. It provides a logical and intuitive means to access information stored in networked, distributed databases for analysis and reporting.

Point-and-Click Graphical User InterfaceQuery Builder enables you to become productive quickly because its graphical user interface works like your other applications. A toolbar enables you to perform common operations quickly.

Distributed Data AccessQuery Builder represents all database objects (tables, views, and so on) as graphical datasources, which look and work exactly the same way regardless of which database or account the data came from.

• Performing distributed queries on complex, enterprise-wide databases is no more difficult than querying a single database.

• Locating database objects is easy because Query Builder uses a single hierarchical directory that lists all accessible data in your account, in other accounts, and in other databases.

Page 308: Oracle Developer: Build Reports

E-4 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

Query Builder Features

• Easy-to-use data access tool• Point-and-click graphical user interface• Distributed data access• Powerful query building

Page 309: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-5......................................................................................................................................................

......................................................................................................................................................What Is Query Builder?

Powerful Query BuildingQuery Builder is designed for professionals who do not have a computer programming or database background. However, because of its powerful query features and its support of Structured Query Language (SQL) statements, experienced database users and programmers will find that Query Builder serves many of their needs as well.

• Graphical representation of tables and their relationships enables you to see the structure of your data.

• You can build queries by clicking on the columns that you want to retrieve from the database. The browser generates the necessary SQL statements behind the scenes.

• You can specify exactly which rows to retrieve from the database by using conditions, which consist of any valid SQL expression that evaluates to true or false.

• You can combine and nest conditions graphically using logical operators. You can disable conditions temporarily for what-if analysis.

Note: Query Builder as a tool in itself also includes WYSIWYG formatting and reporting capabilities. This lesson describes Query Builder as part of tools like Report Builder.

Page 310: Oracle Developer: Build Reports

E-6 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

1 Toolbar

2 Conditions panel

3 Datasource panel

Copyright Oracle Corporation, 1999. All rights reserved.

Query Builder Window

1

2 3

Page 311: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-7......................................................................................................................................................

......................................................................................................................................................The Query Builder Window

The Query Builder WindowThe Query Builder graphical user interface consists of one window, the Query window, where you build your queries.

Query Window PanelsThe Query window is divided into two panels:

• The Conditions panel where you specify conditions to refine your queries

• The Datasource panel where you display and select tables and columns for a query

ToolbarThe toolbar enables you to issue commands with a click of the mouse. You can create conditions, add new data sources, or define new columns.

Page 312: Oracle Developer: Build Reports

E-8 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

Building a New Query

Page 313: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-9......................................................................................................................................................

......................................................................................................................................................Building a New Query

Building a New QueryTo build a query you must select the tables you want to include and the columns you want to retrieve.

How to Include a Table 1 Choose Select Data Tables from the toolbar.

The Select Data Tables dialog box appears.

Note: When you open Query Builder to create a new query, the Data Table dialog box is open by default.

2 Select the table name and then choose Include, or simply double-click the desired table name.

The selected table appears in the Query window.

3 Choose Close to close the dialog box.

You can at any time include additional tables in the query by following these steps.

How to Delete a Table 1 Select the datasource in the Query window.

2 Choose Clear from the toolbar or press Delete.

Page 314: Oracle Developer: Build Reports

E-10 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

1 Datasource name 5 Object type

2 Primary key 6 Column datatype

3 Column name 7 Recursive relationship icon

4 Foreign key 8 Comments icon

Copyright Oracle Corporation, 1999. All rights reserved.

Data Source Components

2

3

4

1 5

6

7

8

Page 315: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-11......................................................................................................................................................

......................................................................................................................................................Datasource Components

Datasource Components

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

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

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

Page 316: Oracle Developer: Build Reports

E-12 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

Refining a Query

Page 317: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-13......................................................................................................................................................

......................................................................................................................................................Refining a Query

Refining a Query

Adding Columns to a QueryThere 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.

Removing Columns to a QueryThere are several methods of removing columns to a query:

• Clear the check box to the right of the column name

• Double-click the column name

To remove all columns from any single table, double-click the table heading.

Changing Column Position in a QueryBy default, Query Builder places columns in the order in which you select them. You can resequence them by selecting the Column Sequence tool.

The Column Sequence dialog box appears. Column names are shown in the Displayed Columns list in order of their appearance in the query. Drag any column to a new postion.

Note: You can also use the Column Sequence dialog box to add columns to or remove them from a query.

Page 318: Oracle Developer: Build Reports

E-14 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

Sorting Data

Page 319: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-15......................................................................................................................................................

......................................................................................................................................................Refining a Query

Sorting DataBy default a query returns the data in no specific order. To sort the data, you must add an ORDER BY clause to the query.

How to Add an ORDER BY Clause to a Query1 Select the Sort tool. The Sort dialog box appears.

2 Select the column you want to sort from the Available Columns list.

3 Choose Copy.

Query Builder adds the column to the Sorted Columns list and places an up arrow in the list box to indicate the default sort ascending order.

Note: You can sort by more than one column. Query Builder sorts according to the order in which columns appear in the Sorted Columns list.

4 You can change the sorting order by selecting the column name in the Sorted Columns list and selecting the desired option button.

5 Choose OK to close the dialog box.

Page 320: Oracle Developer: Build Reports

E-16 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

Viewing and Saving Queries

Page 321: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-17......................................................................................................................................................

......................................................................................................................................................Viewing and Saving Queries

Viewing and Saving Queries

Viewing a QueryChoose the Show SQL tool to view the query text that Query Builder will create.

How to Save a QueryYou can save your query as a SQL statement to the file system.

1 Select the Save tool from the toolbar.The Save As dialog box appears.

2 Enter a file name.Note: If you do not enter a file extension, Query Builder automatically appends the .SQL file extension.

3 Select a destination.

4 Choose OK.

Page 322: Oracle Developer: Build Reports

E-18 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

Including Additional Tables

Page 323: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-19......................................................................................................................................................

......................................................................................................................................................Including Additional Tables

Including Additional TablesOften, all of the data needed to create a desired report cannot be found in a single table. With Query Builder you can include multiple tables in a single query.

Remember that you can see the names of all the tables in your account by choosing the Select Data Tables tool. This brings up the Select Data Tables dialog box. You can also use this dialog box to show only certain types of data sources as well as data sources in other accounts and databases.

How to Find Tables in Other AccountsIf you do not find the table you are looking for in the Select Data Tables list box in your own account, you can search other accounts.

1 Open the pop-up menu to display the name of the current database and the option databases.

2 Select the current database name. The list box displays a list of accounts that contain tables you can access.

3 Select the name of the account in the list and then choose Open, or simply double-click the account name. This opens the account and displays a list of tables in the account.

4 Follow the normal procedure for including tables in the Query window.

How to Find Tables in Other DatabasesIf you do not find the table you are looking for in the Select Data Tables list box in your own account, you can search other databases.

1 Open the pop-up menu to display the name of the current database and the option databases.

2 Select databases.The list box displays a list of databases you can access.

3 Select the name of the database in the list and then choose Open, or simply double-click the account name.

4 Follow the normal procedure for including tables in the Query window.

Page 324: Oracle Developer: Build Reports

E-20 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

Viewing Comments

Page 325: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-21......................................................................................................................................................

......................................................................................................................................................Including Additional Tables

How to View CommentsSometimes, details about the kind of data stored in the database are not reflected by the table or column names. This can often make it difficult to decide which objects to include in your query. Query Builder features the Get Info dialog box to provide this kind of information for tables and columns.

To open the dialog box, follow these steps:

1 In the Datasource panel, select the table or column name.

2 Select the Get Info tool.

Alternatively, you can double-click the Comment icon in each table or column in the Datasources panel.

Page 326: Oracle Developer: Build Reports

E-22 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

Including Related Tables

Page 327: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-23......................................................................................................................................................

......................................................................................................................................................Relationships

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

How to Find and Include Related Tables1 Select the table in the Datasource panel.

2 Select the Select Related Tables tool.A list of tables that have relationships defined with the selected table appears.

3 Select the table name and choose Include, or simply double-click the table name.The selected table appears in the Datasource panel. Relationships between the tables are identified by relationship lines, drawn from the primary keys in one table to the foreign keys in another.

4 Choose Close to close the dialog box.

Once you have included the table, you can retrieve its columns.

Note: When you select a foreign key column before selecting related tables, only the table to which the foreign key refers appears in the Select Related Tables dialog box.

Page 328: Oracle Developer: Build Reports

E-24 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

Creating A User-DefinedRelationship

Page 329: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-25......................................................................................................................................................

......................................................................................................................................................Relationships

Creating A User-Defined RelationshipWhen you create a user-defined relationship, Query Builder draws a relationship line connecting the related columns.

How to Create a Relationship1 Select the Set Table Relationship tool.

The Set Relationship dialog box appears.

2 Enter the foreign key (A->) and primary key (B->) column names.

3 Type the complete table and column names (separate the table name from its column name with a period).

4 Choose OK to close the dialog box.

How to Create a Relationship (Optional Method)1 Select the column that you want to relate (foreign key).

2 While holding down the mouse button, drag the cursor to the related column in the second table (the primary key).You are drawing a relationship line as you do so.

3 Once the target column is selected, release the mouse button to anchor the relationship line.

Page 330: Oracle Developer: Build Reports

E-26 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

Unmatched Rows

Page 331: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-27......................................................................................................................................................

......................................................................................................................................................Relationships

Retrieving Unmatched RowsQuery Builder lets you choose whether to retrieve any unmatched rows when you are using a relationship in a query. An unmatched row occurs when the relationship connects tables where there are values on one side that have no corresponding values on the other side.There are three types of relationships that you can choose from:

• Display records from table A not found in table B

• Display records from table B not found in table A

• Suppress any mismatched records (default)

How to Create an Unmatched Relationship1 Click on the relationship line that connects the tables.

Both the column names and the relationship line should be selected.

2 Select the Set Table Relationship tool from the toolbar.The Set Relationship dialog box appears.

3 Choose one of the three relationship option buttons.

4 Choose OK.An unmatched relationship icon is placed on the relationship line next to the column that returns unmatched rows.

Page 332: Oracle Developer: Build Reports

E-28 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

Conditions

Page 333: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-29......................................................................................................................................................

......................................................................................................................................................Selecting Rows with Conditions

Selecting Rows with Conditions

The Conditions PanelThe Query window contains two independently scrollable panels, the Conditions panel and the Datasource panel. The Datasource panel is where you include tables and columns. The Conditions panel is where you apply conditions. You enter conditions into the Condition field of the panel.

How to Add Conditions to a Query1 Activate the Conditions field.

2 Enter the text that describes the condition.Type the conditions directly into the Condition field.OrClick in the columns in the Datasource panel and enter the rest of the condition.OrSelect columns and functions, using the appropriate tools.Note: Character and date values must be enclosed in single quotes.

3 Close and validate the condition.Note: If a column is used in a condition but it is not displayed in the results window, a gray check mark appears to the left of the column name in the datasource in the Query Window.

Closing and Validating the ConditionQuery Builder automatically validates the condition when you close the Condition field.

You can close the Condition field in the following ways:

• Press [Return].

• Click in the Conditions panel outside the Condition field.

• Choose Accept from the toolbar.

The ToolbarThe 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.

Page 334: Oracle Developer: Build Reports

E-30 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

OperatorsArithmetic• 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

Page 335: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-31......................................................................................................................................................

......................................................................................................................................................Operators

OperatorsAn 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 OperatorsArithmetic (+, -, 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 OperatorsLogical 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 OperatorsComparison 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...AND...

Between two values

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.

Page 336: Oracle Developer: Build Reports

E-32 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

Multiple Conditions

Page 337: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-33......................................................................................................................................................

......................................................................................................................................................Entering Multiple Conditions

Entering Multiple ConditionsThere is no limit to the number of conditions you can include in a Browser query. Multiple conditions are always combined using logical operators. You can add conditions to any query either before or after execution.

How to Add ConditionsThe Conditions panel always displays a blank Condition field at the bottom of the list of conditions. Use this field to enter multiple conditions.

1 Click in the empty Condition field to activate it.

2 Enter the new condition.Each time you add a condition, a new blank Condition field is created.Note: Pressing [Shift-Return] following the entry of each condition is the fastest way to create multiple conditions, because it moves the cursor and prompt down one line so that you can enter another condition.

3 Press [Return] to close and validate the condition.

How to Change Logical OperatorsBy default, Query Builder combines multiple conditions with the AND operator. To change the logical operator:

1 Select the logical operator in the Conditions panel.

2 Click on a new operator on the toolbar or select one from the Data menu.

How to Create Nested ConditionsQuery Builder enables you to combine logical operators to produce complex queries made up of multiple levels of conditions. These are referred to as nested conditions. To nest two or more conditions:

1 Build each condition to be included in the nest.

2 While holding down the [Shift] key, click in the box to the left of each condition to be nested.

3 Select the logical operator to combine the conditions—either AND or OR.Query Builder draws a box around the highlighted conditions in the Conditions panel and combines them with the operator that you specified.

Page 338: Oracle Developer: Build Reports

E-34 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1998. All rights reserved.

Deactivating a Condition

Page 339: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-35......................................................................................................................................................

......................................................................................................................................................Changing Conditions

Changing ConditionsIf 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.

How to Delete a Condition1 Click inside the Condition field to activate it.

2 Select Clear from the toolbar or choose Delete.The condition is removed from the query.

How to Deactivate a ConditionQuery Builder enables you to temporarily deactivate a condition so that you can test different scenarios without having to recreate the conditions each time. Double-clicking on the box to the left of the condition or its operator acts as a toggle switch, alternately turning the condition on and off. Deactivated conditions remain in the Condition field but appear dimmed.Additionally, you can turn conditions on and off by using the Data menu:

1 Select the box to the left of the condition or its operator.Note: Hold down the [Shift] key to select multiple conditions.

2 Double-click in the box to deactivate the condition.

Page 340: Oracle Developer: Build Reports

E-36 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

Defining Columns Using anExpression

Page 341: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-37......................................................................................................................................................

......................................................................................................................................................Defining Columns Using an Expression

Defining Columns Using an ExpressionBesides retrieving columns of data stored in a table, Query Builder enables you to define new columns that are derived or calculated from the values in another column.

How to Define a ColumnWhen you define a column, it exists only in your query, not in the database.

1 Select the table where you want to define a new column.

2 Select the Define Column tool.The Defined Column dialog box appears, which displays a list of all columns currently defined in the query (if any).

3 Click in the Defined Column field to activate it, then enter the name for your new column.

4 Move your cursor to the Defined As field and enter the formula or expression that defines your column.

5 Choose Define.The new column is added to the list of defined columns in the dialog box and appears in the Datasource panel.

6 Choose OK to close the dialog box.

How to Enter ExpressionsYou can enter information in the Defined As field in the following ways:

• Type the expression in directly.

• Choose Paste Column.The Paste Column dialog box appears.

- Select the column from the displayed list.

- Choose OK to paste the column into your expression and return to the Define Column dialog box.

How to Display and Hide Defined ColumnsYou display or hide defined columns from a query in exactly the same manner as you do ordinary columns.

Page 342: Oracle Developer: Build Reports

E-38 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Copyright Oracle Corporation, 1999. All rights reserved.

Defining Columns Using aFunction

Page 343: Oracle Developer: Build Reports

Oracle Developer: Build Reports E-39......................................................................................................................................................

......................................................................................................................................................Defining Columns Using a Function

Defining Columns Using a FunctionThe Browser also enables you to define columns using a variety of built-in functions provided by the Oracle Server. You can type a function directly in the Defined As field of the Define Columns dialog box, or choose Paste Function to select from a list.

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().

How to Select a Function1 Click in the Defined As field to activate it.

2 Choose Paste Function.The Paste Function dialog box appears.

3 Select or deselect the Show Categories check boxes to view the desired list of functions.

4 Select the function from the displayed list.

5 Select the Paste Arguments check box (optional).Note: If this check box is selected, a description or datatype name of the arguments appropriate for the function is pasted into your expression. You then replace the description with the actual arguments.

6 Choose OK to paste the function into your expression and return to the Define Columns dialog box.

Page 344: Oracle Developer: Build Reports

E-40 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix E: Introduction to Query Builder

Page 345: Oracle Developer: Build Reports

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

F

Object Features inOracle Developer

Page 346: Oracle Developer: Build Reports

F-2 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix F: Object Features in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Objectives

At the end of this lesson, you should beable 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

Page 347: Oracle Developer: Build Reports

Oracle Developer: Build Reports F-3......................................................................................................................................................

......................................................................................................................................................Overview

Overview

IntroductionIn this lesson you will review certain object features of Oracle8. This lesson also explains how these objects are displayed in the Object Navigator.

ObjectivesAt 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

Page 348: Oracle Developer: Build Reports

F-4 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix F: Object Features in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

New Oracle8 Scalar Datatypes

• NCHAR

• NVARCHAR2

• FLOAT

• NLS types

Page 349: Oracle Developer: Build Reports

Oracle Developer: Build Reports F-5......................................................................................................................................................

......................................................................................................................................................New Oracle8 Datatypes

New Oracle8 Datatypes

Scalar Datatypes• NCHAR stores fixed-length (blank-padded if necessary) NLS character

data. How the data is represented internally depends on the national character set, which might use a fixed-width encoding such as US7ASCII or a variable-width encoding such as JA16SJIS.

• NVARCHAR2 stores variable-length NLS character data. How the data is represented internally depends on the national character set, which might use a fixed-width encoding such as WE8EBCDIC37C or a variable-width encoding such as JA16DBCS.

• FLOAT is a subtype of NUMBER. However, you cannot specify a scale for FLOAT variables. You can only specify a binary precision, which is the total number of binary digits.

There is no change to the way scalar datatypes are displayed in Oracle Developer. The new datatypes are automatically converted to existing Oracle Developer item datatypes.

NLS TypesOracle8 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.

Page 350: Oracle Developer: Build Reports

F-6 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix F: Object Features in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Object Types

Attributes

po_nocustinfo

line_itemsamount

Methods

Ship

Cancel

Hold

Checkstatus

ORDER

Page 351: Oracle Developer: Build Reports

Oracle Developer: Build Reports F-7......................................................................................................................................................

......................................................................................................................................................New Oracle8 Datatypes

Object TypesAn 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.

Attributes An object type is similar to a record type in that it is declared to be composed of one or more subparts that are of predefined datatypes. Record types call these subparts fields, but object types call these subparts attributes.

Attributes define the object structure.CREATE TYPE address_type AS OBJECT

(address VARCHAR2(30), city VARCHAR2(15), state CHAR(2), zip CHAR(5));

CREATE TYPE phone_type AS OBJECT(country NUMBER(2), area NUMBER(4), phone NUMBER(9));

Just as the fields of a record type can be of other record types, the attributes of an object type can be of other object types. Such an object type is called nested.

CREATE TYPE address_and_phone_type AS OBJECT(address address_type, phone phone_type);

Object types are like record types in another sense: Both of them must be declared as types before the actual object or record can be declared.

Page 352: Oracle Developer: Build Reports

F-8 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix F: Object Features in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Object Types

Attributes

po_nocustinfo

line_itemsamount

Methods

Ship

Cancel

Hold

Checkstatus

ORDER

Page 353: Oracle Developer: Build Reports

Oracle Developer: Build Reports F-9......................................................................................................................................................

......................................................................................................................................................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 NUMBERIS BEGIN

RETURN (dept_id); END;

END;

Page 354: Oracle Developer: Build Reports

F-10 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix F: Object Features in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Object Tables

Object Table Based on Object Type

Page 355: Oracle Developer: Build Reports

Oracle Developer: Build Reports F-11......................................................................................................................................................

......................................................................................................................................................Creating Oracle8 Objects

Creating Oracle8 Objects

IntroductionOnce you have declared an object type, you can create objects based on the type.

Object TablesOne 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.

Page 356: Oracle Developer: Build Reports

F-12 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix F: Object Features in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Object Columns

Object Column Based on Object Type

Page 357: Oracle Developer: Build Reports

Oracle Developer: Build Reports F-13......................................................................................................................................................

......................................................................................................................................................Creating Oracle8 Objects

Object ColumnsAnother 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.

Page 358: Oracle Developer: Build Reports

F-14 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix F: Object Features in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Object Views

Object Views Based on Object Types

Object ViewObject-Oriented

Applicationrelational

Table

Page 359: Oracle Developer: Build Reports

Oracle Developer: Build Reports F-15......................................................................................................................................................

......................................................................................................................................................Creating Oracle8 Objects

Object ViewsOften, 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_typeWITH OBJECT OID (eno) AS SELECT e.empno, e.ename, e.sal, e.jobFROM emp e;

Page 360: Oracle Developer: Build Reports

F-16 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix F: Object Features in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

INSTEAD-OF Triggers

INSTEAD-OF TriggerNon-updatable View

DECLARE

BEGIN

EXCEPTION

END;

Page 361: Oracle Developer: Build Reports

Oracle Developer: Build Reports F-17......................................................................................................................................................

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

Page 362: Oracle Developer: Build Reports

F-18 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix F: Object Features in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

References to Objects

OID

Page 363: Oracle Developer: Build Reports

Oracle Developer: Build Reports F-19......................................................................................................................................................

......................................................................................................................................................Referencing Objects

Referencing Objects

IntroductionIn 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 REFsWith 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.

Page 364: Oracle Developer: Build Reports

F-20 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix F: Object Features in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Object Types inObject Navigator

Copyright Oracle Corporation, 1999. All rights reserved.

Object Type Wizard

Page 365: Oracle Developer: Build Reports

Oracle Developer: Build Reports F-21......................................................................................................................................................

......................................................................................................................................................Displaying Oracle8 Objects in the Object Navigator

Displaying Oracle8 Objects in the Object NavigatorThe Object Navigator lists declared types in the Database Objects section, along with tables, views, and other Oracle objects.

Object TypesBoth 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.

Oracle8 Type WizardObject types can be created using the Oracle8 Type wizard. The wizard allows you to define the attributes and methods.

Page 366: Oracle Developer: Build Reports

F-22 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix F: Object Features in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Object Tables inObject Navigator

Copyright Oracle Corporation, 1999. All rights reserved.

Object Columns inObject Navigator

Page 367: Oracle Developer: Build Reports

Oracle Developer: Build Reports F-23......................................................................................................................................................

......................................................................................................................................................Displaying Oracle8 Objects in the Object Navigator

Object TablesObject 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 ColumnsObject 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.

Page 368: Oracle Developer: Build Reports

F-24 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix F: Object Features in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Object Views inObject Navigator

Copyright Oracle Corporation, 1999. All rights reserved.

INSTEAD-OF Trigger Dialog Box

Page 369: Oracle Developer: Build Reports

Oracle Developer: Build Reports F-25......................................................................................................................................................

......................................................................................................................................................Displaying Oracle8 Objects in the Object Navigator

Object ViewsObject 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 TriggersINSTEAD-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.

Reference For more information about INSTEAD-OF triggers, see:Oracle8 Server SQL Reference ManualOracle8 Concepts Manual

Page 370: Oracle Developer: Build Reports

F-26 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix F: Object Features in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Object REFs inObject Navigator

Page 371: Oracle Developer: Build Reports

Oracle Developer: Build Reports F-27......................................................................................................................................................

......................................................................................................................................................Displaying Oracle8 Objects in the Object Navigator

Object REFsObject 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.

Page 372: Oracle Developer: Build Reports

F-28 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix F: Object Features in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Summary

• Oracle8 introduced three new scalardatatypes.

• Objects and object types allowrepresentation of complex data.

• Three kinds of objects are object tables,object columns, and object views.

Copyright Oracle Corporation, 1999. All rights reserved.

Summary

• INSTEAD-OF triggers allow DML onobject views.

• Object REFs store the Object Identifierof certain types of objects.

• The Object Navigator can displaycertain types of objects.

Page 373: Oracle Developer: Build Reports

Oracle Developer: Build Reports F-29......................................................................................................................................................

......................................................................................................................................................Summary

Summary

New Oracle8 DatatypesOracle8 introduced three new scalar datatypes and new composite dataypes such as object types.

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

Oracle8 Objects in the Object NavigatorThe Object Navigator can display certain types of objects.

Page 374: Oracle Developer: Build Reports

F-30 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix F: Object Features in Oracle Developer

Page 375: Oracle Developer: Build Reports

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

G

Using the Layout Editor inOracle Developer

Page 376: Oracle Developer: Build Reports

G-2 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix G: Using the Layout Editor in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Lesson Objectives

• Control the position and size of objectsin a layout

• Add lines and geometric shapes

• Define the colors and fonts used for text

• Color the body and boundaries ofobjects

• Import images onto the layout

Page 377: Oracle Developer: Build Reports

Oracle Developer: Build Reports G-3......................................................................................................................................................

......................................................................................................................................................Overview

Overview

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

ObjectivesAt 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

Page 378: Oracle Developer: Build Reports

G-4 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix G: Using the Layout Editor in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Using the Layout Editor

Common Features

•Moving and resizing objects and text

•Defining colors and fonts

•Importing and manipulating images

and drawings

•Creating geometric lines and shapes

Copyright Oracle Corporation, 1999. All rights reserved.

Using the Layout Editor

Layout Types

• Canvas-views in Forms

• Display layers for Graphics

• Report layouts

Page 379: Oracle Developer: Build Reports

Oracle Developer: Build Reports G-5......................................................................................................................................................

......................................................................................................................................................Why Use the Layout Editor?

Why Use the Layout Editor?The Layout editor is a graphical tool for defining the arrangement and appearance of visual objects. The Layout editor opens windows in the Oracle Developer Tool Builders to present the surfaces on which you can arrange objects. Some objects only occur in a subset of the Oracle Developer tools, and so the associated Layout editor facility appears only there.

The following are common to each tool:

• Moving objects to new positions in the layout and aligning them with each other

• Resizing objects and text

• Defining the colors of text and visual objects

• Creating lines, boxes, and other geometric shapes

• Importing and manipulating images on the layout

• Changing the font style and weight of text

• Accessing the properties of objects that you see in the layout

Layout TypesYou 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).

Page 380: Oracle Developer: Build Reports

G-6 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix G: Using the Layout Editor in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Invoking the Layout Editor

Page 381: Oracle Developer: Build Reports

Oracle Developer: Build Reports G-7......................................................................................................................................................

......................................................................................................................................................How to Access the Layout Editor

How to Access the Layout EditorYou can invoke the Layout editor from either the builder menus or from the Object Navigator. This applies whether you are doing so for the first time in a session or at a later stage. If you have minimized an existing Layout Editor window, you can also reacquire it in the way you would for any window.

Note: In Graphics, the Layout editor is open while you have a Display open.Reports has three editors, the Layout editor, the Data Model editor, and the Parameter Form editor, which are all displayed in the same window, one at a time.

How to Open from the Object Navigator• Double-click the Layout icon within a report hierarchy, in Reports.

Or

• Double-click a Canvas View icon in a form hierarchy in Forms.

How to Open from the Builder Menus1 Make sure that you have a context for either a report in Reports or a form

in Forms. You can do this by selecting the appropriate objects in the Navigator.

2 In Forms, select Tools—>Layout Editor from the Builder menu.In Reports, select View—>Layout Model from the Builder menu to set the context for the Editor window.

In Forms, you can open several Layout Editor windows—one for each canvas-view. Make sure that you have the canvas you want.

How to Close the Layout EditorYou can close or minimize the Layout Editor window or windows as you would any window.

Closing a layout in Graphics implies that you want to close its entire display (the Graphics module).

Page 382: Oracle Developer: Build Reports

G-8 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix G: Using the Layout Editor in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Layout Editor: Components

Page 383: Oracle Developer: Build Reports

Oracle Developer: Build Reports G-9......................................................................................................................................................

......................................................................................................................................................The Layout Editor Components

The Layout Editor ComponentsCommon components in the Layout editor are:

• Menu facilities: While the Layout Editor window is active, the Main builder menu changes to include three new items: View, Arrange, and Format. These are submenus for controlling the Layout editor.

• Horizontal toolbar: This appears across the top of the window, and is a subset of the tools from the Object Navigator.

• Style bar: This appears under the horizontal toolbar, and is a subset of the Format menu. It may also contain some other tools.

• Vertical toolbar: This contains the tools for creating and modifying objects on the layout. Some tools in the palette may be hidden if you have reduced the size of the Layout Editor window. If so, scroll buttons appear on the vertical toolbar.

There are three types of tools:

- Graphics tools for creating and modifying lines and shapes

- Product-specific tools

- Manipulation tools for controlling color and patterns

• Rulers and ruler guides: Rulers are horizontal and vertical markers to aid alignment; they appear at the top and side of the layout region. You can switch these off or have their units altered, as required. Drag ruler guides from the rulers across the layout region to mark positions in the layout.

• Layout/Painting region: This is the main central/right area where you can place and manipulate objects. A grid pattern is displayed in this area to aid alignment of objects. You can switch off or rescale this grid if required. (In Forms, the grid is hidden if the View—>Show Canvas option is switched on.)

• Status line: This appears at the bottom of the window. It shows you the mouse position and drag distance (when moving objects) and the current magnification level.

Page 384: Oracle Developer: Build Reports

G-10 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix G: Using the Layout Editor in Oracle Developer

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

Copyright Oracle Corporation, 1999. All rights reserved.

Tool Palette

1234567

8910111213

Page 385: Oracle Developer: Build Reports

Oracle Developer: Build Reports G-11......................................................................................................................................................

......................................................................................................................................................Creating and Modifying Objects in the Layout

Creating and Modifying Objects in the LayoutYou can perform actions in the Layout editor by selecting from the vertical toolbar and the builder menus, and by controlling objects directly in the layout region.

Creating Lines and ShapesCreate geometric lines and shapes by selecting from the graphics tools in the vertical toolbar. These include:

• Rectangles/squares

• Ellipses/circles

• Polygons and polylines

• Lines and arcs

• Freehand tool

The default tool in the vertical toolbar is Select, which lets you select and move objects.

How to Create a New Line or Shape1 Select the required graphic tool from the vertical toolbar with a mouse

click. This selects the tool for a single operation on the layout (a double-click causes the tool to remain active for subsequent operations).

2 Position the cursor at the start point for the new object in the layout and then click-and-drag to the required size and shape.

3 Release the mouse button.

Notice that the object remains selected after this procedure (selection handles appear on its boundaries) until you deselect it by clicking elsewhere.Note: You can produce constrained shapes (for example, a circle instead of an ellipse) by depressing the [Shift] key during step 2.

Creating Text (T)The Text tool (T) lets you open a Boilerplate Text object on the layout. You can type one or more lines of text into this object while it is selected with the Text tool. Uses of Text objects vary according to the Oracle Developer tool in which you create them.

Page 386: Oracle Developer: Build Reports

G-12 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix G: Using the Layout Editor in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Selecting Objects

Copyright Oracle Corporation, 1999. All rights reserved.

Manipulating Objects

Expand/Contractin One Direction

Expand/ContractDiagonally

Page 387: Oracle Developer: Build Reports

Oracle Developer: Build Reports G-13......................................................................................................................................................

......................................................................................................................................................Creating and Modifying Objects in the Layout

Selecting Objects for ModificationWith the Select tool active, you can select one or more objects on the layout to move or modify.

How to Select One Object• Click the object

Or

• Draw a bounding box around it the object using click-and-drag

If the object is small or narrow, it is sometimes easier to use the second method. Also, an object may be transparent (No Fill), which can present a similar problem where it has no center to select.It is convenient to select several objects, so that an operation can be performed on them simultaneously.

How to Select Several Objects Together• Hold down the [Shift] key and then click each object to be selected

Or

• Draw a bounding box around the objects using click-and-drag (providing the objects are adjacent to each other)

Changing the Size or RatioWhen an object is selected, there are two types of selection handles visible:

• Corner handles: Position the cursor on one of these to change the size/ratio of the object diagonally.

• Midpoint handles: Position the cursor on one of these to change the size/ratio in a horizontal or vertical direction.

Note: Holding down the [Shift] key lets you resize an object without changing its ratios. This means that squares remain as squares, and bitmapped images do not become distorted when resized.

Page 388: Oracle Developer: Build Reports

G-14 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix G: Using the Layout Editor in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Moving, Aligning, andOverlapping

Page 389: Oracle Developer: Build Reports

Oracle Developer: Build Reports G-15......................................................................................................................................................

......................................................................................................................................................Creating and Modifying Objects in the Layout

Moving and Aligning ObjectsWhen one or more objects are selected in the layout, you can:

• Move them to a new location

Do this by dragging to the required position and releasing the mouse button. You can use the grid and ruler lines to help you position them properly.

• Align the objects with each other

Objects can be aligned with the left-most, right-most, highest, or lowest object selected. They can also be centered, and aligned with the grid. You can do this using the Alignment feature on the Arrange menu:Select Arrange—>Align Objects and then set the options required in the Alignment Settings dialog box.

A Note on Grid-Snap AlignmentYou can ensure that all objects that you move align with snap points that are defined on the grid. To activate these, select View—>Snap to Grid from the menu. You can also use the View options to change the grid-snap spacing and units.

Note: If you position an object using one grid-snap spacing, and then try to position other objects under different settings, it may prove difficult to align them with each other.

Try to stick to the same snap units, if you use Grid Snap at all.

Overlapping ObjectsYou 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

Page 390: Oracle Developer: Build Reports

G-16 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix G: Using the Layout Editor in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Groups in the Layout

• Groups allow several objects to berepeatedly treated as one.

• Groups can be colored, moved orresized.

• Tool-specific operations exist forgroups.

• Groups have a single set of selectionhandles.

• Members can be added or removed.

Page 391: Oracle Developer: Build Reports

Oracle Developer: Build Reports G-17......................................................................................................................................................

......................................................................................................................................................Creating and Modifying Objects in the Layout

How to Manipulate Objects as a GroupSometimes you want to group objects together in the layout so that they behave as a single object.

1 Select the objects on the layout that are to be grouped together.

2 Select Arrange—>Group from the menu.

Notice that there is now just a single set of selection handles for the group, which you can treat as a single object whenever you select a member within it. The Arrange menu also gives you options to add and remove members. Resizing, moving, coloring, and other operations now apply to the whole group.

Groups have different implications depending on the Oracle Developer tool that is using them. Graphics, for example, can reference a group in the layout programmatically.

Manipulating Individual Group MembersTo manipulate group members individually, select the group, then click on the individual member. You can use options in the Group Operations menu to remove objects from the group or to reselect the parent group.

Other Tools for Manipulating Objects• Rotate: The Rotate tool lets you rotate a line or shape through an angle,

using its selection handles.

• Reshape: Reshape lets you change the size/ratio of a shape that has been rotated, or change the sweep angle of an arc. You can also reshape a polygon or polyline.

• Magnify: The Magnify tool lets you increase magnification when you click at a desired zoom position on the layout region. [Shift] + click reduces magnification.

Note: You can undo your previous action in the current Layout editor session by selecting Edit—>Undo from the menu.

Page 392: Oracle Developer: Build Reports

G-18 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix G: Using the Layout Editor in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Format Menu

Page 393: Oracle Developer: Build Reports

Oracle Developer: Build Reports G-19......................................................................................................................................................

......................................................................................................................................................Formatting Objects in the Layout

Formatting Objects in the LayoutThe Format menu provides a variety of facilities for changing the style and appearance of objects in the layout. These include:

• Font sizes and styles

• Spacing in lines of text

• Alignment of text within a text object

• Line thickness and dashing of lines

• Bevel (3D) effects on objects

• General drawing options (style of curves, corners, and so on)

Whichever formatting option you intend to use, first select the objects that you intend to change on the layout, then choose the necessary option from the Format menu.Some of the format options are available from the style bar.

How to Change Fonts on Textual ObjectsThere are a number of ways to change the font characteristics of textual objects; they depend on which Oracle Developer tool you are using. The common methods provided by the Layout editor are:

1 Select the objects in the layout whose content text you want to change (these may be Boilerplate Text objects and other textual object types supported by the Oracle Developer tool you are using).

2 Choose the font style and size that you require from the style bar; or select Format from the Main Builder menu and choose the font style and size that you require.

Note: In Microsoft Windows, choosing Font from the menu opens the standard Windows Font dialog box. In other GUI environments, the font choices may appear in the Format menu itself. Font settings are ignored if the application is run in character mode.

Page 394: Oracle Developer: Build Reports

G-20 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix G: Using the Layout Editor in Oracle Developer

1 Sample window

2 Fill color/pattern

3 Line color

4 Text color

Copyright Oracle Corporation, 1999. All rights reserved.

Color and Pattern Tools

23

4

1

Page 395: Oracle Developer: Build Reports

Oracle Developer: Build Reports G-21......................................................................................................................................................

......................................................................................................................................................Coloring Objects and Text

Coloring Objects and TextThere are three tools in the vertical toolbar for coloring objects:

• Fill Color: Use this tool to define the colors and pattern for an object’s body.

• Line Color: Use this tool to define the color of a line or the boundary line around an object.

• Text Color: Use this tool to choose the color for text.

Coloring ObjectsYou can separately color the Fill area (body) of an object and its boundary line (a Line object has no body).

Page 396: Oracle Developer: Build Reports

G-22 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix G: Using the Layout Editor in Oracle Developer

How to Choose the Fill Area Color1 Select the objects whose color you want to change.

2 Select the Fill Color tool. The color palette appears.If you want the objects to become transparent, choose No Fill at the bottom of the color palette window.

3 Select a color. If you want the Fill Area to be patterned instead of plain, then select Patterns from the bottom of the color palette.

4 If you select Patterns, another window appears from which you can select a pattern. You can define separate colors for the two shades of the pattern by choosing the pattern color buttons at the bottom of the Fill Pattern palette. Each of these buttons opens another color palette

How to Choose the Line Color1 With the desired layout objects selected, click the Line Color tool. The

line color palette opens.

2 Choose the color for lines and bounding lines from this color palette. Select No Line at the bottom of this window to remove the objects’ boundary lines.

Note: If you set both No Fill and No Line, the affected objects become invisible.

Page 397: Oracle Developer: Build Reports

Oracle Developer: Build Reports G-23......................................................................................................................................................

......................................................................................................................................................Coloring Objects and Text

How to Color Text1 Select the textual objects whose color you want to change in the layout.

2 Select the Text Color tool. The color palette appears, showing the available colors.

3 Click a square to select a color.

4 Notice that the selected objects on the layout have adopted the chosen text color. Also, the sample area in the vertical toolbar shows a T with the selected color, and this color appears next to the Text Color tool. This indicates the current text color setting.

How to Alter the Color PaletteChoose Format—>Layout Options—>Color Palette to alter the color palette. You can edit the color palette that is presented when choosing colors. This option is available only when the builder option Color Palette Mode is set to Editable. Changes to the color palette are saved with the current module.

Note: Modifications to the Color palette are not apparent until you close the document and reopen it.

Page 398: Oracle Developer: Build Reports

G-24 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix G: Using the Layout Editor in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Importing Images

Page 399: Oracle Developer: Build Reports

Oracle Developer: Build Reports G-25......................................................................................................................................................

......................................................................................................................................................Importing Images and Drawings

Importing Images and DrawingsOracle Developer tools allow both static and dynamic bitmapped images to be integrated into the application. You can import static images and drawings; that is, ones that are fixed on the layout. These might include:

• Company logos

• Photographs for inclusion in a report or display

• Background artwork

Importing DrawingsThese 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 ImagesSelect File—>Import—>Image from the menu and set the Import Image options:

Manipulating the Imported Image or DrawingWhen the imported image or drawing appears on the layout, you can move it or resize it like other objects on the layout. When resizing images, it is usually better to do so in Constrained mode (while pressing the [Shift] key) so the image does not become distorted.

Option Description(Option buttons) File/Database Where to import fromFilename File to be importedFormat 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

Page 400: Oracle Developer: Build Reports

G-26 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix G: Using the Layout Editor in Oracle Developer

Copyright Oracle Corporation, 1999. All rights reserved.

Summary

• Create objects by:

1. Choosing a palette tool

2. Clicking and dragging on layout region

• Color palette tools for fill area, lines, andtext

• View, arrange, and format menus availablefor layout

• Objects may be grouped for operations

• Import images and drawings byFile—>Import

Page 401: Oracle Developer: Build Reports

Oracle Developer: Build Reports G-27......................................................................................................................................................

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

Page 402: Oracle Developer: Build Reports

G-28 Oracle Developer: Build Reports......................................................................................................................................................

......................................................................................................................................................Appendix G: Using the Layout Editor in Oracle Developer


Top Related