You are on page 1of 577

Building Reports Manual

Release 2.5

Building Reports Manual


Release 2.5
Part No. A324881

Oracle Reportst Building Reports Manual, Release 2.5 Part No. A324881, April 1995 Copyright E Oracle Corporation 1984, 1988, 1995 All rights reserved. Printed in the U.S.A. Primary Author: Lori Ann White Contributors: Chandu Bhavasar, Jeff Bowles, Per Brondum, Ivan Chong, Karen DenchfieldMasterson, Bilal Homsi, Alex Hsieh, George Kwan, Sofia Lutan, Boris Protasov, Greg Rogalski, Frank Rovitto, Ingrid Snedecor, Gene Sohn, Marco Tilli, Harry Wong, Simon Wong This software was not developed for use in any nuclear, aviation, mass transit, medical, or other inherently dangerous applications. It is the customers responsibility to take all appropriate measures to ensure the safe use of such applications if the programs are used for such purposes. This software/documentation contains proprietary information of Oracle Corporation; it is provided under a license agreement containing restrictions on use and disclosure and is also protected by copyright law. Reverse engineering of the software is prohibited. If this software/documentation is delivered to a U.S. Government Agency of the Department of Defense, then it is delivered with Restricted Rights and the following legend is applicable: Restricted Rights Legend Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of DFARS 252.2277013, Rights in Technical Data and Computer Software (October 1988). Oracle Corporation, 500 Oracle Parkway, Redwood City, CA 94065. If this software/documentation is delivered to a U.S. Government Agency not within the Department of Defense, then it is delivered with Restricted Rights, as defined in FAR 52.22714, Rights in Data General, including Alternate III (June 1987). The information in this document is subject to change without notice. If you find any problems in the documentation, please report them to us in writing. Oracle Corporation does not warrant that this document is errorfree. ORACLE, Pro*COBOL, Pro*FORTRAN, Pro*Pascal, Pro*PL/I, SQL*Connect, SQL*Net, SQL*Plus, and SQL*ReportWriter are registered trademarks of Oracle Corporation. Developer/2000, ORACLE7, Oracle Book, Oracle Forms, Oracle Graphics, Oracle Help, Oracle*Mail, Oracle Reports, PL/SQL, and Pro*C are trademarks of Oracle Corporation. All other products or company names are used for identification purposes only, and may be trademarks of their respective owners.

Read This First


his book is one of six documents in the Oracle Reports Version 2.5 documentation set. Before you use it, you should be familiar with the following topics:

audience Oracle Reports documentation and related information how to use this book how to contact Oracle about documentation and product comments

Read This First

Audience
The information in this manual is intended for application developers who want to create reports. Readers should have a working knowledge of SQL, PL/SQL, and ORACLE server concepts.

Oracle Reports Documentation and Related Information


Oracle Reports has the capability to interact with a variety of products, such as the ORACLE server, various networking tools, and several programming languages. Sometimes, knowledge of these other products is necessary. The following map is provided to help you determine any additional documentation you may need.

ii

Building Reports Manual

Oracle Reports Documentation

The following books are included in the Oracle Reports documentation set:

Reports Documentation Set Version 2.5, Part No. A32486, is a collection of all Oracle Reports manuals. Reports Enhancements Manual Version 2.5, Part No. A32487, contains information about features new to Oracle Reports Version 2.5. Building Reports Manual Version 2.5, Part No. A32488, contains a tutorial and a rich discussion of Oracle Reports concepts as well as many example reports. Reports Reference Manual Version 2.5, Part No. A32489, contains detailed reference information about all aspects of Oracle Reports. It is intended primarily to answer specific questions that you might have about using Oracle Reports. Reports Messages and Codes Manual Version 2.5, Part No. A32490, contains all Oracle Reports messages with cause and action descriptions. Reports Runtime Manual, Graphical and Character Mode Interfaces, Version 2.5, Part No. A32493, contains information for end users (i.e., those who only run reports). It contains a tutorial and reference information about the Oracle Reports runtime executable. Reports Migration Manual Version 2.5, Part No. A32491, contains all information that you need to convert SQL*ReportWriter Version 1.1 reports and printer definitions to Oracle Reports Version 2.5. The online help system consists of the Reports Reference Manual, Reports Messages and Codes Manual, Reports Runtime Manual, and procedural information in online format.

Each Oracle Reports manual is also shipped as an Oracle Book document. For the names and locations of the document files, see your Developer/2000 Installation Guide.

Related Information

As an application designer using Oracle Reports Version 2.5, you may need to refer to some or all of the documents listed below. Please see the document in question for information on its specific purpose and usage.

Developer/2000 Installation Guide or System Release Bulletin. This document is different for each hardware/software platform. Ask your sales representative for the appropriate part number.

Read This First

iii

ORACLE7 Server Documentation Set, Part No. 503070 ORACLE7 Server Documentation Set V7.1, Part No. A12383 Oracle Network Products Messages Manual, Part No. A16263 MultiProtocol Interchange Administrators Guide, Part No. A10157 PL/SQL Users Guide and Reference, Version 1.0, Part No. 800V1.0 PL/SQL Users Guide and Reference, Version 2.0, Part No. 80020 Programmers Guide to ORACLE Precompilers, Part No. A18820 Pro*C Precompiler Supplement, Part No. A16084 Pro*COBOL Precompiler Supplement, Part No. A16083 Pro*FORTRAN Precompiler Supplement, Part No. A16086 Pro*Pascal Precompiler Supplement, Part No. A16145 Pro*PL/I Precompiler Supplement, Part No. A16146 Understanding SQL*Net, Part No. 16029 Oracle Network Manager Administrators Guide, Part No. A16264

How to Use this Book


This book is designed to get you up and running with Oracle Reports no matter what level of experience you may have: New Users: You need to quickly gain a working knowledge of Oracle Reports so you can start building reports. Experienced 1.1 Users: You know many of the concepts underlying the construction of a report, but you need to gain familiarity with new features and the graphical user interface. Experienced Oracle Reports Version 2.0 Users: You already know how to use Oracle Reports Version 2.0 to build and run reports. However, you now need exposure to the new features provided by Oracle Reports Version 2.5. Below are suggestions on how to use this book, based on your personal level of expertise with Oracle Reports.

iv

Building Reports Manual

Part I

Using Oracle Reports, which contains:


Chapter 1, Getting Started, an overview of the basic concepts of Oracle Reports. Chapter 2, Tutorial, five lessons that lead you step by step through the construction of several reports.

Part II

Understanding Oracle Reports, which contains:

Chapter 3, Oracle Reports Concepts,a more indepth conceptual overview of the product.

Part III

Building Reports, which contains:

Chapter 4, Visual Index, a brief description, including expected output, of each sample report included in Chapters 5, 6, and 7. Chapter 5, Introductory Reports, sample reports that show how to use several basic Oracle Reports features. Chapter 6, Advanced Reports, sample reports that explain how to use more advanced features of Oracle Reports. Chapter 7, Reports with New V2.5 Features, sample reports that include many features new to Oracle Reports Version 2.5.

Part IV

Tasks and Procedures, which contains:

Chapter 8, How To..., a collection of stepbystep instructions on how to accomplish tasks associated with creating a report in Oracle Reports. Read Getting Started for an overview of Oracle Reports basic concepts, then work through the Tutorial, taking enough time to understand why the lessons call for each action. Read Oracle Reports Concepts for a conceptual overview of the product. Start building the reports in Chapters 5, 6, and 7. We recommend that you build them in order; they grow more difficult as you progress through the chapters. Refer to Chapter 8, How To..., for instructions on how to complete specific tasks if you get stuck.

New Users:

Read This First

Experienced V1.1 Users:

Read Getting Started for an introduction to new features. Work through the Tutorial to become familiar with how 2.5 objects map to 1.1 objects. Read Oracle Reports Concepts for more specific information about the new interface, new report objects, new features, and new capabilities of Oracle Reports V2.5. Start building the reports in Chapters 5, 6, and 7. Refer to Chapter 8, How To..., for instructions on how to complete specific tasks if you get stuck.

Experienced V2.0 Users:

Read Getting Started for an introduction to new features. Work through the Tutorial. Much of it will be familiar, but it also includes sections on how to use several of the new features Build the reports in Chapter 7, New Features. Keep the Reports Enhancements Manual Version 2.5 handy as you work. This document will provide you with more information on the new features youll use as you create the reports. You can also refer to Chapter 8, How To..., for pointers if you get stuck.

Notational Conventions

You should be familiar with the notational conventions listed in the following table. Convention File>New>Report Data/Selection:Repeat
Font Change

Explanation Indicates a selection of submenu item Report from the New submenu of the File menu. Indicates a selection of Repeat from the Data/Selection tab of a property sheet. Indicates text to be entered exactly as shown. Indicates command, column, parameter, field, boilerplate, and anchor names. Indicates table, menu, query, group, frame, and repeating frame names, as well as property sheet names. Indicates items within a menu, buttons, or tabs on a property sheet. Indicates options for Oracle Reports settings.

UPPERCASE Initial Caps

Bold Italics

vi

Building Reports Manual

Your Comments Are Welcome


We value and appreciate your comments as an Oracle user. As we write, revise, and evaluate our work, your opinions are the most important input we receive. At the back of this manual is a Readers Comment Form. We encourage you to use this form to tell us both what you like and dislike about this (or other) Oracle manuals. If the form is gone, or you would like to contact us, please use the following addresses and phone numbers. For documentation questions/comments, contact: Oracle Reports Documentation Manager Oracle Corporation 500 Oracle Parkway Box 659412 Redwood Shores, California 940655028 (415) 5067000 (415) 5067200 (fax)

For product questions/comments, contact: Oracle Reports Product Manager Oracle Corporation 500 Oracle Parkway Box 659412 Redwood Shores, California 940655028 (415) 5067000 (415) 5067200 (fax)

Read This First

vii

viii

Building Reports Manual

Contents

PART I

USING ORACLE REPORTS

Chapter 1

Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . What is Oracle Reports? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Rich in Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Nonprocedural Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . Portability with GUI Conformance . . . . . . . . . . . . . . . . . . . . . Full Integration with Other Oracle Products . . . . . . . . . . . . . Open Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Oracle Reports Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Create a New Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Define the Data Model for a Report . . . . . . . . . . . . . . . . . . . . . Specify the Layout for a Report . . . . . . . . . . . . . . . . . . . . . . . . . Specify a Runtime Parameter Form for a Report . . . . . . . . . . Use the Oracle Reports Interface . . . . . . . . . . . . . . . . . . . . . . . . How to Prepare for the Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11 12 12 12 12 12 12 13 13 14 15 17 18 1 10

Chapter 2

Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Lesson Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A Note on Platform Specifics . . . . . . . . . . . . . . . . . . . . . . . . . . . Lesson I: Create a Default Report ........................ Invoke the Oracle Reports Designer . . . . . . . . . . . . . . . . . . . . . Specify Your Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Specify a Default Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Save and Run Your Report . . . . . . . . . . . . . . . . . . . . . . . . . . . View Report Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Time to Explore... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary of Lesson I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

21 22 24 25 26 28 2 10 2 13 2 15 2 15 2 16

Contents

ix

Lesson II: Create a Break Report . . . . . . . . . . . . . . . . . . . . . . . . . Invoke Oracle Reports and Open a Report . . . . . . . . . . . . . Change the Data Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Update the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Create Computations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Change Default Layout Settings and Redefault . . . . . . . . . . . Time to Explore... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary of Lesson II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Lesson III: Add Boilerplate Text and Line Drawings to the Report .......................................... Restart Oracle Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Modify Default Boilerplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . Modify Field Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Add Boilerplate and Fields in the Report Margin . . . . . . . . . Import Layout Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Add Boilerplate From a Linked File . . . . . . . . . . . . . . . . . . . . . Summary of Lesson III . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Lesson IV: Incorporate Multimedia Objects ............... Customize Your Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Add Page Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Add Multimedia Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . View Your Report in the Previewer ................... Time to Explore... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary of Lesson IV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Lesson V: Combine Report Types . . . . . . . . . . . . . . . . . . . . . . . . Create a Master/Detail Data Model . . . . . . . . . . . . . . . . . . . . . Add a New Layout to an Existing Layout . . . . . . . . . . . . . . . . Force a Page Break . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Time to Explore... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary of Lesson V . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2 17 2 18 2 18 2 19 2 22 2 27 2 29 2 29 2 30 2 31 2 31 2 32 2 33 2 37 2 38 2 42 2 43 2 44 2 46 2 47 2 52 2 54 2 54 2 55 2 56 2 58 2 59 2 61 2 61 2 62

Building Reports Manual

PART II

UNDERSTANDING ORACLE REPORTS

Chapter 3

Oracle Reports Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Oracle Reports Object Navigator . . . . . . . . . . . . . . . . . . . . . . . . . . . Oracle Reports Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Module Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Storage and Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Reportlevel Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Report Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Unit of Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data Model Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data Definition Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Layout Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Repeating Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Boilerplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Anchors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . OLE2 Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Layout Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Parameter Form Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Boilerplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Building a Parameter Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . Matrix Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Matrix Data Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Matrix Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Simple Matrix Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Nested Matrix Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MultiQuery Matrix with Break . . . . . . . . . . . . . . . . . . . . . . . . Matrix Break Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

31 32 33 33 33 34 34 34 35 35 35 36 38 38 3 12 3 13 3 16 3 19 3 21 3 23 3 24 3 26 3 28 3 29 3 31 3 34 3 35 3 35 3 41 3 41 3 41 3 42 3 42 3 42 3 47 3 48 3 50 3 52 3 54

Contents

xi

Using PL/SQL with Your Reports . . . . . . . . . . . . . . . . . . . . . . . . . . External PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ReportLevel PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Data Model Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Layout Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Parameter Form Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Previewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Executables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . R25CONV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . R25MREP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . R25RUN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . R25DES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PART III Chapter 4 BUILDING REPORTS Visual Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Access Demo Reports . . . . . . . . . . . . . . . . . . . . . . . . . A Note on Platform Specifics . . . . . . . . . . . . . . . . . . . . . . . . . . . Tabular Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . External Query Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Introductory Mailing Label Report . . . . . . . . . . . . . . . . . . . . . . Form Letter Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Master/Master Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Break Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Master/Detail Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Master/Detail/Summary Report . . . . . . . . . . . . . . . . . . . . . . . Formula Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Across Break Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wrapped Break Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Header and Footer Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Placing Database Values In Page Headings . . . . . . . . . . . . . . Graphics and Text Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Matrix Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Time Series Calculations Report . . . . . . . . . . . . . . . . . . . . . . . . Aggregating Data within Ranges . . . . . . . . . . . . . . . . . . . . . . . Renumbering Pages by Repeating Frame . . . . . . . . . . . . . . . . Anchors Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intermixing Fields from Different Repeating Frames . . . . . . Check Printing Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3 56 3 56 3 58 3 59 3 59 3 60 3 61 3 62 3 63 3 64 3 64 3 64 3 64

41 42 42 43 44 45 46 47 48 49 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24

xii

Building Reports Manual

Spelling Out Cash Amounts On Checks . . . . . . . . . . . . . . . . . Printing Reports On Preprinted Forms . . . . . . . . . . . . . . . . . Invoice Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PL/SQL Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ranking Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Suppressing Labels When No Detail Records Are Retrieved . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Advanced Mailing Label Report . . . . . . . . . . . . . . . . . . . . . . . . Mailing Reports to Multiple Users . . . . . . . . . . . . . . . . . . . . . . Conditional Form Letter Report . . . . . . . . . . . . . . . . . . . . . . . . Conditional Highlighting Report . . . . . . . . . . . . . . . . . . . . . . . Static Graphics Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Dynamic Graphics Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Nested Matrix Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Matrix Break Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Matrix with Summaries Report . . . . . . . . . . . . . . . . . . . . . . . . . ASCII File Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DrillDown Report with Parameter List of Values and Character Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Multimedia Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . OLE2 Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tracing and Debugging Report Execution . . . . . . . . . . . . . . .

4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 4 42 4 43 4 44

Chapter 5

Introductory Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Use This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tabular Report ...................................... Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . External Query Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Introductory Mailing Label Report . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Related Concepts: Suppressing Blank Lines . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Form Letter Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Master/Master Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Break Report .......................................... Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Related Concepts I: Multiple Columns in a Break Group . . . Steps to Build This Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Related Concepts II: Multiple Break Groups . . . . . . . . . . . . . .

51 52 53 54 57 58 5 11 5 12 5 15 5 16 5 18 5 19 5 22 5 23 5 25 5 26 5 29 5 30 5 32

Contents

xiii

Steps to Build This Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Master/Detail Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Related Concepts: Running Summaries . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Master/Detail/Summary Report . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Formula Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Across Break Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wrapped Break Report ................................. Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Header and Footer Report .............................. Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Placing Database Values In Page Headings .............. Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Graphics, Text, and Color Report ........................ Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Matrix Report ......................................... OneQuery Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build the OneQuery Report . . . . . . . . . . . . . . . . . . . ThreeQuery Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build the ThreeQuery Report . . . . . . . . . . . . . . . . . . Related Concepts I: Zeroes in Place of NonExistent Values . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Related Concepts II: Matrix With Summaries . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Related Concepts III: Adding a Grid . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 6 Advanced Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Use this Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Time Series Calculations Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Aggregating Data within Ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Renumbering Pages By Repeating Frame . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5 33 5 35 5 37 5 40 5 42 5 48 5 50 5 51 5 53 5 56 5 58 5 61 5 62 5 64 5 65 5 67 5 68 5 71 5 72 5 75 5 76 5 81 5 82 5 83 5 85 5 85 5 88 5 89 5 90 5 91 5 93 5 93 61 62 63 64 66 67 69 6 11

xiv

Building Reports Manual

Anchors Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intermixing Fields from Different Repeating Frames . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Check Printing Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Spelling Out Cash Amounts On Checks . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Printing Reports On Preprinted Forms . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Invoice Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PL/SQL Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ranking Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Concepts, Part I: Ranking by Count . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Concepts, Part II: Ranking by Percentage . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Suppressing Labels When No Detail Records Are Retrieved . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Advanced Mailing Label Report . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Method One (barcode font) . . . . . . . . . . . . . . . . . . . . . . . . . . . . Method Two (Oracle Graphics tool) . . . . . . . . . . . . . . . . . . . . . Mailing Reports to Multiple Users . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build empdatab.rdf . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build mailitb.rdf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Conditional Form Letter Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Conditional Highlighting Report . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Static Graphics Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Dynamic Graphics Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Related Concepts: Selecting the Graphic at Runtime . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Nested Matrix Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Method One (onequery): . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Method Two (multiquery): . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6 14 6 16 6 20 6 21 6 23 6 24 6 27 6 28 6 30 6 31 6 35 6 36 6 41 6 42 6 47 6 47 6 48 6 50 6 51 6 53 6 54 6 57 6 58 6 59 6 59 6 61 6 63 6 64 6 66 6 67 6 71 6 72 6 76 6 78 6 81 6 83 6 85 6 86 6 89 6 90 6 90 6 91 6 92

Contents

xv

Related Concepts: Multiquery Matrix with Break . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Matrix Break Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Matrix with Summaries Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ASCII File Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6 94 6 95 6 97 6 98 6 100 6 102 6 104 6 105

Chapter 7

Reports with New V2.5 Features . . . . . . . . . . . . . . . . . . . . . . . . . . How to Use this Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Access the Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . Platform Specifics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DrillDown Report with Parameter List of Values . . . . . . . . . . . . New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Prerequisite Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Multimedia Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Prerequisite Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . OLE2 Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Prerequisite Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Build this Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tracing and Debugging Report Execution . . . . . . . . . . . . . . . . . . . New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Prerequisite Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

71 72 72 73 75 75 75 76 78 7 14 7 14 7 14 7 15 7 15 7 19 7 19 7 19 7 20 7 20 7 20 7 23 7 23 7 23 7 24 7 25

xvi

Building Reports Manual

PART IV

TASKS AND PROCEDURES

Chapter 8

How To... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Invoking Online Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Accessing the Online Documentation . . . . . . . . . . . . . . . . . . . . . . . Setting Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Set Preferences for Designing Reports . . . . . . . . . . . . . . . . . . . Set Preferences for Running Reports . . . . . . . . . . . . . . . . . . . . Set Preferences for the Object Navigator . . . . . . . . . . . . . . . . . Set Font Aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Set Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Performing Common Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Connect to a Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Copy Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Open Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Save Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Rename Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Grant Access to Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Delete Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Archive Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Select Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deselect Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Resize Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Hide and Show Components . . . . . . . . . . . . . . . . . . . . . . . . . . Working with the Object Navigator . . . . . . . . . . . . . . . . . . . . . . . . . Display Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Expand and Collapse Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . Navigate to Specific Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . View Node Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Display Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Customize the Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Working with Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Create Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Run and Print Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Convert Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Migrate Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Generate Runtime Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Produce Reports on Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . Reference External Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . Working with External Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . Create External Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

81 82 82 82 82 83 83 83 83 84 84 85 85 85 85 86 86 87 8 10 8 11 8 12 8 13 8 14 8 14 8 14 8 15 8 15 8 15 8 16 8 17 8 17 8 20 8 24 8 25 8 26 8 26 8 27 8 29 8 29

Contents

xvii

Working with External PL/SQL Libraries . . . . . . . . . . . . . . . . . . . Create External PL/SQL Libraries . . . . . . . . . . . . . . . . . . . . . . Convert External PL/SQL Libraries . . . . . . . . . . . . . . . . . . . . . Reference External PL/SQL Libraries from Another Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Working with Data Model Objects . . . . . . . . . . . . . . . . . . . . . . . . . . Create Data Model Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . Work with Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Display Data Model Object Properties . . . . . . . . . . . . . . . . . . . Rename Data Model Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . Delete Data Model Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Move Data Model Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Reference Columns and Parameters . . . . . . . . . . . . . . . . . . . . . Magnify or Reduce the Data Model Editor Display . . . . . . . Working with Layout Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Activate Layout Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Create a Default Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Create Layout Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Display Layout Object Properties . . . . . . . . . . . . . . . . . . . . . . . Rename Layout Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Delete Layout Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Group Layout Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Move Layout Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Copy and Paste Layout Objects . . . . . . . . . . . . . . . . . . . . . . . . Magnify or Reduce the Layout Editor Display . . . . . . . . . . . . Modify Layout Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Undo Editor Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Import Layout Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Export Layout Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Working with Parameter Form Objects . . . . . . . . . . . . . . . . . . . . . Create a Default Parameter Form . . . . . . . . . . . . . . . . . . . . . . . Customize the Runtime Parameter Form . . . . . . . . . . . . . . . . Working with the Previewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Navigate in the Previewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Print from the Previewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Change the Title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Split the Viewing Region . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Magnify or Reduce the Image . . . . . . . . . . . . . . . . . . . . . . . . . . Open Multiple Previewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

8 30 8 30 8 31 8 31 8 33 8 33 8 40 8 42 8 43 8 43 8 45 8 46 8 46 8 47 8 47 8 48 8 50 8 58 8 58 8 59 8 59 8 60 8 63 8 64 8 64 8 72 8 72 8 73 8 75 8 75 8 75 8 77 8 77 8 77 8 77 8 78 8 78 8 78

xviii

Building Reports Manual

Working with PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Create Reportlevel PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . Open and Edit Existing PL/SQL . . . . . . . . . . . . . . . . . . . . . . . Rename Reportlevel PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . Drag and Drop PL/SQL Program Units . . . . . . . . . . . . . . . . . Copy and Paste PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Delete Reportlevel PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . Compile PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Import and Export PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . Working with Report Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Create Report Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Delete Report Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Debugging Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Set the Object Navigator Display . . . . . . . . . . . . . . . . . . . . . . . Use the Program Unit Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . Use the PL/SQL Interpreter . . . . . . . . . . . . . . . . . . . . . . . . . . . Trace Report Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Glossary Index

8 79 8 79 8 80 8 80 8 80 8 80 8 81 8 81 8 82 8 83 8 83 8 83 8 84 8 84 8 84 8 85 8 86

Contents

xix

xx

Building Reports Manual

PART

Using Oracle Reports

CHAPTER

Getting Started
his chapter is a brief introduction to Oracle Reports concepts, including the major objects that make up a report and how to use the graphical user interface to create them. It gives you enough information to begin the Tutorial in Chapter 2. Specifically, this chapter contains the following information about Oracle Reports Version 2.5:

description 1 2 basic concepts 1 3 what you need to get started 1 10

Getting Started

11

What is Oracle Reports?


Oracle Reports is a tool for developing, displaying, and printing productionquality reports. It is designed for application developers who are familiar with SQL and PL/SQL.

Rich in Features

Oracle Reports enables you to create a wide variety of reports, including master/detail reports, nested matrix reports, form letters, and mailing labels. Major features include:

data model and layout editors in which you can create the structure and format of your report object navigator to help you navigate among the data and layout objects in your report packaged functions for creating computations support for fonts, colors, and graphics conditional printing capabilities fullyintegrated Previewer for viewing your report output contextsensitive online help system

Nonprocedural Approach

The unique nonprocedural approach of Oracle Reports lets you concentrate on design improvements instead of programming. Its easytouse, fillintheform interface and powerful defaults make developing and maintaining even the most complex reports fast and simple. Oracle Reports adheres to the native lookandfeel of your host environment. You can create reports on bitmapped platforms and run them on charactermode, bitmapped, and blockmode platforms with the guarantee of identical functionality and complete compatibility across all systems. You can integrate Oracle Reports with other Oracle products such as Oracle Forms, Oracle Graphics, and Oracle Mail. For example, you can run a report using Oracle Forms triggers, include graphics and charts in a report, and send output to other users via Oracle Mail. Oracle Reports open architecture enables you to incorporate userdefined routines written in COBOL, C, and most other programming languages, as well as the powerful PL/SQL language. You can always present information exactly the way you want.

Portability with GUI Conformance

Full Integration with Other Oracle Products

Open Architecture

12

Building Reports Manual

Oracle Reports Basic Concepts


There are three steps to building a report with Oracle Reports:

Create a new report definition. Define the data model (choose the data, data relationships, and calculations you will use to produce the report output). Specify a layout. You can use a default, customizing it if desired, or create your own.

Create a New Report

When you first invoke Oracle Reports, it creates a new report definition for you. The first window you see is called the the Object Navigator. This window displays a comprehensive list of report objects. Initially, it shows all objects that Oracle Reports has created for you, as part of the report definition.

Using the Object Navigator, you can easily navigate to all objects contained within all currentlyopen reports. One heading appears for each different type of object your report can contain, while under each heading is a hierarchical list of the corresponding objects that have actually been created during the current session.

Getting Started

13

The Object Navigator also enables you to navigate to the following Oracle Reports windows:

The Data Model editor, in which you define the data for the report. The Layout editor, in which you create the report layout. The Parameter Form editor, in which you customize the appearance of the Runtime Parameter Form, a window that optionally appears at runtime and enables you to enter parameter values that affect report execution.

Define the Data Model To specify the data for a report, define a data model. A data model is composed of some or all of the following data definition objects: for a Report

queries groups columns parameters links

Below is a sample data model in the Data Model editor.

14

Building Reports Manual

Queries

Queries are ANSIstandard SQL SELECT statements that fetch data from a standard database such as ORACLE, DB2, or SQL/DS. You can use any number of queries to select data from any number of tables, located in any number of databases on any number of machines. Groups determine the hierarchy of the data appearing in a report, and are used primarily to create breaks. Oracle Reports automatically creates a group for each query, but you are not limited to these defaults. Occasionally a new group is necessary. For example, if you want to create a break to group the data in the output, you can create a new group in the data model and include the column you want to use as the break column. In addition to break reports, you also create groups to define the cross products of matrix reports.

Groups

Columns

Columns contain the data values for a report. Default report columns corresponding to the table columns included in each querys SELECT list are automatically created by Oracle Reports, then each column is placed in the group associated with the query that selected the column. If you want to perform summaries and computations on database column values, you can create new columns. You can also reassign one or more columns to a group or groups youve created. Parameters are variables for your report that enable you to change selection criteria at runtime. Oracle Reports automatically creates a set of system parameters at runtime, but you can create your own as well. You can create parameters to replace either single literal values or entire expressions in any part of a query. You can reference parameters elsewhere in the report, such as in PL/SQL constructs providing conditional logic for the report. Data links are used to establish parentchild relationships between queries and groups via columnmatching. After defining the data model, you specify the reports layout; i.e., you position objects as you want them to appear in the report output. Oracle Reports provides six default layout styles from which to choose: tabular, master/detail, form letter, form, mailing label, and matrix. You can choose one of these default layouts and modify it as needed, or create your own report layout.

Parameters

Data Links

Specify the Layout for a Report

Getting Started

15

A report layout can contain any of the following layout objects:


repeating frames frames fields boilerplate anchors

The next figure shows a sample layout in the Layout editor.

Repeating Frames

Repeating frames act as placeholders for groups, and present rows of data retrieved from the database. Repeating frames repeat as often as the data is retrieved. Frames surround other layout objects, enabling you to control multiple objects simultaneously; e.g., ensuring that they maintain their positions relative to each other in the output. Fields act as placeholders for columns. They define the formatting attributes for all columns displayed in the report. A field is one of the objects that can be located inside a frame or repeating frame.

Frames

Fields

16

Building Reports Manual

Boilerplate

Boilerplate consists of text and graphics that appear in a report each time it is run; e.g., a label appearing above a column of data is boilerplate text. Graphics drawn in the layout are boilerplate, as well as text added to the layout, and Windows users can create OLE2 boilerplate to contain OLE2 objects. Anchors fasten an edge of one object to an edge of another object, ensuring that they maintain their relative positions. For example, you can anchor boilerplate text to the edge of a variablesized repeating frame, guaranteeing the boilerplates distance and position in relation to the repeating frame, no matter how the frames size might change. When you are almost ready to run your report, you can optionally customize the Runtime Parameter Form using the Parameter Form editor. The Parameter Form editor contains a subset of the Layout editors functionality, and determines the positions of objects as they should appear in the Runtime Parameter Form. A Runtime Parameter Form can contain any of the following objects:

Anchors

Specify a Runtime Parameter Form for a Report

fields boilerplate

The figure below shows a sample layout in the Parameter Form editor.

Getting Started

17

Fields

Fields in the Parameter Form editor act as placeholders for parameters. They define the formatting attributes for all parameters displayed in the Runtime Parameter Form. Boilerplate in the Parameter Form editor refers to text and graphics that appear in the Runtime Parameter Form each time it is run; e.g., a label denoting a particular parameter is boilerplate text. Lines or boxes drawn in the layout are also considered boilerplate, as well as any added text.

Boilerplate

Use the Oracle Reports Use the following interface components to define report objects: Interface property sheets

Object Navigator editors tool palettes and toolbars

Property Sheets

A property sheet is a window that display the settings defining an Oracle Reports object. Each object (query, group, frame, parameter, etc.) has a property sheet.

18

Building Reports Manual

Object Navigator

The Object Navigator, as previously mentioned, shows a hierarchical view of objects in your report. Use it to gain an overview of a reports organization. Each list item is called a node, and represent an object or type of object your report can contain or reference.

Editors

An editor is a work area that contains graphical representations of related objects. You use the Data Model editor to manipulate (create, delete, move, resize, copy, paste, etc.), data model objects, the Layout editor to manipulate layout objects, and the Parameter Form editor to manipulate parameter form objects. The Tool palettes and toolbars contain tools used to manually create or manipulate objects in the editors. Each editor has a tool palette and a toolbar; each tool appears as an icon on the palette or toolbar. Some tools, such as the Select tool, are common to all the palettes. Other tools are specific to the editors in which they appear. Toolbar items have menu equivalents. To see the palettes, refer to the inside back cover flap of this book.

Palettes and Toolbars

Getting Started

19

How to Prepare for the Tutorial


Before you begin the tutorial or the sample reports, the following items must be installed on your system:

ORACLE Relational Database Management System (RDBMS) Version 7.0 or later Oracle Reports Version 2.5 Oracle Reports demo (database) tables and files

If you are responsible for installing Oracle Reports, read and and follow the next several steps to successfully install Oracle Reports on your system. If someone will install Oracle Reports for you or has already installed it on your system, skips to the next section and answer the following list of questions concerning what you should know before you begin using Oracle Reports.

What to Install

1.

Install the ORACLE RDBMS Version 7.0 or later. For specific instructions on how to do this, refer to your Developer/2000 Installation Guide. Set up logon accounts for yourself and other users. For specific instructions on how to do this, see the Oracle7 Server Administrators Guide. Install Oracle Reports Version 2.5. Refer to your Developer/2000 Installation Guide for instructions on installing Oracle Reports Version 2.5. Part of the process consists of installing several Oracle Reports tables. These tables must be installed in order to use Oracle Reports. Load the sample database tables used by all sample reports. If you are using the Oracle Installer, refer to your Developer/2000 Installation Guide for directions on how to do this. If you are installing via command line, complete the steps listed below. Refer to your Developer/2000 Installation Guide for systemspecific details on this procedure. Note: You must install the demo tables for Oracle Reports 2.5, even if you already have tables from a previous version installed. From your operating system prompt, do the following:

2.

3.

4.

5.

Go to the operating system directory in which you will run the installation program.

1 10

Building Reports Manual

6.

Enter the following command:


demobld username/password

The DEMOBLD program builds the sample tables and reports under the specified logon ID. Questions to Ask the Oracle Reports Installer 1. 2. Is Oracle Reports Version 2.5 installed? What username/password should I use to access ORACLE? (It is likely that this username/password is different from the username/password you used to log on to your computer.) Are the sample database tables loaded? Are the sample reports used in this book loaded and all files used by them available on my system?

3. 4.

Note: The default location for all sample reports is /demo/bitmap. The default location for all other files (i.e., TIFF files) is /demo/reqfiles.

Getting Started

1 11

1 12

Building Reports Manual

CHAPTER

Tutorial
he best way to learn to use Oracle Reports is to build reports with it. Thats why this fivelesson tutorial takes you step by step through the creation of five different reports:

a default tabular report 2 5 a break report containing computational columns 2 17 a report containing customized text and graphics 2 30 a report that accesses a multimedia object 2 43 a master/detail report 2 55

The goal of each lesson is to build a complete report. When you finish a lesson you can leave the tutorial. However, we recommend that you work through all the lessons consecutively if you can.

Tutorial

21

Lesson Overview
Lesson I Youll create a simple tabular report with the output shown below. This lesson will teach you the basics: how to create a new report, select data for it, and how to save, run, and view it. Youll also learn about Oracle Reports powerful defaulting capabilities.

Lesson II Youll modify the report created in Lesson I to create a break report. This lesson will teach you some simple ways to customize your report, such as how to group information. Youll also create four computational columns.

22

Building Reports Manual

Lesson III Youll reposition the columns of data, add text from a file, and create borders and graphics. This lesson will teach more advanced ways to customize your report, such as manually changing the layout.

Lesson IV Youll add a button that displays an image when pressed. Youll also explore the Previewer (the window in which you view report output), and learn about user preferences.

Lesson V Youll add a master/detail report to the existing layout. This exercise will teach you how to establish relationships between multiple queries, and how to combine more than one layout style into a single report.

Tutorial

23

A Note on Platform Specifics

During the course of the tutorial, you may be asked to create one or more objects of a certain dimension or appearance. The accompanying instructions are merely guides. Since font sizes, sizing algorithms, and so on differ from platform to platform, your objects may not appear exactly as shown in this manual. Feel free to modify the objects as necessary. However, try to preserve their relative proportions and positioning as shown in the accompanying figures. In addition, you may be asked to select certain fonts, text attributes, etc. (for example, to create text with a typeface of Helvetica, a font size of 12, and a weight and style of bold italic). The method used to select fonts is dependent upon your platform, and some of the fonts and text attributes may not be on your machine. Choose the font and text attributes youd like. Have fun. Finally, since Oracle Reports conforms to the native look and feel of the platform on which it is running, differences in the names of options or objects may occurfor example, to exit Oracle Reports, you may choose Quit or Exit, depending on your platform. These variations are slight, and you should have no problem determining what is appropriate for your platform.

24

Building Reports Manual

Lesson I: Create a Default Report


Youve been hired as an application developer for Summit Sporting Goods, a sporting goods manufacturer. Summit has just purchased a new reporting tool, Oracle Reports, so you decide to first familiarize yourself with Oracle Reports defaulting capabilities by creating a report using only default settings. At the end of the lesson, your report will produce output like that shown below. This style of report is called a tabular report.

While you build the report, you will learn how to:

invoke the Oracle Reports designer and create a new report definition 2 6 connect to the database and define your data 2 8 specify a default report layout 2 10 save and run your report 2 13 view your report output 2 15

Approximate time to complete: 30 minutes.

Tutorial

25

Invoke the Oracle Reports Designer

1.

Invoke Oracle Reports. The method you use will depend on your system. If you invoke products via icons on your desktop, doubleclick on the Oracle Reports Designer icon. If you invoke products via command line, see your Developer/2000 Installation Guide. Once you invoke Oracle Reports, the Object Navigator appears. Note: If it does not appear, see your system administrator for help.

About the Object Navigator The Object Navigator is a road map to your report. It not only shows the objects currently in use, it shows all types of objects that you can create or reference. In addition, you can use the Object Navigator to access the properties of objects, create certain objects, rename objects, and examine the structure of your report from different perspectives, or views. Youll have several opportunities to explore the Object Navigator throughout the tutorial.

26

Building Reports Manual

Connect to the Database

Although connecting to the database is not necessary until you actually want to access it, now is a convenient time. 1. Select File>Connect.... (From the File menu, choose Connect....) The Connect dialog box appears, prompting you for your username and password. Click in the User Name field and type your username (e.g.,
scott).

2. 3.

Click in the Password field and type your password (e.g., tiger). Your password will not appear when you type.

4.

If you are connecting to a local database, skip to Step 5. If you are connecting to a remote database (one located on another computer), type your connect string in the database field (e.g., t:boston:payroll, where t is the SQL*Net communications protocol, boston is the database node, and payroll is the database name). Hint: You can also type all three valuesusername, password, and SQL*Net protocolin the username field, as follows:
scott/tiger@t:boston:payroll

However, this method does not conceal your password. 5. Select the Connect button. Hint: You have two other options for connecting to the database. You can connect to your database from a command line (where applicable) when invoking the designer. For more information, see R25DES in Chapter 1 of the Reports Reference Manual. You can also simply proceed to define your data. The first time you attempt to access the database, Oracle Reports will display the Connect dialog box and you can fill it in as explained above.

Tutorial

27

Specify Your Data

After you invoke the designer and connect to the database, your next step is to specify the data for the report. This is done in the Data Model editor, which is accessed via the Object Navigator or the Tools menu. In the Data Model editor, youll create one or more queries, which are data model objects that fetch data for your report. 1. Doubleclick on the icon in the Data Model node (the entry in the Object Navigator directly below Untitled). This displays the Data Model editor. Select the Query tool by clicking on it once in the Tool palette. Hint: If you are uncertain whether youve found the right tool, place the mouse pointer over the tool. After a moment, the name of the tool is displayed. 3. Move the mouse pointer into the Data Model editor. Click once. A query object, represented by a rounded rectangle, appears.

Data Model Icon

Query Tool

2.

4.

Doubleclick on the query object to display its property sheet. (Recall that a property sheet is a window displaying all properties of a single Oracle Reports object.) Click in General:Name, delete Q_1, and replace it with Q_Ordpict.

5.

28

Building Reports Manual

Hint: You are not required to name your query, but we highly recommend that you choose unique, mnemonic names for all the objects in your report 6. Notice the SELECT Statement field. In this field you can type a Select statement, or you can build one using the Table and Column Names dialog box, as follows. 7. Select Tables/Columns. The Table and Column Names dialog box appears, listing all of the database tables to which you have access.

8. 9.

Scroll down the Database Objects list until you see ORDPICT. Select ORDPICT. If you accidentally select the wrong table, simply click on ORDPICT to change your selection. Ordpicts columns appear in the Columns list of values.

10. Select CUSTID, ORDERDATE, ORDID and TOTAL by clicking on them. Note: Use the method appropriate to your platform to select multiple, nonconsecutive items from a list. 11. Select the Selectfrom button to build a select COLUMN(S) from TABLE(S) statement in the SELECT Statement field. Close the Table and Column Names dialog box (select Close). 12. Move your text cursor to the line below from ORDPICT in the SELECT Statement field and enter the following text, as shown:

Tutorial

29

order by CUSTID, ORDID

Note: If the SELECT statement is unclear, refer to your SQL Language Reference Manual.

13. Select OK to close the Query property sheet. A default group, G_Ordpict, is created, containing a list of the selected columns.

Specify a Default Layout

After specifying the data for the report, create its layout. 1. Select Tools>Default Layout... (or the Default Layout tool). The Default Layout dialog box appears. Using this dialog box, you can specify several layout settings. Oracle Reports uses these specifications to create a complete, executable report. You can modify the following settings on the Style tab (refer to the next figure):

Style (e.g., Tabular, Master/Detail, and so on) which determines the initial layout style of your report. Use Current Layout Settings, which determines if Oracle Reports should use its own defaults when creating boilerplate, or if it should use any changes youve made to the default attributes (e.g., new font, font size, type style, and so on).

2 10

Building Reports Manual

You can modify the following settings on the Data/Selection tab (refer to the next figure):

Group and Repeat (e.g., G_Ordpict and Down) which determine the groups to include in the report output and the direction in which to display their data (i.e., down or across the page). Column, Label, Width (W), and Height (H), which determine the columns to include in the report output, their labels, and the widths and heights of the fields that will display them.

2.

Click on Data/Selection:Column:Ordid to deselect it.

Tutorial

2 11

Deselecting ORDID prevents it from appearing in your report. You used ORDID to help order your output, but you wont display it in your report for this lesson. 3. Select OK to accept the dialog box. The Layout editor is displayed in front of the other windows. Examine the objects in the Layout editor. Oracle Reports used the settings in the Default Layout dialog box to generate these objects, which, in turn, will determine how their associated data objects appear when you run the report. The layout objects are (refer to the figure below):

Boilerplate (e.g., Custid) for labelling the data. Fields (e.g., F_CUSTID) for displaying the data. Repeating frames (e.g., the rectangle enclosing the fields), for controlling each record. Frames (e.g., the rectangle enclosing the boilerplate labels) for grouping other layout objects.

2 12

Building Reports Manual

Each type of layout object governs a different aspect of the reports format and final appearance. For example, notice the small arrow in the upperleft corner of the repeating frame. This arrow points down, indicating that the rows will display sequentially down the page.

Save and Run Your Report

While you work on your report, Oracle Reports preserves your changes in a memory buffer. You can save your changes to a file or to the database. During the Tutorial, save to a file to conserve database space. 1. Select File>Save (or the Save tool). The Save dialog box appears.

2.

Select the File radio button and ensure that either All or Reports is checked. Hint: The Preferences dialog box (located via Tools>Tools Options:Preferences) provides a setting enabling you to specify that a module (e.g., your report) always be saved to either a database or a file. If you set this preference, the Save dialog box does not appear. For more information about the Preferences dialog box, see Customize Your Session on page 2 44.

3.

Select OK. The Save To File dialog box appears. Notice the default filename: Untitled.rdf. RDF stands for Report Definition File. You can both open and run .rdf files; they are binary and portable. For more information about the different file extensions, see Oracle Reports File Storage in Chapter 18 of the Reports Reference Manual.

4.

Delete Untitled.rdf, name your report customer, optionally specify a location for it, then select OK.

Tutorial

2 13

5.

Select File>Run (or the Run tool). Oracle Reports displays the Runtime Parameter Form, as shown below.

This window prompts for runtime options that you can be change just before the report is executed; e.g., where to send the report, how many copies to print, etc. For example, you can specify that you want to send it to a file, and in addition specify the filename. Oracle Reports provides several system parameters, two of which are included in the Runtime Parameter Form by default. You can include any or all of the other system parameters in the Runtime Parameter Form, or create your own. For more information about the Runtime Parameter Form, see Runtime Parameter Form in Chapter 9 of the Reports Reference Manual. 6. Select Run Report to accept the default values.

2 14

Building Reports Manual

View Report Output

The Previewer is the window in which you view report output.

1. 2.

Use the scroll bar and arrows to scroll through the page of output. Select Close to close the Previewer.

Time to Explore...

Now that youve finished Lesson I, take a moment to look around. Explore...the Object Navigator The nodes first displayed in the Object Navigator are primarily heading nodesi.e., they denote the major types of objects that can be created during a reportbuilding session, such as the reports themselves, external queries, PL/SQL libraries, etc. For example, the node Reports is a heading node representing all reports that are or may be opened during the current session. Examine some of the other heading nodes. They give clues about what you can add to your report. Youll find out more about external queries, libraries, packages, etc. in Chapters 5 and 6.

Tutorial

2 15

Not all nodes are heading nodes. Look now at CUSTOMER, which should be selected in the Navigator. CUSTOMER is the node representing your report. This node gives you access to all the objects in your report. Explore...the Menus, Toolbar, and Palettes Take some time to familiarize yourself with the all the tools available to help you build reports. Also take a few moments to examine the toolbars on each window. Move your mouse pointer over the tools to find out what theyre called. To help you familiarize yourself with the menus, the Tutorial will initially direct you to menu items. Feel free to substitute tools from the toolbars when available. Note: If you want to continue the tutorial with this report, dont save over customer.rdf. Select File>Save As... and save your experiments under a new name, or select File>Revert when you are finished exploring to revert your report to its last saved state.

Summary of Lesson I

While familiarizing yourself with the basic functions of Oracle Reports, you created and ran a default tabular report. More specifically, you:

invoked the Oracle Reports designer connected to ORACLE (File>Connect...) created a query using the Table and Column Names dialog box selected a default layout (Tools>Default Layout...) saved the report (File>Save) ran the report (File>Run...) accepted the Runtime Parameter Form defaults viewed the report output in the Previewer

If youd like to examine a completed version of this report, it can be found in the demo/bitmap directory under the name of lesson1b.rdf. If youre satisfied with this report, you can exit Oracle Reports. If you want to improve the readability of your report, continue to Lesson II.

2 16

Building Reports Manual

Lesson II: Create a Break Report


You probably see ways to improve your report. For example, you can suppress duplicate values of CUSTID where they appear. Also, you can make the data in the TOTAL column more meaningful by providing summaries (e.g., a total per customer and a grand total for the entire report). To remove the duplicate values, create a break report based on the customer identification number. This will group all information related to a particular customer under the same CUSTID in the report output. To add the summaries, create your own computational columns. At the end of this lesson, the output will resemble that shown below.

As you add these improvements, you will:


change the data model 2 18 update the layout to reflect data model changes 2 19 create a formula column 2 23 create three summary columns 2 22 change the default settings in the Layout editor, then update the layout again to reflect further data model changes 2 27

Approximate time to complete: 45 minutes.

Tutorial

2 17

Invoke Oracle Reports and Open a Report

If you did not exit the designer after Lesson I, skip to Change the Data Model. If you did exit the designer, you need to invoke Oracle Reports and open the report customer.rdf. To do this: 1. 2. 3. 4. Invoke the Oracle Reports designer and connect to ORACLE as you did in Lesson I. Select File>Open... (or the Open tool). The Display dialog box appears. Select the File System radio button, then select OK. The Open dialog box appears. Open customer.rdf using the Open dialog box as you would normally open a file. (Notice that the new report definition, Untitled, is automatically closed if you open a report.)

Change the Data Model

To suppress the duplicate values for CUSTID, create a new group containing the CUSTID column. The new group is a break group; i.e., a group that owns a column with at least one value that repeats over multiple records. 1. Ensure that the Data Model editor is visible, either by doubleclicking on the icon in the Object Navigators Data Model node or by selecting Windows>customer: Data Model. Grab the G_Ordpict group by clicking in the G_Ordpict title bar. Drag the group down about 1 inch. Release the mouse button. Moving G_Ordpict down provides room in the Data Model editor to create a new group. 3. 4. Select the CUSTID column in the G_Ordpict group by clicking on the word CUSTID. Notice that it is now highlighted. Clickanddrag the CUSTID column out of the G_Ordpict group so that it is above G_Ordpict. Release the mouse button. A new group is created around CUSTID and above G_Ordpict, as shown in the next figure. By creating a break group above G_Ordpict, you are specifying that the break group ranks above G_Ordpict in the data hierarchy of the report. Thus, for each value of CUSTID fetched for the break group, all columns in the default group, G_Ordpict, will be displayed.

Create a Break Group

2.

2 18

Building Reports Manual

5. 6.

Doubleclick on the new group to display its property sheet. Click in General:Name and replace G_1 with G_Break.

7.

Select OK.

Update the Report Layout

Youve changed the hierarchy of the data for your report, so the next step is to update the layout to incorporate your changes.

Tutorial

2 19

Hint: Youll need to update the report layout whenever you remove a column, add a column that you want to show in your report, or change the hierarchy of the data in your data model as you just did. 1. Select Tools>Default Layout... (or the Default Layout tool). The Default Layout dialog box appears. Notice that the break group, G_Break, now appears under Data/Selection:Group. 2. Ensure that Style:Tabular is still selected, then choose OK. A confirmation box appears, asking if you want to replace the existing layout.

3.

Select Yes to replace the existing layout. The Layout editor displays the updated layout. Note: Instead of overwriting your layout you can revise it by hand in the Layout editor. Youll do this in Lessons IV and V. The new layout, shown in the next figure, resembles the default tabular layout from Lesson I. It contains the same fields and the same boilerplate labels. The major difference between the layouts is in the number of repeating frames generated for each.

2 20

Building Reports Manual

About Repeating Frames... Repeating frames contain the data owned by their corresponding groups. Theyre called repeating frames because they repeat as many times as necessary to display all values of the data they contain. For example, if a report consists of a single column with ten values, the repeating frame displaying those values repeats ten times. Each instance of the repeating frame contains a single value. This recordlevel display method enables the use of recordlevel printing criteria. The first layout contained only one repeating frame, called R_Ordpict, which contained the columns in the G_Ordpict group. The second layout contains two repeating frames: R_Ordpict, which still surrounds the columns of the G_Ordpict group, and R_Break, which surrounds G_Breaks column CUSTID and the R_Ordpict repeating frame and its columns. Placing the G_Break group above the G_Ordpict group in the Data Model ranks it higher in the data hierarchy and causes the R_Break repeating frame to enclose the R_Ordpict repeating frame in the reports layout. Within one instance of R_Break, R_Ordpict can repeat as many times as necessary to display all records related to R_Breaks current record. This is similar in action to a DOloop in structured programming. In the Layout editor, a repeating frame appears as a box surrounding one or more fields. The arrow on its border indicates the direction in which the repeating frame repeats. Both repeating frames in your layout show downwardpointing arrows on their borders, signifying that both will print down the page. 4. Run the report (select File>Run... or the Run tool, then accept the Runtime Parameter Form). The report output appears in the Previewer, as shown in the next figure.

Tutorial

2 21

The values in your report are now grouped according to customer. But there is more information youd like the report to show:

TAX_TOTAL: a column to that takes each value of TOTAL, computes its proper tax, and adds the two together CUSTOMER_TOTAL: a grand total for each customer of all values of TAX_TOTAL RUN_TOTAL: a column to track CUSTOMER_TOTAL as it accumulates GRAND_TOTAL: a grand total for the report as a whole

To provide this information, youll create several computational columns that calculate values based on the values of TOTAL.

Create Computations

Not all columns must be selected from the database. You can create your own columns to perform computations. Such columns calculate their own values based either on PL/SQL expressions or on data provided by database columns. There are two types of computations you can add to a report:

2 22

Building Reports Manual

Formulas

Compute their own values using PL/SQL expressions. Formulas can operate on multiple values per record (e.g., SAL + COMM). Compute their own values using functions shipped with Oracle Reports. Summaries operate on one value over multiple records (e.g., sum of SAL).

Summaries

Before you add the new computations to your data model, you may need a little more room to work. 1. Find the Data Model editor (select Window>customer: Data Model, or doubleclick on the Data Model node icon in the Object Navigator.). Clickanddrag G_Ordpict down another inch, giving you enough room to enlarge G_Break in the next step. Select G_Break (click in the group title bar), then clickanddrag one of the groups lower handles (the small boxes at the corners) down approximately one inch. Release the mouse button. Use the same method to enlarge G_Ordpict. Click once on the Formula Column tool in the Tool palette, then click below TOTAL within the G_Ordpict group. A new column, initially named CF_1, is created. Since you created the new column within G_Ordpict, it will display as often as the other G_Ordpict columns. 2. 3. Enter the Formula Display the new columns property sheet. Delete CF_1 from General:Name and rename the column TAX_TOTAL. Ensure that the datatype is Number.

2.

Create a Formula Column


Formula Column Tool

1.

Use the Program Unit editor, an integrated PL/SQL editor, to create your formula. 1. Select Formula:Edit.... The Program Unit editor appears, as shown in the next figure. Notice that it already contains a template for your formula.

Tutorial

2 23

2.

Rename the function if you wish, then enter the remainder of the PL/SQL in the Source Text field. Heres the complete formula (assuming a sales tax of 7.5%):
function TAX_TOTAL return NUMBER is TAX_TOTAL NUMBER; begin TAX_TOTAL := :TOTAL + (:TOTAL * .075); return TAX_TOTAL; end;

The colons appear before TOTAL because it functions as a bind variable reference; i.e., the values of TOTAL are substituted into the formula at runtime. If this is unfamiliar, see the PL/SQL Users Guide and Reference. 3. Select Compile. If you typed the function correctly, the status line reports, Successfully Compiled. Otherwise, the status line reports Compiled with Errors, and the Program Unit editor points out your error in the Compilation Messages field. (If this occurs, correct the mistake in the Source Text field and select Compile again.) For more information on using the Program Unit Editor, see the Oracle Procedure Builder Users Guide and Reference

2 24

Building Reports Manual

4.

Select Close to close the Program Unit editor, then accept the property sheet. TAX_TOTAL is now listed as a column belonging to G_Ordpict. The column name appears in italic, indicating that it is a usercreated column.

Create a Group Summary


Summary Column Tool

To create a summary that computes the total per customer: 1. Click once on the Summary Column tool in the Data Model editors Tool palette, then click in the G_Break group below CUSTID. A new column, initially named CS_1, is created. Since you created the new column within G_Break, it will display as often as the other G_Break column, CUSTID. The new summary will appear once for each customer, thus functioning as a grouplevel summary 2. Display the property sheet for the new column. Delete CS_1 from General:Name and enter CUSTOMER_TOTAL. Notice the Function field. The value in the Function field tells Oracle Reports what type of computation the summary will perform. Sum, which already appears, is the default function assigned to usercreated summary columns. Take a moment to click on the Function field and examine the list of functions available with Oracle Reports. Release the mouse button without changing the default value. For details on each of these summary functions, see Column Properties in Chapter 6 of the Reports Reference Manual. 3. Select TAX_TOTAL from the Source list of values. This tells Oracle Reports that you want the summary to add data from the TAX_TOTAL column. 4. Select G_Break from the Reset At list of values. This tells Oracle Reports to reset the value of your summary to zero for each new value of G_Break. 5. Accept the property sheet for CUSTOMER_TOTAL.

Create a Running Summary


Summary Column Tool

To create a summary that keeps track of the total per customer as it accumulates: 1. Select the Summary Column tool, then click in the G_Ordpict group below TAX_TOTAL. A new column, again named CS_1, is created in G_Ordpict. Since you created the new column within G_Ordpict, it will display as often as the other G_Ordpict columns.

Tutorial

2 25

2. 3. 4.

Display the columns property sheet. Name it RUN_TOTAL. Select TAX_TOTAL from the Source list of values. Select G_Break from the Reset At list of values. In this case the accumulating total prints once for each new value of TAX_TOTAL added. Since both CUSTOMER_TOTAL and RUN_TOTAL reset to zero at G_BREAK, RUN_TOTAL shows how, record by record, the value for CUSTOMER_TOTAL accumulates.

5. Create a Report Summary


Summary Column Tool

Accept the property sheet for RUN_TOTAL.

To create a summary that computes a grand total: 1. Select the Summary Column tool and click in an open space in the editor. A new column is created. As it belongs to the report as a whole, it will display only onceby default, at the end of the report. Display the columns property sheet and name it GRAND_TOTAL. Select TAX_TOTAL from the Source list of values. Ensure that the reset level is set to Report. A reset level of Report means that GRAND_TOTAL never resets to zero. Oracle Reports will continue to accumulate the values of TAX_TOTAL until the end of the report. The final data model looks like the next figure.

2. 3. 4.

2 26

Building Reports Manual

Change Default Layout Youve added columns that you want to show in the output, so you Settings and Redefault need to update your layout. This time you can change the defaulting to
improve the overall appearance and readability of your report. Change Layout Settings Oracle Reports offers a variety of options for displaying text and graphics. You can use any font (e.g.,Courier or Helvetica), weight (e.g., bold), and style (e.g., italic) available on your system to create boilerplate text. 1. Go to the Layout editor (doubleclick on the Layout node in the Object Navigator or select Window>customer: Layout.). Note: Do not select a default layout first. Using the choices in the Format menu, specify a font of Arial, 8 pt., bold, as you would normally specify a font in an application. Note: Remember that if you dont have the choices specified here, feel free to choose a comparable type face and style. 3. Notice the Fill Color, Line Color, and Text Color tools located near the bottom of the Tool palette. The middle tool, Line Color, is used to customize borders around layout objects. The top tool, Fill Color, is used to fill layout objects with colors and patterns. The last tool, Text Color, enables you to change the default text color. The Fill/Line/Text Display, the box directly above the three tools, shows the currentlyselected fill, border, and text. The default fill and border for objects created by Oracle Reports are transparent, while the default for objects you create is a black, onepoint line around a white fill. Since you are changing the text defaults, when you redefault the layout, all objects with be created with white backgrounds and black borders. To prevent this, change the fill and border to transparent.
Fill Color Tool

2.

4.

Select the Fill Color tool. When the color palette appears, select No Fill. When you redefault your layout, none of the layout objects will have fills.

Line Color Tool

5.

Select the Line Color tool. When the color palette appears, select No Line. When you redefault your layout, none of the layout objects will have borders.

6.

Select Tools>Default Layout... (or the Default Layout tool) to display the Default Layout dialog box.

Tutorial

2 27

7. 8.

Select General:Use Current Layout Settings to ensure that the new text settings are used as defaults. Accept the Default Layout dialog box and the alert that appears. The layout appears in the Layout editor.

Notice that the boilerplates and fields use the font, the font size, and the weight you specified. Note: If your layout does not match that shown above, you may need to reduce the size of the font, so that all columns and column labels will fit in one row across the report page. To do so, choose a smaller font size, then redefault the layout. You do not need to change the border and fill again. 9. Save and run your report.

2 28

Building Reports Manual

Time to Explore...

Youve finished Lesson II. If youd like to play around a bit with Oracle Reports, here are some suggestions: Explore...the Object Navigator Find the nodes representing the new columns. (Hint: Look under the Data Model heading node.) Use a node to display an objects property sheet. (Hint: Doubleclick on a portion of the objects node.) Examine the node for the formula column. Use the node to invoke the Program Unit editor. (Hint: An icon in the node shows you that the formula column has attached PL/SQL. Doubleclick on that icon.) Now find the nodes representing the new fields and boilerplate Oracle Reports created for the columns (Hint: Look under the Layout heading node.) Explore...the Default Layouts Use the Default Layout dialog box to format your report as a master/detail report. (Select the Master/Detail format and accept the dialog box). Examine the layout objects in the new layout. How many frames? How many repeating frames? What are their print directions (what directions are the arrows pointing)? Explore...Font Attributes Select single text objects and change their font attributes, alignment, etc. Note: If you want to continue the tutorial using this report, dont save the changes you make as you explore. Instead, save your experiments under a new name, or select File>Revert to revert your report to its last saved state.

Summary of Lesson II

While modifying your tabular report into a break report, you:


changed the data model for your report by creating a new group and assigning a column to it created computations changed the settings used by Oracle Reports to create default objects redefaulted the report layout to reflect changes to the data model

If youd like to examine a completed version of this report, it can be found in the demo/bitmap directory under the name of lesson2b.rdf. Youve now completed a break report and can exit if you wish, but to learn how to add text to customer.rdf and manually modify the layout, continue on to Lesson III.

Tutorial

2 29

Lesson III: Add Boilerplate Text and Line Drawings to the Report
customer.rdf is starting to take shape, but still contains only data. Its up to you to improve the appearance and readability of your report so that, by the end of this lesson, it will produce the output shown below. Notice the new title and the modified column labels. Youll also link to a file containing text and pull it into your report, as well as import a graphic and create graphics using Oracle Reports drawing tools.

As you add these new elements, you will learn to:


modify default boilerplate text 2 31 modify the formatting of a column 2 32 add text, a field, and a decorative border and fill to the margin 2 33 add a logo imported from a file to the margin 2 37 add boilerplate from a linked file 2 38

Approximate time to complete: 90 minutes.

2 30

Building Reports Manual

Restart Oracle Reports

If you exited the Oracle Reports designer after Lesson II, restart the designer and reopen customer.rdf. For more information on restarting the designer, see Invoking the Oracle Reports Designer on page 2 6. In Oracle Reports, objects such as column labels, report titles, and graphics (i.e., text and graphics appearing in a report each time it is run) are called boilerplate. Oracle Reports generates default boilerplate, such as column labels. You can modify the default boilerplate, or add new boilerplate, in the Layout editor. 1. 2. If necessary, go to the Layout editor. Select the Text tool in the Tool palette. Move the cursor to the Custid label and click. A box appears around the label, indicating you are in text mode and can add or change text at the position of the cursor. Delete Custid and type Cust ID as the new label. Click anywhere outside the text region to get out of text mode. The Text tool is deselected, the Selecting tool is activated, and the text you just modified is also selected. Click once more outside the text region to deselect it. Your modified report layout should resemble the one below. Remember in the final output for Lesson II the columns containing dollar amounts were not consistently formatted. To make the column values display as dollar values, you can specify format masks for their fields. (Note: Change the field properties and not the column properties. The fields are the layout objects that correspond to columns and govern the way column values appear in the report output.)

Modify Default Boilerplate

Text Tool

3.
Selecting Tool

4.

Tutorial

2 31

Modify Field Properties

Each layout object, like each data model object, has properties you can modify. In this section, youll modify several fields so they display as dollar amounts with all values properly aligned. 1. Doubleclick on the F_TOTAL field to display its property sheet. Just as with data model objects, doubleclicking on a layout object displays its property sheet. 2. Click in Object:Format Mask and give F_TOTAL a format mask of $NNN,NN0.00. This tells Oracle Reports to display the contents of the field with at least one number before and two numbers after the decimal point (as indicated by the positions of the zeroes) and to include a negative sign if the value is negative, but no sign if the value is positive. The character N tells Oracle Reports to display a number in that position if it exists, but not to pad with blanks if it does not. For more information on format masks, see Format Mask in Chapter 8 of the Reports Reference Manual. 3. 4. Accept the property sheet. Display the F_CUSTOMER_TOTAL property sheet and change its format mask to $NNN,NN0.00. Hint: Instead of typing the format mask in the field again, click on the arrow next to the field. A list of values appears, containing the format mask you specified for F_TOTAL. Each time you create a new format mask, it is added to the list. Select it, then select Insert to insert the mask into the Format Mask field. 5. Using the same process, change the format masks for F_TAX_TOTAL, F_RUN_TOTAL, and F_GRAND_TOTAL to
$NNN,NN0.00.

Hint: If you have several fields that require the same format mask (or any common property) select all of them at once using the method appropriate to your platform for selecting multiple objects, and select Tools>Common Properties.... The Common Properties property sheet appears. Go to Field:Format Mask, and either enter the mask, or list the available masks and select one. The Common Properties property sheet contains all settings the objects have in common, and you can modify them hereas long as you want to change them all to the same value. 6. Run your report again to see the change in formatting.

2 32

Building Reports Manual

7.

Close the Previewer.

Add Boilerplate and Fields in the Report Margin

By default, only the body of a report is displayed in the Layout editor. However, a margin area is also created for each physical (i.e., printed) report page. You can display layout objects in the margin area as well. For this report, youll add the following objects to the margin:

highlighted title field for the current date company logo object with a border and fill

Add a Highlighted Title

1.

Margin Tool

Select View Options>Layout... to display the Layout Options dialog box. Go to Layout:Display Layout Using: and select the Margin radio button, then select Apply to accept changes without closing the dialog box or OK to accept changes and close the dialog box. (You could also use the Margin tool). By default, your report has 0.5 inch top and bottom margins, and no left or right margins. The default margins arent large enough to contain everything youll add to this report, so youll resize them.

Tutorial

2 33

Note: Objects in the report body are visible while the margin is displayed so you can position objects in the margin relative to them. You cannot select or edit them. 2.
Text Tool

Clickanddrag the upper edge of the report body down 0.5 inch, to give your report a 1inchwide top margin. Select the Text tool, move the cursor to a point about 2.5 inches across the page and halfway down the margin, click, and type
...Monthly Sales Report.

3.

4.

Drag the cursor across the length of the text you just typed, highlighting it. Using the choices under the Format menu, select bold, italic 18point Arial as you normally do on your platform. Remember, if any of the above choices are unavailable, choose a comparable one.

Note: Unless you changed the font characteristics from Lesson II, you should only need to change the font size and style. 5. 6. Click outside the title to deselect it. The title appears in the specified font, size, and weight. Run your report to see the new title.

2 34

Building Reports Manual

8. Add the Current Date

Close the Previewer.

Next, youll add a field for the current date to the margin. 1. Verify that the title is deselected, then return the font size to 8 points. Select the Field tool. Starting directly below the M in Monthly, drag down and to the right to draw a field about one inch long. Display the new fields property sheet. Rename it F_DATE. Display the list of possible source columns (select Source) and select &Current Date. The values for all fields in your report are currently supplied by data fetched from the database. Oracle Reports also provides several sources for field values, including the date, the page number, and the total number of pages. 5. Go to General Layout:Sizing:Horizontal and select Variable to ensure that, no matter what size you drew the field in the margin, it is capable of properly displaying the date. Accept the property sheet.

Field Tool

2. 3. 4.

6.

Tutorial

2 35

Add a Border and Fill

Text is just one type of boilerplate object you can create in the Layout editor. The Tool palette contains tools for drawing a wide variety of shapes, such as circles, squares, rectangles, rounded rectangles, and more. You can also assign borders and fills to these objects. 1. Select the Rectangle tool. Starting in the upperleft corner of the margin, drag down and to the right to create a rectangle enclosing the entire top margin. When you release the mouse button, the rectangle is created on top of the boilerplate text. With the rectangle still selected, select the Fill Color tool to display the fill color palette. Choose a color. Were using light gray. Select the Line Color tool to display the line color palette. Select the solid black square. The border of the selected boilerplate, as well as the borders of any subsequentlycreated layout objects, will now display as a solid black line until you choose another color or pattern. 4. Select Format>Line, then choose a line width. This specifies a width for the border around the boilerplate (and any other objects you create in the Layout editor until you choose another width). Note: You can also use the Fill and Line Color tools to assign patterns and colors to layout objects. 5. Select Arrange>Send to Back. The rectangle is placed behind the title, as shown by the figure.

Rectangle Tool

Fill Color Tool Line Color Tool

2. 3.

2 36

Building Reports Manual

6.

Deselect the rectangle. Select the Line Color tool again and select No Line, then select the Fill Color tool and select No Fill. This step ensures that subsequently created layout objects will not have fills or borders until you select a new pattern.

Import Layout Objects

You can import images, drawings, and Oracle Graphics displays from files or the database into reports. Supported formats include CGM, TIFF, BMP, and Oracle Format. 1. Select Edit>Import>Image... to display the Import Image dialog box. Here youll specify the location (and optionally, the format) of the item you will import. Ensure that the File radio button is selected. Notice the value of Any shown in the Format field. This indicates that you want Oracle Reports to determine the file format of your image. To display a list of all formats supported by Oracle Reports, click and hold on the list button. Notice some of the other choices available in the Import Image dialog box. You can import an image from the database and determine the relative quality of the imported image (the higher the quality, the more storage space the image requires). 3. Click on Browse. The File Selection dialog box appears. Change the directory listing to show the files available in the reqfiles directory and select summit.tif from the list of files. Select OK. The company logo is imported into the margin. The image summit.tif has now been added to your report definition. It will appear in the report margin in its current form even if the original TIFF image is deleted or moved from its current location in the file system. 4. 5. Keep the image in the upperleft corner of the margin area, but resize it so that it doesnt overlap the title. Save and run your report. The logo appears in the report margin.

2.

Tutorial

2 37

Add Boilerplate From a Next, add text from a file to the report. To do so: Linked File move several objects in the Layout editor simultaneously

link to a file containing text

Move Objects in the Layout Editor


Body Tool

Before adding the text, move the layout objects out of the way. 1. Select View Options>Layout:Display Layout Using: and select the Body radio button. Accept the dialog box. (You could also use the Body tool). The margin disappears. Click in the outermost frame (M_Break_GRPFR), and drag all the layout objects down about 1.5 inches. Dragging all objects together is possible because, by default, the Layout editor is in Confine mode. All layout objects must remain within their parent objects. Since M_Break_GRPFR is the outermost frame of the break layout, when it is repositioned, all other objects are repositioned with it. Note: If the M_Break_GRPFR is the only frame that moves, Confine mode has inadvertently been disabled, as shown by the Confine tool. Select Edit>Undo to restore the frame to its original position, then toggle Confine mode on.)

2.
Confine Mode On

Confine Mode Off

2 38

Building Reports Manual

3. Add Text From a Linked File

Move your cursor to a blank area and deselect the frame.

Now you can add a paragraph of boilerplate text. This time, youll add it by linking to a file containing the text. Linking to a file differs in an important way from importing a file into a report. Importing summit.tif actually made the TIFF image a part of the report. Linking to a file, on the other hand, tells Oracle Reports to pull the contents of the file into your report each time the report is run. Your report will always include the most recent version of the file. To modify the contents, edit the file, not the report. Oracle Reports also provides an environment variable, REPORTS25_PATH, that you can set to preserve the portability of your reports. For more information about Oracle Reports environment variables, see File Searching Method in Chapter 18 of the Reports Reference Manual.

Link File Tool

1.

Select the Link File tool. Beginning in the upperleft corner, clickanddrag a box about 3 inches across and 1.5 inches down the page. Adjust it as you wish to fill up the space between the top of the report body and the layout objects. Release the mouse button to create a boilerplate object, marked by a large X, in the report body. Your layout should resemble the next figure.

2.

Tutorial

2 39

3.

Doubleclick on the boilerplate object to display its property sheet. Go to Object:Name and rename it B_Intro. B_Intro is external boilerplate, meaning that the boilerplate contained by the boilerplate object comes from a file. Display the list under Format to see the types of files to which you can link. Leave the format as Text.

4.

Move to the Link File field and select List.... Go to the reqfiles directory and specify intro.dat. Note: If you cannot find intro.dat, use any small text file you have available. Select OK. intro.dat (and its directory path) now appears in the Link File field. Display the list under General Layout:Sizing:Vertical and change the value to Variable. The text in intro.dat will appear on only the first page of your report, but if you dont change the vertical size of the boilerplate object in which it appears from Fixed to Variable, any subsequent page of report output will display a large blank space corresponding in size to the boilerplate object. Note: If your platform supports the use of OLE2 (Object Linking and Embedding), you can select the OLE2 tool and create a piece of OLE2 boilerplate, in which you can display an OLE2 object. However, your report would not be portableif you moved the report to a different location, the link to the object would break. Giving the boilerplate object a variable size ensures that Oracle Reports will adjust the position of other layout objects around it accordingly; i.e., on the following pages Oracle Reports will push them into the space that would otherwise contain the boilerplate.

5. 6.

7.

Accept the property sheet. The Layout editor reappears, and the boilerplate object now contains the text from the linked file. The text appears in the same font as the date field.

8.

Change the font size of the text or resize the boilerplate object to better fit the text within the boilerplate. Weve changed the text from 8 points to 9, and from bold italic to bold. You can specify the alignment of the text within the boundaries of the object. With the boilerplate object still selected, select Format>Alignment and change the alignment to Left, Center, or Right. Well leftalign it.

2 40

Building Reports Manual

Add a Border to Each Record

1. 2. 3.

If your new boilerplate is still selected, click in an empty area of the Layout editor to deselect it. Select the R_Break repeating frame. Selected the Line Color tool to display the line color palette. Choose the solid black square. Delete the boilerplate lines under the following column headers: Custid ID, Orderdate, Order, Total, Tax Total, and Run Total, and the boilerplate lines over the following fields: F_CUSTOMER_TOTAL, and F_GRAND_TOTAL. (Select the lines, then select Edit>Clear.) Since youve added a border, the lines appearing under the column labels are no longer necessary. Save and run your report.

Time to Explore...

Now that youve finished Lesson III, take a moment to look around. Explore...the Margin Reopen the margin area of your report. Try to select and modify objects in the report body. Scroll down the the bottom of your report page and note the bottom margin. Resize the margin as desired. What happens to the placement of layout objects in the report body when you make the margin bigger? Smaller?

Tutorial

2 41

Explore...the Drawing Tools Use the drawing tools to create objects in the Layout editor. (Remember, if you position the mouse pointer over one of the tools, the name of the tool will display.) Give the objects fills and borders, and, if you have a color monitor, assign them foreground and background colors. In addition, menu choices under the Format menu can be used to enhance the appearance of your reports. You can change the width and appearance of lines and borders. Explore...the Object Navigator Youve created many new objects in this lesson. Find their nodes in the Object Navigator. Note the different types of boilerplate objects that are listed. Where do you find the nodes for the objects youve created? Explore...Layout Editor Modes Go to the Layout editor and try moving objects around. If the object is inside (a child of) another object, what happens? Use the Confine tool to turn Confine mode off. Now move the layout objects. What happens? Note: If you want to continue the tutorial using this report, dont save the changes you make as you explore. Instead, save your experiments under a new name, or select File>Revert to revert your report to its last saved state.

Summary of Lesson III To make your report easier to understand, you modified it by changing
the layout and adding such boilerplate objects as titles, headings, text, and graphics. You:

modified boilerplate objects modified field formats added text, fields, and imported graphics to the reports margin linked to a file so that its contents would appear in the body of your report at runtime

If youd like to examine a completed version of this report, it can be found in the demo/bitmap directory under the name lesson3b.rdf. Youve made the purpose of your report much clearer and can exit if you wish, but if you want to add computations to your report, continue on to Lesson IV.

2 42

Building Reports Manual

Lesson IV: Incorporate Multimedia Objects


Not everyone at Summit can identify a customer by ID number, but you dont really have room in your layout for another column. You can, however, display an electronic business card for each customer in the Previewer with just a touch of a buttona button you create as part of your report. At the end of this lesson, your report will produce the output shown below.

As you add the buttons you will learn how to:


customize your session 2 44 add page numbers 2 46 add multimedia capability to the report 2 47 view the report output using more sophisticated Previewer functionality 2 52

Approximate time to complete: 60 minutes.

Tutorial

2 43

Customize Your Session

Oracle Reports gives you a number of options for customizing your session. Two different dialogs display your options:

Tools Options (select Tools>Tools Options..., then select the appropriate tab: Preferences, Runtime Parameters, or Runtime Settings) Report Properties (doubleclick on the report icon representing the current report

The different dialogs serve three different purposes. Preferences The Preferences tab of the Tools Options dialog contains several settings that affect your environment while you are in the designer, but are not necessarily saved with the report.

If you want your preferences to remain in effect only for the current Oracle Reports session, select OK. If you want your preferences applied to subsequent Oracle Reports sessions, select Save at any time during the session. All preferences are saved to the file prefs.ora, located in your Oracle home directory. Note: The exact location of this file is operating systemdependent. For the location of this file, see your Developer/2000 Installation Guide. For an explanation of each field in the Preferences tab, see your online help. Runtime Parameters The Runtime Parameters tab of the Tools Options dialog box enables you to set the values of Oracle Reports system parameters. These values will persist for the length of the current session until you change them.

2 44

Building Reports Manual

Runtime Settings The Runtime Settings tab of the Tools Options dialog box contains several settings that affect the way your reports run during the current session but are neither saved with your report nor saved in a preferences file for use during subsequent sessions.

Note: The settings on both the Runtime Parameters tab and the Runtime Settings tab correspond to several of the runtime options available with the Oracle Reports designer executable. For more information about each of the settings, see R25DES in Chapter 1 of the Reports Reference Manual.

Tutorial

2 45

Report Properties The Report Properties property sheet contains several settings that affect the current report. These settings are saved with your report definition and become a part of your report. For more information on report properties, see Report Properties in Chapter 4 of the Reports Reference Manual.

Change Report Properties

Thus far your entire report output fits on one standard lettersize (8.5 inches by 11 inches) page. Company format requires 8.5 inches by 6 inches. Youd like to change the page size of your report so that it prints in the correct size automatically. 1. 2. 3. Doubleclick on the report icon in the CUSTOMER node. Go to Report:Page Height: and replace the default height of 11 with 6. Select OK to close the property sheet with your change in effect.

Add Page Numbers

Now that your report has a smaller page size, it is highly unlikely the complete output will fit on one page, so next youll add page numbers. To ensure they appear on each page, youll place them in the margin of the report, as you did with the report title. The page number, like the current date, is a dynamic value; i.e., it changes with each new page. To ensure the page numbers are correct, take the following steps.

2 46

Building Reports Manual

Margin Tool

1.

You added a border to the R_Break repeating frame, so make sure you display the Line Color color palette and select No Line again. Display the margin (use the Margin tool or the Layout Options dialog). Next, specify the same text attributes you used for the date text: 8 point, bold, italic Arial. Select the Text tool, then select a suitable location in the margin, click the mouse, and type Page. Get out of text mode. Select the Field tool. Draw a field about two characters wide and one character high to the right of the word Page. Doubleclick on the new field to display its property sheet. Go to Object:Name and rename the field F_PAGENO. Select a source of &Physical Page Number. In the report output, the current page number will appear in the field F_PAGENO. Accept the property sheet and return to the Layout editor. Note: To precisely align the label Page with the field F_PAGENO, select both objects and select Arrange>Align Objects.... In the Alignment Settings dialog box, make sure the Align To Each Other box is checked, then select the Align Top radio button and accept the dialog box. The top margin should appear as shown below.

Text Tool

2. 3.

Field Tool

4. 5. 6.

Add Multimedia Capabilities

Now its time to turn your report into a genuine multimedia presentation with a button that will display in the Previewer and enable you to access multimedia files. Before you add the button, you need to do the following:

add the column designating the images enlarge the layout objects that will enclose it

Note: :Before you begin, copy the following files from the reqfiles directory your working directory: evrymntn.tif, jockspor.tif, justenn.tif, ktsports.tif, nrthwood.tif, shapeup.tif, tkbsport.tif, volyrite.tif, and womnsprt.tif.

Tutorial

2 47

Add the Source Column

Your report includes nine different customers, so youll need to display nine logos. Importing or linking to nine files would require nine buttons and would be extremely cumbersome and difficult to maintain. However, you have another option. For each image you want to display, you can include the names and directory path information in a database column, then include that column in your SELECT statement. 1. Open the Data Model editor and doubleclick on Q_Ordpict to display its property sheet. Add the column CARDS to the list of columns selected. Now your SELECT statement reads:
select CUSTID, ORDERDATE, ORDID, TOTAL, CARDS from ORDPICT order by CUSTID, ORDID

Accept the query property sheet. 2. Display the property sheet for CARDS. Select General:Read From File. Selecting Read From File tells Oracle Reports to treat each column value as a link to a file. Now your report will find that file and display it. If you dont check Read From File, your report will display the names and path information contained in each record. 3. Select Image as the format. Now youre telling Oracle Reports that the files named in the column are image files. Accept the property sheet and return to the Layout editor. Enlarge the Layout Before you add the button, you need to enlarge the layout objects that will enclose it. If you have trouble identifying the objects in the Layout editor, you can navigate to them using the Object Navigator. 1. If necessary, close the margin. Display the Object Navigator (select Window>Object Navigator). Position it beside the Layout editor on your display. If you havent used the Object Navigator during your explorations, nows your opportunity. The Object Navigator provides a quick and easy way to find report objects and access their properties. 2. Click on the plus sign in the Layout node. The node expands to show a list of heading nodes. Each heading node corresponds to a type of object you can include in your report layout. Each node that contains a plus sign can be expanded further. Clicking on a minus sign will collapse a node. A node prefixed by a grayedout plus sign has no sublevels.

2 48

Building Reports Manual

3.

Expand the Body header node and click on the name M_Break_FTR. Notice that when you select the node, the frame is selected in the Layout editor. You can now go to the Layout editor and resize the frame.

Flex Mode On

4.

Select the Flex tool in the toolbar to toggle Flex mode on. Clickandhold inside the footer frame and drag the footer and its contents down about .25 inch. Deselect the frame. When Confine mode is used in conjunction with Flex mode, a parent object automatically resizes to accommodate a child objects new position. If Confine mode is off while Flex mode is on, a child object can be resized, and once again the parent will resize to accommodate.

Flex Mode Off

5.

Toggle Flex mode off. Select the R_Break node. Clickandhold on one of the repeating frames lower handles. Enlarge the frame to fill in the space below the M_Break_FTR frame. Deselect the repeating frame.

Add a Button
Button Tool

1.

Select the Button tool and clickanddrag out a small region in the space directly below the F_CUSTID field. Take a moment to examine the Object Navigator. Notice that below R_Break is now U_1, a button node.

2.

Doubleclick on the button to display its property sheet.

Tutorial

2 49

3. 4.

Go to Object:Name and rename the button Card_Button. Select Multimedia Column as the action. The type of action you select tells Oracle Reports what to do when the button is pressed in the Previewer:

Multimedia Column says use the values of column records to obtain filenames of images, sounds, etc. to display Multimedia File says display the multimedia object identified with the filename provided PL/SQL says execute the specified PL/SQL construct Note: Not all actions are available on all platforms. For more information about the multimedia actions available on your platform, see your Developer/2000 Installation Guide.

5.

Display the dropdown list next to Multimedia Column and select CARDS (it should be the only column name available). CARDS, the source for your button, contains the names of image files. Notice that Type has automatically been updated to Image based on your selection. Oracle Reports automatically determines sound and image formats, as it did when importing the Summit Sporting Goods logo.

6.

Type Business Card as your label.

2 50

Building Reports Manual

Two different types of labels can appear on your button: a text string (the default) or an icon. This report will use a text string. 7. Accept the property sheet, then save and run your report.

Using Buttons in the Previewer

Notice the locations and appearance of the buttons in the Previewer. You created the button object in the R_Break repeating frame; therefore, it repeats once for each record. 1. Click on the first button. Oracle Reports displays the first image in the Image Viewer. Using the Image Viewer, you can magnify or reduce an image, pan across an image too large to be completely displayed on the screen, and select portions of an image to cut or copy. 2. Close the Image Viewer and click on the next button. The next image appears in the Image Viewer. Note: Certain restrictions apply to buttons:

Only one button can be activated at any one time. If you try to select another button you will receive an error message.

Tutorial

2 51

Buttons and the media they invoke can only be viewed in the Previewer. They will not display in any fashion in report output written to a file, sent to the printer, or mailed to other users.

For more information on buttons and their properties, see Button Properties in Chapter 8 of the Reports Reference Manual.

View Your Report in the Previewer

While your report output is being displayed, take a moment to explore several of the convenient features provided by the Previewer for viewing and printing your reports, such as:

scrolling paging split vertical and split horizontal multiple Previewers printing from the Previewer Note: If your system supports a variety of printers, you may need to select a default printer before you can print from the Previewer. For more information about choosing a printer, see your Developer/2000 Installation Guide.)

Scroll

Click on the scroll bars and scroll arrows. Scroll through the output now to see your data, as well as the title, logo, page number, etc., that you added to the report. Select Next to go to the next page of the report and Prev to go to the previous page. First and Last take you to the first and last pages of the report, respectively. To go to a selected page, enter the page number in the Page field, then select the Page button. You can also split the screen, either horizontally or vertically, to create two views of your output. This enables you to examine two different sections of the output at the same timefor example, to make sure two layout objects are properly aligned. 1. Move the cursor to the box at the far left of the bottom horizontal scroll bar on the Previewer, then clickanddrag the box to the approximate center of the scrollbar. When you release the mouse button, the Previewer window splits into two vertical sections, each showing part of the current page. 2. Use Split Horizontal in a similar fashion, by dragging the box at the top of the right vertical scroll bar toward the center of the window.

Page Up and Page Down

Use Split Vertical and Split Horizontal

2 52

Building Reports Manual

You can scroll and page through each view independently. Note: You cannot use Split Vertical and Split Horizontal simultaneously.

Magnify or Reduce the Image

To magnify the image of the report output in the Previewer, click on the large magnifying glass icon in the lowerleft corner of the Previewer border. (Conversely, select the small icon to reduce the image.) Next, click anywhere in the Previewer. Repeat this step to increase the magnification or reduction. Select the New button in the current Previewer. This displays a second Previewer. You can use its paging and scrolling functions to compare different pages of your report.

Use Multiple Previewers

Print from the Previewer

1.

Select Print. The Print Job dialog box is displayed. You can use this dialog box to print your report or write it to a file. (The Print Job dialog box varies according to platform. For more information about the Print Job dialog box, see your Developer/2000 Installation Guide.

2.

Close both Previewers and save your report.

Tutorial

2 53

Time to Explore...

Now that youve finished Lesson IV, take a moment to look around. Explore...Customizing Your Session Examine the tabs on the Options dialog box and the Global Properties property sheet. Experiment with some of the settings. You might:

Suppress the Runtime Parameter Form: When you dont need to change any values for parameters in the Runtime Parameter Form, you can suppress its appearance. To do so, display the Runtime Settings dialog box by selecting Tools>Tools Options:Runtime Settings. Deselect the Parameter Form check box to suppress the appearance of the Runtime Parameter Form at runtime. Select OK to close the dialog box with your change in effect. Run your report.

Change the unit of measurement: If you want to create reports based on centimeters or picas, you can change the default unit of measurement. by selecting Tools>Tools Options:Preferences. Clickandhold on the Unit of Measurement field to see a dropdown list of all available units. Select one, then accept the dialog box.

Explore...Multimedia Run your report again and use the tools provided by the Image Viewer to examine the images. If you have access to other image or sound files, change the source of your button to a different sound or image. Note: If you want to continue the tutorial using this report, dont save the changes you make as you explore. Instead, save your experiments under a new name, or select File>Revert to revert your report to its last saved state.

Summary of Lesson IV In Lesson IV of this tutorial, you added multimedia to your report.
Specifically, you:

customized your report added a page number and aligned objects added a button that enabled you to display images in the Previewer viewed the report output using more advanced Previewer functions

If youd like to examine a completed version of this report, it can be found in the demo/bitmap directory under the name of lesson4b.rdf. In the final lesson youll learn to create a report containing two different layout styles: tabular and master/detail.

2 54

Building Reports Manual

Lesson V: Combine Report Types


The flexibility of Oracle Reports formatter enables you to build a single report containing more than one layout style. In this final lesson youll learn how to take advantage of this functionality by adding a second layout to customer.rdf. This new layout will display different data in a different format than the existing break report layout. At the end of this lesson, your report will produce output like that shown below.

As you create the master/detail report, you will learn how to do the following:

create a master/detail data model 2 56 add another default layout to an existing report layout 2 58 force a page break before the new layout 2 59

Approximate time to complete: 60 minutes.

Tutorial

2 55

Create a Master/Detail Data Model

Master/detail data models are very similar to break report data models. However, a master/detail data model is created using two queries, each of which owns at least one group, and a data link. A break report data model is created using one query and at least two groups. While reports based on a single query are usually more efficient than reports based on multiple queries, sometimes the structure of your data tables may require you to link multiple tables. For more information about how different data models affect report performance, see Data Model Suggestions in Chapter 17 of the Reports Reference Manual.

Create the Detail Query


Query Tool

You already have the master queryQ_Ordpict. You now need to create the detail query. 1. In the Data Model editor, create a query (select the Query tool in the Tool palette, then create a new query object to the right of Q_Ordpict). Display the property sheet, go to General:Name, and rename the query Q_Products. Type the following SELECT statement:
SELECT CUSTID, CUSTNAME, PRODNAME, AMOUNT FROM SALES ORDER BY CUSTID

2.

Accept the property sheet. Link the Queries Queries are generally linked via a common column. In this case, both queries have selected the CUSTID column. (To distinguish between the two columns, Oracle Reports appends a 1 to the name of the second CUSTID column selected.) Using the CUSTID column, create a link to establish the relationship between the queries. 1. 2. 3. Select the Data Link tool in the Tool palette. Move to the G_Break group and click on the CUSTID column. Drag the mouse cursor to the G_Products group and release the mouse button over the CUSTID1 column. The link appears in the Data Model editor. Notice the direction of the arrow. It shows the flow of the data from the parent group (G_Break, the group owning the first selected column) to the child query (Q_Products). In the Ordpict table, CUSTID is the primary key; i.e., each value in the column can be used to uniquely identify the record in which it is found. In the Sales table, CUSTID is a foreign key; i.e., it can use CUSTID to link to Ordpict and reference records in that table. The figure below illustrates this link.

Data Link Tool

2 56

Building Reports Manual

For more information on primary and foreign keys, see the SQL Language Reference Manual. 4. Doubleclick on the link to display its property sheet.

WHERE appears by default in the SQL Clause field, but you can also

use HAVING and START WITH. The equal sign (=) displayed in the Condition field shows that the link is an equijoin. An equijoin, also called a simple join, combines rows from two or more tables, based on an equalityi.e., CUSTID and CUSTID1. 5. 6. 7. Close the Link property sheet without changing any settings. Clickanddrag the CUSTNAME column and drop it above G_Products, creating a new break group. Display the property sheet for the new group and name it
G_Customer.

This new data model will not only have a master/detail relationship, but a break within the detail group. Youll need this break to suppress the display of duplicate values of CUSTNAME.

Tutorial

2 57

This break is similar to the break you created in Lesson II to prevent the display of duplicate values of CUSTID. Your data model should look like this:

Add a New Layout to an Existing Layout


Additional Default Layout Tool

Now youll add the master/detail layout to your reportwithout replacing the existing break report layout. The first step is to define where you want the master/detail layout to appear. 1. Go to the Layout editor. Select the Additional Default Layout tool. (Note: Use the Additional Default Layout tool from the Tool palette, and not the Default Layout tool from the toolbar.) Starting about 3.5 inches down the page and about 0.5 inch across the page, clickanddrag a region about 4 inches wide and 1.5 inches high. Release the mouse button. The Default Layout dialog box appears. Select Style:Master/Detail. Examine the Data/Selection tab. It contains all of the settings from the last time you accepted it, plus the default settings for the G_Customer and G_Products groups. 3. Click on Data/Selection:Group:G_Ordpict to deselect it. G_Ordpicts columns disappear from the Column section. Deselecting G_Ordpict tells Oracle Reports not to create layout objects for its columns. 4. Move to Data/Selection:Column. Deselect GRAND_TOTAL, CUSTOMER_TOTAL, CARDS, and CUSTID1.

2.

2 58

Building Reports Manual

The first three are the columns from G_Break that youve already displayed. They have no relationship to your new query, so you can deselect them. CUSTID1 served to enable you to link the two columns, but you already have CUSTID, so you can deselect it. 5. Clickandhold on the Repeat field for the G_Break group and select Across/Down from the list of values. This tells Oracle Reports to print the data from the G_Break columns across, then down, each physical page. 6. Delete the label CUSTNAME and type Customer. Use the same method to change the PRODNAME label to Product and the label CUSTID to Cust. ID. In Lesson III you modified column labels directly in the Layout editor. If you know what you want to label columns before you default the layout, you can modify them in the Label field. 7. Change the widths of CUSTNAME and PRODNAME to 15 and the width of AMOUNT to 12. Changing the column widths ensures that their fields will fit in the layout. 8. Accept the dialog box. The Layout editor displays the new master/detail layout in the region you created, as shown below. Notice the arrows appearing on the repeating frames. The arrow on R_Break1 points across the page, while the arrow on R_Products points down the page.

Force a Page Break

To separate the two sections of your report, you can specify that the master/detail section begin on a new page. 1. 2. Display the property sheet for the M_Break_GRPFR1 frame. Under General Layout:Pagination select the Page Break Before check box. Accept the M_Break_GRPFR1 property sheet.

Tutorial

2 59

Notice the Page Break Before icon appearing on the bottom edge of M_Break_GRPFR1. Since the M_Break_GRPFR1 group frame encloses all the master/detail layout objects, when you select Page Break Before all of the objects inside the frame will automatically move to a new page. Modify the Spacing of the Data 1. 2. Display the property sheet for the R_Break1 repeating frame. Under General Layout:Spacing:Vertical enter 0.25 and accept the

property sheet.
Vertical Spacing determines how much blank space should be left between instances of a repeating frame. Here, 0.25 inch of blank space will appear between each set of customer information. 3. Save and run your report. Examine the last three physical pages of report output to see your master/detail report. Once again, a dollar amount does not appear as a dollar amount, so youll need to give F_AMOUNT a format mask. 4. 5. Close the Previewer. Display the property sheet for F_AMOUNT and give it a format mask of $NNN,NN0.00 Run your report again to verify the format of AMOUNT.

2 60

Building Reports Manual

Time to Explore...

Before you leave the Tutorial, take a few moments to explore your new master/detail report. Explore the Object Navigator Examine the nodes listed under both Data Model and Layout. See if you can identify the new nodes for the master/detail data model and layout objects. Select Navigator>Navigator Options... to display the Object Navigator Options dialog box, and change the settings. Select Display Cross References, then examine the nodes again. What do they show? Under Group Settings, deselect View Groups by Structure. How do the nodes under the Data Model node change? Also deselect View Layout by Structure and see how that affects the nodes listed under Layout. Explore Print Direction Delete the master/detail section (either draw a bounding box around the layout objects to select them all, or click with the Frame Select tool in the outermost frame). Use the Default Layout tool to redefault the master/detail layout and change the print directions for the different groups.

Summary of Lesson V

In Lesson V, you:

created a master/detail report added a default layout to an existing report layout forced a page break before the master/detail section changed the print direction of a repeating frame and adjusted the spacing of data

If youd like to examine a completed version of this report, it can be found in the demo/bitmap directory under the name of lesson5b.rdf.

Tutorial

2 61

Conclusion

Congratulations! Youve completed the Tutorial for Oracle Reports. If youre in a hurry to build a particular type of report, turn to Chapter 4, Visual Index, and leaf through the visual index of report outputs. Find the type of report output youd like to produce, then go to the associated report in either Chapter 5 or Chapter 6, and build it. However, remember that in this tutorial weve only been able to show you a few of Oracle Reports many capabilities. The fastest way to become an expert report builder is to continue to work your way through this book. We suggest that you:

read Chapter 3, Oracle Reports Concepts, to gain a deeper understanding of the objects that make up a report and the interface you use to create it. build the reports in Chapters 5 (Introductory Reports), 6 (Advanced Reports), and 7 (New Features). This will give you experience with all the basic report types and many of the features provided by Oracle Reports.

2 62

Building Reports Manual

PART

II

Understanding Oracle Reports

CHAPTER

Oracle Reports Concepts


his chapter describes Oracle Reports concepts that will help you become more proficient when designing production reports:

Oracle Reports Object Navigator 3 2 Oracle Reports objects 3 3 matrix reports 3 42 PL/SQL in reports 3 56 editors and Previewer 3 59 executables 3 63

Concepts

31

Oracle Reports Object Navigator


The Object Navigator shows a hierarchical view of the objects in your current session. In the Object Navigator, you can access the properties of each report object as well as each database object (such as stored procedures) and all PL/SQL packages that are shipped with Oracle Reports. Additionally, you can access helpful design information such as a list of your debugging actions and variable values under the Debug Actions and Stack nodes. In the Object Navigator, each level is a node, representing objects and types of objects your report can contain or reference.

For more information about the Object Navigator, see Object Navigator in Chapter 12 of the Reports Reference Manual.

32

Building Reports Manual

Oracle Reports Objects


The objects you create with Oracle Reports are either:

modules, which are toplevel objects (e.g., a report) that can be referenced by other objects (e.g., an Oracle Forms form) reportlevel objects, which are objects that comprise a report

Modules
A module is a toplevel object (e.g., a report) that can be referenced by other modules (e.g., an Oracle Forms form). Modules may be referenced numerous times by numerous other modules.

Module Types

You can build three types of modules with Oracle Reports:


external queries, which are ANSIstandard SQL SELECT statements that can be referenced by modules external PL/SQL libraries, which are collections of PL/SQL source code that can be referenced by modules reports, which are collections of reportlevel objects and references to external queries and PL/SQL libraries (optional) that can be referenced by modules

The benefits of modules are twofold: you never have to create the same module twice; and when you change a module, the modifications are available to all reports or applications that reference it. Thus, using modules speeds both application development and maintenance.

Concepts

33

Creation

To create modules with Oracle Reports, select File>New from the main menu, or select the heading node in the Object Navigator that denotes the type of module you want to create, then select the Create tool from the toolbar. Specify the module (e.g., name it, define a SELECT statement, etc.), then save it. You can store modules in a database or in an operating system filewhichever you prefer. Where you store it determines how its security is assigned.

Storage and Security

If you store a module in a file, its security is assigned by your operating system. You can change the security as you would any other file. If you store a module in the database, its security is assigned by the database (only you can use it by default). To enable others to use it, add their names to the modules access list via File>Administration>Module Access.... To revoke access privileges, delete their names from the list. Note: Although people on the access list can use an object, they cannot grant access to other users. This ensures that only the objects creator controls the objects security.

Reportlevel Objects
Reportlevel objects are used to build reports but cannot be referenced by other modules. An example of a reportlevel object is a field, which defines how a columns data appears in the report output. Reportlevel objects are created either by you or by Oracle Reports. If you create an object, it is called a usercreated object; if Oracle Reports creates an object, it is called a default object.

34

Building Reports Manual

Reportlevel objects can belong to any one of three functional sets:


data model objects, which define the data, calculations, and parameters (i.e., variables) for the report layout objects, which define the appearance of the report parameter form objects, which define the appearance of the Runtime Parameter Form (i.e., the dialog that appears at runtime in which users can specify parameter values)

Only one reportlevel object does not fall into one of these categories: the report object, which defines the physical report.

The Report Object


The report object defines a reports unit of measurement, dimensions, and sections.

Unit of Measurement

A report can be defined using inches, centimeters, picas/points, or characters ; its unit of measurement is independent of the device on which you build it. As a result, you can design reports that will run on any platform on which Oracle Reports runs. For example, if you design reports using Motif, you can run them on Macintosh, Microsoft Windows, or Motif, and print them as ASCII or Postscript output. You can change a reports unit of measurement in these ways:

Invoke the report designer executable R25DES and specify a different unit of measurement. Invoke the report conversion executable R25CONV and specify a different unit of measurement. Open the report in a different environment. For example, if you are in a bitmapped environment and you open a report defined in characters, Oracle Reports will change the reports unit of measurement to the bitmapped environments default. If you then save the report, it will be saved with the new unit of measurement.

Dimensions

A report page can have any length and any width. Because printer pages may be smaller or larger than your reports page, the concept of physical and logical pages is used (see the next figure). A physical page is the size of a page that is output by your printer. A logical page is the size of one page of your report; one logical page may be made up of multiple physical pages.

Concepts

35

In the example above, six physical (printed) pages are output for each logical page (page of the report). Because each logical page requires 3 physical pages across and 2 physical pages down, the logical page size is 3 x 2 physical pages.

Sections

A report has three sections: the report header pages, report body/margin pages, and report trailer pages (see the next two figures).

Report Header Report Body/Margin

The report header pages optionally appear once at the beginning of each report. They can contain text, graphics, data, and computations. The body/margin pages appear between the header and trailer pages. Each page in this section consists of a body and a margin. The body comprises the bulk of the reports data and may contain text, graphics, data, and computations.

36

Building Reports Manual

Objects in the body are formatted relative to the logical page. The margin may contain anything that can be placed in the body. A margin is formatted on each physical page of the body/margin section of the report; its dimensions are the same on all of the reports pages. You can change the margin size or remove it altogether. Report Trailer The report trailer pages optionally appear once at the end of each report. They can contain text, graphics, data, and computations. The figure below illustrates the different report sections.

Concepts

37

Data Model Objects


A data model defines what data should be fetched or calculated for a report. The data may appear in the report output, be used to calculate computations, or cause Oracle Reports to perform actions (e.g., execute PL/SQL or user exits). The following objects comprise a reports data model:

queries links groups columns

See the figure below for a sample data model.

Queries

Queries are SQL SELECT statements that define which rows and columns from specified tables or views are to be fetched from the database. A query is different from an external query in that it cannot be referenced by other modules. The data fetched by a query can be used in calculations, sorts, or set operations such as UNION, as well as displayed in the report output.

38

Building Reports Manual

You can select data from these local or remote sources:


ORACLE databases databases supported through SQL*Connect, such as SQL/DS and DB2 datasources supported through ODBC, such as SQL*Server (see your Developer/2000 Installation Guide for details)

If the database is remote, specify its database link in the query (e.g., @Colorado in the example below).
SELECT E.DEPTNO, E.SUM(SAL), C.DEPTNO FROM EMP E, JONES.OTHER@COLORADO C WHERE C.DEPTNO (+) = E.DEPTNO GROUP BY E.DEPTNO, C.DEPTNO ORDER BY E.DEPTNO

Query Creation/Properties

Create a query with the Query tool in the Data Model editor, then specify its properties in its property sheet (shown below). To display an objects property sheet, doubleclick on the object.

Singlequery Reports

Reports built using one query are the simplest reports. The most popular formats for singlequery reports are tabular, mailing label, form letter, and break. In one report, you can display one querys data any number of timeseven in different formats. The figure below shows the data of one query formatted various ways.

Concepts

39

Notice that the last report (break) seems use an entirely different query. Instead, the data it displays was hidden in the other reports, and vice versa. With Oracle Reports, you can query data without including it in the report output. This is useful for establishing relationships between multiple queries, performing calculations, and so on. Multiquery Reports A report created with Oracle Reports may contain any number of queries. Multiqueries reports are useful when you want to:

3 10

Building Reports Manual

produce multipart unrelated query reports produce multipart related query reports make your queries easier to maintain (often a report with a complex query containing embedded SELECT statements and joins can also be created with multiple simple queries that are linked. The latter are often easier for others to understand and maintain.) display the same data twice in a report with different sorting criteria

If you create a report with multiple queries, you can either leave the queries unrelated, or establish a relationship between them using a data link (discussed in the next section). Multipart Unrelated Query Reports If you do not link the queries, youll produce a multipart unrelated query report (commonly called a master/master report). These types of reports display lists of unrelated data. For example, in the report below, one query selects products and another selects customers. Notice that there is no relationship between the products and customers.

When you run this type of report, Oracle Reports will fetch the data for each query independently. Multipart Related Query Reports In many reports, the data fetched for one part of the report is determined by the data fetched for another part. This is termed a master/detail, or parent/child, relationship, and is defined with a data link between two queries. When you run a master/detail report, each row of the master (or parent) query will cause the detail (or child) query to be executed, retrieving only matching rows.

Concepts

3 11

Data Links

A data link establishes the relationship between the data of two queries. In the figure below, the line between the queries represents a data link.

Data Link Creation/Properties

Create a data link with the Data Link tool in the Data Model editor then specify its properties in its property sheet (shown below).

A data link can establish these relationships:


between one querys column and another querys column between one querys group and another querys group (this is useful when you want the child query to know about its parents data)

3 12

Building Reports Manual

Although links are commonly equijoins (e.g., WHERE DEPTNO = DEPTNO), you can create links with various SQL clauses (i.e., WHERE, HAVING, or START WITH) and conditions. If your database has database constraints, you can create a data link that derives its SQL clause and condition from the constraints. When a report with a data link is executed, the data link is converted into a SQL clause and appended to the child query. The child query is executed with the values of the primary key used by the parent. For the report below, the following link was defined: Parent Group SQL Clause Parent Column(s) ORDID Condition Child Column(s) = ORDID

G_ORD WHERE

The default group of the master query (containing the columns Order ID and Customer) is the parent group; the detail query (the query to which Item, Product and Amount belong) is the child query.

Groups

Groups can do two things: separate a querys data into sets , and filter a querys data.

Concepts

3 13

Group Creation/Properties

There are two types of groups in Oracle Reports:


default (created by Oracle Reports) usercreated (created by you)

Default Groups By default, Oracle Reports generates one group for each query and assigns all of the querys columns to it. Usercreated Groups Create a group in the Data Model editor by dragging a column outside of an existing group, then specifying its properties in its property sheet (shown below). Add columns to an existing group by dragginganddropping them from another group or creating them yourself.

Create groups when you want to treat some columns differently than others. For example, you create groups to:

produce subtotals (i.e., totals at a more granular level) print the groups columns in a different direction create breaks or cross products

With the exception of crossproduct groups, all usercreated groups are called break groups. Break Groups Create break groups to produce subtotals, print columns in a different direction, create breaks, and so on. A break group suppresses duplicate values in sequential records. For example, in the report below, the department number is actually selected for each record; however, the duplicates are not printed.

3 14

Building Reports Manual

To build the above report, create a group for the DEPTNO column by dragging it above the default group. Look again at the above report, and notice that subtotals exist for each department. Because the DEPTNO column is in a break group, subtotals can be performed for each department; otherwise, only reportlevel totals would be possible. Cross Product Groups Create cross product groups to perform mathematical cross products, which are generally used to create matrix reports. For more details, see Matrix Reports on page 3 42. Group Filters Filters enable you to conditionally remove records selected by your queries. Groups can have two types of filters:

Oracle Reports packaged filters usercreated filters

Packaged Filters Oracle Reports is shipped with two packaged filters:


First, to display only the first n records for the group (e.g., the first 5 records) Last, to display only the last n records for the group

Usercreated Filters You can create filters using PL/SQL.

Concepts

3 15

Group Hierarchy

The group hierarchy of a reports data model determines the order of groups in the Default Layout dialog box, which in turn determines the order of the groups in the default report layout. Remember, this is not the final data model; you can always customize the layout Group hierarchy is determined by following groups in the Data Model editor from left to right, top to bottom. If data links are defined, they are also followed.

Columns
Column Creation/Properties

Columns represent the data of your report. There are two types of columns:

default usercreated

Default Columns By default, Oracle Reports generates one column for each item in a querys SELECT list, and assigns each column the datatype and width specified in the database data dictionary. The default columns are placed in the default group. In addition to the traditional column types (e.g., date, number, character), Oracle Reports also supports graphic columns, which are columns whose values can be:

graphics stored directly in the database Such a column is usually of datatype LONG or LONG RAW and contains a graphic. In this case, specify the graphics format in the columns property sheet. filenames The values of such a column are pointers to files stored in the operating system. In this case, specify in the columns property sheet that the its values are file contents (Read from File) and the format of the files.

Many graphics formats are supported, including BMP, CALS, CGM, GIF, JFIF, Oracle drawing, Oracle image, PCD, PCX, PICT, RAS, TIFF, etc. Usercreated Columns Create a column in the Data Model editor by selecting one of the Column tools in the Tool palette and:

click in a groups column list to create a groupowned column, or click in an open area of the editor to create a reportlevel column

Then specify its properties in its property sheet (shown in the next figure).

3 16

Building Reports Manual

There are three types of usercreated columns:


summaries formulas placeholders

Summaries A summary is a computation that is performed on all records of one column; for example, the sum of all salaries. Oracle Reports is shipped with these summaries:

Average Count First Last Maximum

Minimum % of Total Standard Deviation Sum Variance

Each summary except First and Last has a running variation (e.g., running sum, running percent) that you create by specifying how frequently the summary resets to zero via the Reset At field.

Concepts

3 17

Occasionally, you may find that a report requires a different computationfor example, one that computes sales tax. When you need a customized computation, create a formula. Formulas A formula is a computation performed on one or more columns of one record. For example, :ITEMTOT *.07 is a formula that performs a computation on one column, while :SAL + :COMM performs a computation using two columns in a record. Create formulas using PL/SQL or supported 3GLs. As a result, you can create any number or type of customized computations. If you use PL/SQL, Oracle Reports provides a PL/SQL editor in which to write the formula. If you use a 3GL, first write your program as you normally do, then link it with Oracle Reports. For details on how to write user exits and link them to Oracle Reports, see User Exit Interface in Chapter 14 of the Reports Reference Manual. Placeholders A placeholder is a column whose value and datatype are set via PL/SQL or supported 3GLs. Placeholder columns are useful when you want to selectively set the value of a column (e.g., each time the nth record is fetched, or each time a record containing a specific value is fetched , etc.). Column Hierarchy As with group hierarchy, a data models column hierarchy determines the order of columns in the Default Layout dialog box. This in turn determines the order of the columns in the default report layout.

3 18

Building Reports Manual

Column hierarchy is determined by following the columns from top to bottom inside each group. Reposition columns within a group by dragginganddropping them.

Parameters

Parameters are report variables which can assume different values at runtime. Parameters are especially useful for modifying SELECT statements and setting PL/SQL variables at runtime. Parameter values can be specified in these ways:

accepting the default parameter values (default values are set in the Parameter property sheet, and you can control whether the values are displayed at runtime on the Runtime Parameter Form) typing the parameter value(s) as arguments on the command line (where applicable) choosing from a list or entering the parameter value(s) in the Runtime Parameter Form

Parameter Creation/Properties

There are two types of parameters:


default (called system parameters) usercreated (called bind and lexical parameters)

System Parameters Oracle Reports is shipped with the following parameters. (Change their default values as described above.) System Parameter BACKGROUND COPIES CURRENCY DECIMAL DESTINATION FORMAT DESTINATION NAME DESTINATION TYPE MODE Function Is whether to fork a separate background process for the report (where supported) Is the number of report copies to be printed Is the symbol for the currency indicator: e.g., $ Is the symbol for the decimal indicator: e.g., . Is the format of the output device: e.g., the default driver for a printer Is the name of the output device: e.g., the file name, printer name, mail userid Is where to send the output: e.g., screen, file, mail, printer, screen in Postscript format Is whether to run the report as a bitmapped or charactermode report

Concepts

3 19

System Parameter ORIENTATION PRINTJOB THOUSANDS

Function Is the orientation of the printed report: e.g., landscape or portrait Is whether to display the Print Job dialog box when running a report Is the symbol for the thousands indicator: e.g., ,

Usercreated Parameters Create a parameter in the Object Navigator by selecting the User Parameters node, then selecting Navigator>Create (or the Create tool). A new node named P_1 appears. Specify its properties in its property sheet (shown below).

Note: Oracle Reports automatically creates a parameter when you have a bind parameter reference in a query. Parameter and Column References Reference usercreated parameters, system parameters, and columns in two ways:

as bind references as lexical references

Bind References Use a bind reference when you want the parameter to substitute only one value at runtime. Precede a bind reference with a colon (:).

3 20

Building Reports Manual

For example:
SELECT * FROM ORD WHERE ORDNO = :ORDPARAM

Because :ORDPARAM can only be replaced by one expression (e.g., 19945), you precede the parameter reference with a colon. Queries with bind references are parsed, or checked for errors, once. The bind references themselves are reevaluated for each execution of the query. Lexical References Use a lexical reference when you want the parameter to substitute multiple values at runtime. Precede a lexical reference with an ampersand (&). For example:
SELECT * FROM DEPT &WHERECLAUSE

Since &WHERECLAUSE can be replaced by several expressions (e.g., WHERE DEPTNO > 20 ORDER BY DEPTNO), you use a lexical parameter. Queries with lexical references are parsed, or checked for errors, each time the lexical reference changes values. Lexical references themselves are reevaluated for each execution of the query. Note: A parameter must exist and have a default value set in its property sheet before you can create a lexical reference to it. Parameter Lists of Values and Comboboxes On the parameter property sheet, you can specify that a list of values or a combobox should be displayed on the Runtime Parameter form. The list can be derived from a SELECT statement or from static values that you specify. Additionally, you can specify whether users may type a value possibly not in the list. For an example of a parameter with a list of values, see DrillDown Report with Parameter List of Values, on page 7 5. In Oracle Reports, data is defined independent of format(layout). As a result, you should be aware of when to use links instead of breaks.

Data Definition Concepts

Concepts

3 21

Links vs Breaks

The layouts of a master/detail report which uses two queries and a link and a break report which uses one query and two groups can be identical. Below is an example of a default master/detail report and a break report that query the same data. Notice the difference between the two reports: unlike the break report, the master/detail report displays department 40. This is because the data link in the master/detail report causes an outerjoin: the link automatically fetches unrelated data. If you are designing a break report that requires an outerjoin, explicitly add it to your SELECT statement via (+).

Note: For performance considerations regarding the number of queries, see Performance and Tuning in Chapter 17 of the Reports Reference Manual.

3 22

Building Reports Manual

A master/detail/detail report (see the next figure) is a report that contains three groups of data: for each master group, two unrelated detail groups are displayed. To produce a master/detail/detail report or any variation of it, you must use links. If you try to produce this report with a control break using a single query and three groups the query will establish a relationship between the two detail groups.

Layout Objects
Layout objects define a reports format; i.e., the positioning and appearance of data, text, and graphics in the report output. The following objects comprise a reports layout:

frames repeating frames fields boilerplate anchors buttons OLE2 objects

See the figure below for a sample report layout.

Concepts

3 23

Frames

A frames contains data and other report objects. It prints only as often as the object by which it is enclosed or to which it is attached. A frame is not recordrelated. Create frames when you want to:

group together objects to ensure they maintain their relative positions during printing delineate sections in your report Example: You want the top of each page to have a tabular format, but the bottom of each page to have a matrix format.

protect other objects from being overwritten Example: A summary is centered under two repeating frames. Defaulting rules state that the summary must remain at a fixed distance from only the first object that can overwrite it; therefore, the summary is in danger of being overwritten by the second repeating frame. Enclosing both repeating frames with a frame will force the summary to maintain a fixed distance from both of them, and it will not be overwritten.

3 24

Building Reports Manual

prevent an object from printing until other objects finish printing Example: A summary is centered under two repeating frames. According to defaulting rules, the summary will print as soon as the first repeating frame finishes printing. Create a frame around the two repeating frames to ensure the summary prints after both repeating frames have finished printing.

A frame looks like this:

Frame Creation/Properties

There are two types of frames:


default usercreated

Default Frames When you accept the Default Layout dialog box, Oracle Reports automatically generates frames to surround objects, such as boilerplate and summary fields, that need to remain with the same object in the layout. Usercreated Frames Create a frame in the Layout editor by clicking on the Frame tool, dragging a region, then specifying its properties in its property sheet (shown in the next figure).

Concepts

3 25

Repeating Frames

A repeating frame is a place holder for recordsit prints once for each record of a group, the data model object with which it is associated. It is a frame in that it is a data container, but its recordrelated. Use repeating frames to define recordlevel layout information. For example, you can specify the direction in which the records print (e.g., Down, Across, Across/Down, etc.) and the spacing between each record., they provide a subset of repeating frame functionality (e.g., they do not have a Maximum Records per Page property). A repeating frame looks like this:

Repeating Frame Creation/Properties

There are two types of repeating frames:


default usercreated

Default Repeating Frames When you accept the Default Layout dialog box, Oracle Reports generates one repeating frame for each group in the data model, and places one field inside it for each of the groups columns. Repeating frames can enclose any layout object, including other repeating frames. Nested repeating frames are typically used to produce master/detail and break reports. For each record of the outer repeating frame, Oracle Reports will format all related records of the enclosed repeating frame. Usercreated Repeating Frames Create a repeating frame in the Layout editor by clicking on the Repeating Frame tool, dragging a region, then specifying its properties in its property sheet.

3 26

Building Reports Manual

Repeating Frame Format Triggers

Repeating frames have format triggers, with which you can conditionally set formatting attributes (i.e., fonts, colors, etc.) via PL/SQL. For example, you can specify that if a record value is less than 0, the record will have a red border. To set formatting attributes using PL/SQL, use a PL/SQL builtin procedure called SRW.SET_ATTR. For details, see Format Trigger in Chapter 13 of the Reports Reference Manual.

Repeating Frame Sizing

For each record, a repeating frames size can be expandable, contractible, variable, or fixed horizontally or vertically. For example, you can specify that a repeating frame should be fixed in size horizontally, but expand vertically if a record requires more space. An example is shown in the figure below. Notice that there are four records for department 20, but only one record each for departments 10 and 30. The repeating frame has expanded vertically to accommodate department 20s additional records

Concepts

3 27

Repeating frames that contract horizontally or vertically reduce in size when a record requires less space than the repeating frames initial size. A repeating frame may also be variable in size: it expands or contracts based on the size of the value it displays. Also, if a repeating frame is fixed in size and a records data requires a larger field than the it can contain, the remaining data will be pushed onto the following page(s) in the same x and ycoordinates.

Fields

Fields are place holders for parameters, columns, and such values as the page number, current date, etc.. If a parameter or column does not have an associated field, its values will not appear in the report output. You can assign the following properties to a field:

alignmentwhether the data should be centered, or left, right, flush left, flush right, or centeraligned format maskhow the data should be displayed if it is a number ($N.00, DM N.000.000,00), a date (March 10, 1991, 10 Jan. 1990), or a character (e.g., ALL CAPS, lowercase) displayhow the data appears (foreground and background color and pattern; font type, size, and style; line spacing)

A field looks like this:

Field Creation/Properties

There are two types of fields:


default usercreated

3 28

Building Reports Manual

Default Fields When you accept the Default Layout dialog box, Oracle Reports automatically generates one field for each column, and places each field inside of a repeating frame. Usercreated Fields Create a field in the Layout editor by clicking on the Field tool, dragging a region, then specifying its properties in its property sheet.

Boilerplate

Boilerplate, or constant text, is text, lines, or graphics not fetched by a query, yet appearing in the report output. Use boilerplate to customize your report, such as creating heading pages, adding graphics, etc. Boilerplate can look like this:

Boilerplate Creation/Properties

There are two types of boilerplate:


default usercreated

Default Boilerplate When you accept the Default Layout dialog box, Oracle Reports automatically generates one column label for each field. For example, if a column is named ENAME, a boilerplate object containing Ename is generated for the column. For some report types, Oracle Reports also generates lines under the labels.

Concepts

3 29

Usercreated Boilerplate Create a boilerplate object in the Layout editor by clicking on one of the boilerplate tools, dragging a region, and specifying its properties in its property sheet. Boilerplate Tools:

Arc tool Polygon tool Ellipse tool Polyline tool Freehand tool

Rectangle tool Line tool Rounded Rectangle tool Link File tool Text tool

Boilerplate from Files

If you have a text or graphic file that you would like to display as boilerplate in your report, you can:

import the contents of the file using the Import dialog box When you import a file, a boilerplate object is created and the contents of the file are placed in the boilerplate object. The boilerplate objects contents are static. They remain the same even if you later change the contents of the file. link to the file Linking to a file means that the contents of the file are pulled into the boilerplate object each time the report is run. In this way, you can ensure that your output includes the most recent changes to the file.

3 30

Building Reports Manual

Anchors

Anchors determine the relative positioning of objects in the report output by attaching one layout object, called the child, to a second, called the parent. They also define the vertical and horizontal displacement of the child relative to its parent. The child object may be either outside of or contained within the parent. Anchors look like this:

Anchor Creation/Properties

There are two types of anchors in Oracle Reports:


implicit (anchors that Oracle Reports creates when a report is run) explicit (anchors you create)

Implicit Anchors At runtime, Oracle Reports generates an implicit anchor for each layout object that does not already have an explicit anchor. It determines for each layout object which objects, if any, can overwrite it, then creates an anchor from the layout object to the closest object that can overwrite it. This prevents the object from being overwritten. The implicit anchor functionality saves you from having to define the positioning of each object. Implicit anchors are not visible in the Layout editor. However, you can specify that the Object Navigator display anchoring information using the Object Navigator Options dialog. Explicit Anchors Create an anchor in the Layout editor by clicking on the Anchor tool, dragging from one edge of the child to the one of the parents edges, then specifying the anchors properties in its property sheet. Any anchor you create for an object will override its implicit anchoring. Explicit anchors are always visible in the Layout editor unless you specify otherwise via the Layout Options dialog.

Concepts

3 31

Relative Positioning of Anchors

When you anchor a child object to a parent object, the x and ycoordinates of the anchors attachments are important. If the parent object is located above or below the child object:

The vertical distance between the two objects is fixed. For example, in the next figure the vertical spacing between the parent and Object 1 is fixed. The horizontal positioning of the anchors xcoordinate on the child object is relative to the anchors xcoordinate on the parent object. For example, in the next figure the anchor is 50% from the edge of the parent and 75% from the left edge of Object 1. Therefore, when this report is run, Oracle Reports will shift Object 1 25% to the left of the center of the parent.

3 32

Building Reports Manual

If the parent object is located to the right or left of the child object:

The vertical positioning of the two objects is relative. For example, in the figure below both ends of the anchor are about 80% down from the top edges of the objects. Therefore, when the report is run, Oracle Reports will calculate the length of the two objects (as they may expand), calculate the y coordinate that is 80% down for both objects, and position the two objects so that those two points are separated by the amount of space separating them in the Layout editor. The horizontal positioning between the two objects is fixed. For example, in the figure below, the horizontal spacing between the parent and Object 1 is fixed.

If you need to position an object outside a repeating frame or frame but you want the object to be owned by the repeating frame or frame (i.e., to be formatted when its owner is), create an anchor that is attached to an object inside the frame or repeating frame. Collapsing Anchors You can create anchors to be collapsible. Collapsing anchors help avoid unnecessary empty space in your report. Such empty space can occur when the parent object does not print on the same page as the child object, either because the parent and child can not fit on the same page or because of an assigned Print Condition. A collapsing anchor allows the child object to move into the position which would have been taken by the parent had it printed. The child object will also maintain its relative position as defined by the anchor. For more information on anchors, see Anchor Properties in Chapter 8 of the Reports Reference Manual.

Concepts

3 33

Buttons

Buttons are layout objects on which users can click on the Previewer to do the following:

display videos, sounds, or images that are fetched by a query display videos, sounds, or images that are stored in files execute PL/SQL to perform some action (such as launch a detail report for the current record in the Previewer)

Buttons look like this in the layout:

Unlike OLE2 objects, buttons are portable. Button Creation/Properties There are two types of buttons:

default usercreated

Default Buttons When you accept the Default Layout dialog box, Oracle Reports automatically generates buttons for video and sounds in the database. Usercreated Buttons Create a button in the Layout editor by clicking on the Button tool, dragging a region, then specifying its properties in its property sheet (shown below).

3 34

Building Reports Manual

OLE2 Objects

OLE2 objects are Oracle Reports layout objects that display objects (e.g., spreadsheets, or drawings) from OLE2aware applications. The OLE2 objects can be static or dynamic (i.e., displayed based on report values). Such objects are available only on platform supporting OLE2. There are two types of OLE2 objects:

OLE2 Object Creation/Properties

default usercreated

Default OLE2 Objects When you accept the Default Layout dialog box, Oracle Reports automatically generates a field to contain the OLE2 object. This field is a normal fieldits only difference lies in the datatype of the column whose values it will display in the report output. In addition, the property sheet for a default OLE2 object is simply a normal field property sheet, and you can use it to specify all settings you can normally specify for a field. Usercreated OLE2 Objects Create an OLE2 object in the Layout editor by clicking on the OLE2 Object tool, dragging a region, selecting the type of object to create, and creating the OLE2 object as you normally would. The property sheet for an OLE2 boilerplate object is a normal boilerplate property sheet, and you can use it to specify all settings you can normally specify for a piece of boilerplate. The appearance of a usercreated OLE2 boilerplate object in the Layout editor is dependent upon the type of object it is (i.e., whether its a document, spreadsheet, graphic, video, etc.). For more information about OLE2 objects, see OLE2 in Chapter 16 of the Reports Reference Manual.

Layout Concepts

Several important concepts and properties apply to layout objects:


print condition column mode keep with anchoring object page protect format triggers layout definition concepts

Print Condition

The Print Condition property defines when an object is triggered to print, relative to when its owner (parent object) prints. Ownership is determined either by explicit or implicit anchors, or by enclosing an object. Print Condition only triggers the object to print, it does not

Concepts

3 35

guarantee the object will print. Other factors (e.g., a format trigger) may cause the object not to print. Define a print condition for the objectnot the objects parent. You can assign the following print conditions to the object: All triggers the object to print on all logical pages on which the parent prints (e.g., column labels that print on all pages because they are anchored to the page) triggers the object to print on all but the first logical page on which the parent prints (e.g., page numbers that begin on page two because they are anchored to the page) triggers the object to print on all but the last logical page on which the parent prints (e.g., an endofpage summary that is replaced on the last report page by an endofreport summary) triggers the object to print on only the first logical page on which the parent prints (e.g., column labels that only appear once) triggers the object to print on only the last logical page on which the parent prints (e.g., summaries or group footers) has Oracle Reports evaluate the objects position to determine which of the above is most relevant

All But First

All But Last

First

Last

Default Column Mode

The Column Mode property causes the space that a repeating frame occupies to be maintained even when the repeating frame runs out of instances. This prevents any objects to the right of it from moving. For example, assume there are two pages of instances for the A and C repeating frames, but only onehalf page of instances for the B repeating frame, as shown in the figure below. If you do not specify Column Mode for repeating frame B, the instances of repeating frame C will appear on page two where B would have appeared. If Column Mode is selected, however, C will continue to appear in its same x and ycoordinates.

3 36

Building Reports Manual

Keep with Anchoring Object

The Keep with Anchoring Object property causes the parent object to move to the next page if its child object cannot appear with it on the same page. Keep with Anchoring Object uses any existing explicit anchor to determine the parent. If there is no explicit anchor, an implicit anchor is used. Relying on the implicit anchor can be risky, unless you fully understand the implicit anchoring algorithm described in the Reports Reference Manual. Keep with Anchoring Object for a repeating frame means that Oracle Reports should keep the enclosed objects with the repeating frame for one record. Keep with Anchoring Object for a frame means that Oracle Reports should protect all objects within the frame, including all records of any repeating frame enclosed within the frame. Look at the next figure. The report on the left was created without Keep with Anchoring Object specified, resulting in an employee list separated from its department number. The report on the right uses Keep with Anchoring Object to ensure that the name and information always appear on the same page. If the two objects require more than one page together, the objects are moved to the next page only once.

Concepts

3 37

Page Protect

The Page Protect property causes all objects within a repeating frame or frame to remain together on the same logical page, when possible. If it is impossible to keep them on the same page, Oracle Reports will let them span multiple pages. Page Protect for a repeating frame means that Oracle Reports should protect one record of the repeating frame. For a frame, it means Oracle Reports should protect all enclosed objects, including all records of any repeating frame enclosed within the frame. Assume you are designing a break report made up of department numbers and employees, as shown below. Without Page Protect set on for a repeating frame, a departments employee names could split between pages. Specifying Page Protect for the repeating frame that encloses the Deptno field ensures that the department number and all of its related records will always appear on the same page.

3 38

Building Reports Manual

Format Triggers

A format trigger contains PL/SQL executed when the object is formatted. One important use of format triggers is to govern conditional printingi.e., to change the appearance of one or more objects based upon set criteria. For example, you can use a format trigger to cause a value to display in bold if it is less than zero. Another example is to use a format trigger touse scientific notation for a field if its value is greater than 1,000,000. Oracle Reports is shipped with a PL/SQL package that contains procedures with which you can quickly change the format attributes of an object. These include procedures to:

change the border pattern and color of an object change the interior pattern and color of an object change the font size, style, weight, spacing, and justification of a field or boilerplate text change the format mask of a field change the charactermode attributes of an object, including highlighting access a fields value

Concepts

3 39

For examples of conditional printing, turn to Conditional Form Letter Report, on page 6 66, and Conditional Highlighting Report, on page 6 71. Layout Definition Concepts There are a few layout definition concepts concerning defaulting and editing your layout of which you should be aware. You can build a layout for your report in one of the following ways:

use a default layout use a default layout and then customize it create your own layout form letter master/detail matrix

There are six default layout styles shipped with Oracle Reports:

tabular mailing label form (across report)

For a description of these layout styles, see Layout Defaulting in Chapter 2 of the Reports Reference Manual. To create a default layout, do the following: 1. 2. Select Tools>Default Layout... to display the Default Layout dialog box. Select a layout style and fill out the rest of the dialog box.

When you select one of the default layout styles Oracle Reports creates the necessary layout objects, based upon the reports data model. For example, if you want to build a mailing label report and have defined an appropriate data model, simply choose the mailing label default style. Oracle Reports automatically creates the reports layout objects and places them in the Layout painter. You can completely customize any default layout you create. You can cut, copy, paste, move, resize, and edit each layout object that Oracle Reports generates for you. If you prefer to build your own layout, you can go directly to the Layout editor without choosing a default format and create all of the objects. Note: There are three important things to know about defaulting:

All previouslydefined layout objects for the report will be overwritten (including format triggers) unless you define the area in which you wish to create the layout as one which does not already contain layout objects.

3 40

Building Reports Manual

One report can have any number of different formats. For example, you can build a report that has a tabular format on the top of the first page, and a matrix format on the bottom of the same page. For details on how to produce a multistyle report, see Adding a New Layout to an Existing Layout on page 2 58. Once you have created a report layout any further changes you make to the data model will not automatically be included in the layout. For example, if you create a query after you have created a report layout and then run your report, the data from the new query will not appear in the report output. To incorporate your changes, you need to either redefault or modify the layout.

Parameter Form Objects


When you execute a report, Oracle Reports provides a window to optionally appear at runtime in which you can override default parameter values (e.g., values that modify SELECT statements, route the report output to a specified device, etc.). This window is called the Runtime Parameter Form. You build it using two reportlevel objects: fields and boilerplate. Look at the figure below for an example of the Runtime Parameter Form and its objects.

Fields

The parameter form field object is a place holder for parameters. Use a field to assign display attributes (e.g., bold) to the default parameter values that appear on the Runtime Parameter Form. By default, one field is created for each parameter. Boilerplate in the Parameter Form painter is the same as boilerplate in the Layout paintertext or graphics that either you create or Oracle Reports generates by default. Boilerplate enables you to customize the Runtime Parameter Form. By default, a boilerplate label is produced for each field that appears on the Runtime Parameter Form.

Boilerplate

Concepts

3 41

Building a Parameter Form

You can build a parameter form layout in much the same fashion as you build a report layout. One default parameter form style is shipped with Oracle Reports. You can use this default style as is or as a basis for your own Parameter Form, or create your own. To build a default parameter form, select Tools>Default Parameter Form.... Oracle Reports will create the necessary parameter form objects based upon the parameters that are defined in the data model. To build a complete, customized Runtime Parameter form, use the Parameter Form editor. If you dont create a parameter form, Oracle Reports will create one at runtime. However, the default parameter form objects are deleted when the report has finished running.

Matrix Reports
A matrix report is a crosstabulation of four sets of data:

One set of data is displayed across the page. One set of data is displayed down the page. One set of data is the crossproduct, which determines all possible locations where the across and down data relate and places a cell in those locations. One set of data is displayed as the filler of the cells.

With Oracle Reportsyou can create many different matrix reports. The four general types of matrix reports covered in this manual are simple matrix, nested matrix, multiquery matrix with break, and matrix break, but you are not confined to these designs. Before discussing the particulars of matrix building, well cover the following general issues:

matrix data model matrix layout

Matrix Data Model

In building your matrix data model, you should consider the following:

number of queries group structure summary settings

3 42

Building Reports Manual

Number of Queries

Although matrix report always require at least four groups, they can be built with any number of queries. If you build a matrix report with only one query (usually the most efficient structure), you must create at least three groups manually in addition to the one created by default. If you build a matrix report with multiple (three or more) queries, which SQL*ReportWriter Version 1.1 users are accustomed to doing, you still need to create at least one group. The figure below illustrates the two types of query structures that you can use for your matrix data model.

OneQuery Matrix One advantage to a onequery data model is that the resulting report is generally more efficient than a report based on a multiquery data model. For more information on performance issues, see Performance and Tuning in Chapter 17 of the Reports Reference Manual. Multiquery Matrix You may consider using a multiquery data model, as it often has simple queries and can be easier to maintain than the equivalent onequery data model. In addition, a multiquery data model is required for some types of matrices (e.g., some nested matrix reports). For more information on nested matrix reports, see Nested Matrix Reports on page 3 50.

Concepts

3 43

Group Structure

Matrix reports are built with four or more groups:

Two or more dimension groups. Dimension groups are contained within the cross product group. In the layout, the information in at least one group goes across the page, and the information in at least one group goes down the page, forming a grid. The information in these groups is sometimes referred to as matrix labels, as they appear to provide column and row labels for the matrix. One or more cross product groups. The cross product group represents all possible combinations of the values of the dimension groups. In the layout, the cross product group is represented by the intersection of the repeating frames for the across and down dimension groups. When the report is run, it expands, and each instance of data intersection becomes a separate cell. This concept is sometimes best understood graphically, as in the figure below. The rectangles are cells, and show where each department/job combination is valid.

One cell, or filler group. The cell group contains the actual information that is represented by the cells of the cross product. For each intersection of the values of the dimension groups (cell), the cell group contains zero, one, or multiple values. When the report is run, these values appear in the appropriate cells.

The next figure shows graphical representations of how groups are related for both single and multiquery data models.

3 44

Building Reports Manual

Notice that for each data model the cross product group is represented by the large rectangle, while the dimension groups are the smaller rectangles enclosed by it, and the cell group is shown outside of the cross product group. Summaries and Product Order Creating a summary for a matrix requires more information than creating a summary for other kinds of reports. When you create summary columns for your matrix, you need to indicate the following:

The frequency of the summary. The frequency specifies the dimension groups for which to compute the summary. The order in which to compute the summary. The order specifies how to traverse the matrix in calculating the summary (top to bottom or left to right).

In Oracle Reports, you specify this information using the Product Order setting for your summary. All summaries that are owned by the cross product group require that a Product Order be specified. Suppose that you have a matrix report that looks something like the one below.

Concepts

3 45

This is a nested matrix report. (For more information about nested matrix reports, see Nested Matrix Reports on page 3 50.) Assume that group G_YEAR contains the YEAR column, G_DEPT contains the DEPTNO column, G_JOB contains the JOB column, and G_CROSS is the cross product group. To create the summary of salaries by job which appears at the bottom of the matrix for each job, you create a summary column in G_CROSS with the following settings: Product Order G_JOB Reset At G_JOB

These settings tell Oracle Reports that the summary should be calculated for each job in the G_JOB group and the summary should be reset to zero for each job in the G_JOB group.

3 46

Building Reports Manual

To create the summary of salaries by year which appears at the right of the matrix directly underneath the boilerplate lines, you create a summary column in G_CROSS with the following settings: Product Order G_YEAR Reset At G_YEAR

These settings tell Oracle Reports that the summary should be calculated for each year in the G_YEAR group and the summary should be reset to zero for each year in the G_YEAR group. To create the summary of salaries by year and department which appears at the right of the matrix for each department row of the matrix that contains a value, you create a summary column in G_CROSS with the following settings: Product Order G_YEAR, G_DEPT Reset At G_DEPT

These settings tell Oracle Reports that the summary should be calculated for each record of G_DEPT within each record of G_YEAR. G_DEPT comes after G_YEAR in the Product Order because, in this report, it changes more frequently than G_YEAR. If G_YEAR changed more frequently (i.e., years were listed for each department), it would make more sense to have a Product Order of G_DEPT, G_YEAR. This summary is reset to zero for each record in the G_DEPT group. When you have multiple groups listed in Product Order and you want a nonrunning summary, the reset group should be the same as the last group in Product Order. When you have multiple groups listed in the Product Order and you want a running summary, the reset group should be a group other than the last one in the Product Order.

Matrix Layout

The figure below shows the objects which make up a simple, twodimensional matrix. These are the minimum necessary for a matrix report (although the field labels may optionally be suppressed).

Concepts

3 47

A matrix layout model must consist of the following layout objects:

at least two repeating frames, one with a Print Direction of Down and one with a Print Direction of Across (e.g., R_DEPT and R_JOB in the figure above) several group, header, and footer (if summaries are included) frames a matrix object created for the cross product group, inside of which are the cells of the matrix (e.g., the rectangle in the figure above with R_SUMSAL and F_SUMSAL inside it) boilerplate for each column and row of values, as well as for summaries (e.g., Job and Deptno). Note: Displaying the boilerplate is optional, but Oracle Reports will generate it by default.

For more information about the default layout objects created for a matrix report, see Layout Defaulting in Chapter of the Reports Reference Manual. Matrix Object The matrix object defines the intersection of at least two repeating frames. The repeating frames are the dimensions of the matrix and the matrix object contains the field that will hold the filler or values of the cell group. You need one matrix object for each pair of intersecting repeating frames in the layout. One of the repeating frames must have a Print Direction of Down and the other must have a Print Direction of Across in order to form a matrix. A simple matrix report is a matrix with only two dimensions, like the matrix shown in the next figure.

Simple Matrix Report

This section describes the following for a simple matrix report:


data model layout

For steps on how to produce a simple matrix report, see Matrix Report on page 5 81.

3 48

Building Reports Manual

Data Model

The figure below illustrates the onequery data model for a simple matrix report.

This data model has one query and four groups. The two groups inside the cross product group are the dimensions of the matrix and the group outside the cross product contains the values for the cells. You can also create an equivalent report with three queries. Layout The figure below illustrates the layout for a simple matrix report:

This layout contains only three repeating frames. One repeating frame prints across, one prints down, and one is inside of the matrix object (the intersection of the across and down repeating frames).

Concepts

3 49

Nested Matrix Reports

A nested matrix report has more than two dimensions; therefore, it has multiple dimensions going across and/or down the page. For example, look at the report below. Notice that for each year there is a nested list of related departments. Also notice that the list of jobs (the across values) appears only once. Because the job values appear only once, a summary of each category of jobs can be made to line up with the values it summarizes.

This section describes the following for a nested matrix report:


data model layout

For steps on how to produce a nested matrix report, see Nested Matrix Report on page 6 89. Data Model You can create the data model for a nested matrix report with one query or multiple queries. You should have at least three groups owned by the cross product group. The figure below illustrates the onequery data model for a nested matrix report.

3 50

Building Reports Manual

The dimension groups inside the cross product group do not have any master/detail relationships with each other. Since none of the groups depend on each other, all of the nested records appear for each record inside which they are nested, regardless of whether they actually contain data. Notice how all three department numbers in the sample above appear for each year, regardless of whether a department has any data for that year. Layout The layout for a nested matrix report is the same, regardless of whether you use one or multiple queries in your data model, and is shown in the figure below.

Concepts

3 51

MultiQuery Matrix with Break

A multiquery matrix with break is similar to a nested matrix report in that it has more than two dimensions. For example, the multiquery matrix with break below shows the same data as the sample nested matrix report. Notice that, once again, for each year there is a nested list of related departments.

The advantage of using multiple queries is that you get a real break, or master/detail relationship, for the nesting groups (e.g., notice that in the multiquery example above, Year 80 shows only record 20, but in the singlequery example (Nested Matrix Reports on page 3 50)., Year 80 shows all records whether or not they contain data for Year 80). If you want to suppress detail records that do not contain data for a particular master record, you must use multiple queries. This section describes the following for a multiquery matrix with break:

data model layout

For steps on how to produce a crossproduct master/detail matrix, see Related Concepts: MultiQuery Matrix with Break on page 6 94.

3 52

Building Reports Manual

Data Model

For a multiquery matrix with break, you should once again have at least three groups owned by the cross product group. The figure below shows the data model for a multiquery matrix with break.

Notice the master/detail relationship between two of the dimension groups (G_Year and G_Dept). Since one of the groups depends on the other, only its related detail records will appear for each master record. For example, look at the sample multiquery matrix with break. Notice how it differs from the output for the nested matrix report. For each year, only those departments that contain some data are displayed. Layout The layout for a multiquery matrix with break is shown in the figure below.

Concepts

3 53

Matrix Break Reports

A matrix break report contains a new matrix for each master record. For example, for each year (master) in the report below there is a unique matrix that contains only that years departments and jobs. This means that a summary of each job category may not line up with the values it summarizes because the position of each job category in the matrix may vary for each year.

This section describes the following for a matrix break report:


data model layout

For steps on how to produce a matrix break report, see Matrix Break Report on page 6 97.

3 54

Building Reports Manual

Data Model

When creating a matrix break report, define a data model in which the cross product group has a parent group. The figure below illustrates the data model for a matrix break report.

Layout

The figure below illustrates the layout for a matrix break report.

The repeating frame containing the F_YEAR field surrounds the repeating frames and matrix object that make up the matrix. This outer repeating frame is what causes a separate matrix to be displayed for each year.

Concepts

3 55

Using PL/SQL with Your Reports


Oracle Reports enables you to use PL/SQL, an application development language for use with databases, to extend your reportwriting capabilities. If you need to use conditional logic in your reports, you can include a PL/SQL construct to do the job. For example, you can modify the output if a certain value returned is not as expected, or you can substitute a different parameter value depending on what data you want fetched at the time. There are two different levels of PL/SQL you can use in your report:

external PL/SQL, as in a separate PL/SQL library or package stored outside your report, to which you make calls when necessary reportlevel PL/SQL, as in format triggers, or PL/SQL formulas for computational columns

External PL/SQL

External PL/SQL consists of named functions and procedures stored in libraries or packages outside of your report. External PL/SQL libraries are modules; i.e., they can be referenced any number of times by one or more reports and by other Oracle products. External PL/SQL libraries are sets of named functions or procedures. Unlike PL/SQL packages, the functions and procedures included in a library do not need to be logically related. However, packages can be considered libraries. To create a library, do the following: 1. In the Object Navigator, select the Libraries node, then select Navigator>Create (or the Create tool). A node for a new library appears under the Libraries heading node. Expand the node for the new library to show two subnodes: Program Units and Attached Libraries. Select the Program Units node, then select Navigator>Create (or the Create tool). In the New Program Unit dialog box, enter the name of your PL/SQL procedure, function, or package. Accept the dialog box. In the Program Unit editor, type your PL/SQL procedure, function, or package. Compile your code and close the Program Unit editor. Select File>Save or File>Save As... to name your library and save it either to the database or to a file. An external PL/SQL library is not created until you save it.

External PL/SQL Libraries

2.

3. 4. 5.

3 56

Building Reports Manual

The library, and all the PL/SQL functions and procedures it contains, are now available to be referenced by any of your report, as well as by several other Oracle products. However, before you can do so, you must attach the library to your report. 1. 2. In the Object Navigator, select the Attached Libraries node, then select Navigator>Create (or the Create tool). In the Attach Library dialog box, type the name of the external PL/SQL library in the Library field, or select Find.... Select the external PL/SQL library you want to reference, then select OK in the File dialog box to redisplay the Attach Library dialog box. Select Attach to attach the library. Finally, select OK to accept the Attach Library dialog.

For more information on external PL/SQL libraries, see your online help. PL/SQL Packages An external PL/SQL package is a group of logically related PL/SQL types, objects, and functions or procedures. It generally consists of two parts: the package spec, including data declarations, and the package body. Packages are especially useful because they allow you to create global variables. UserCreated Packages To create a package, begin as you would when creating a new external PL/SQL library. When the Program Unit editor appears, enter your package specifications. Save the package as an entry in the library. For more information on usercreated PL/SQL packages, see Packages in Chapter 13 of the Reports Reference Manual. The Oracle Reports PL/SQL Package Oracle Reports is shipped with a package that contains several functions, procedures, and exceptions you can reference from your reports. The PL/SQL provided by Oracle Reports enables you to perform such actions as change the formatting of fields, run reports from within other reports, create customized messages to display in the event of report error, and execute SQL statements, among several other options. You can reference the contents of the Oracle Reports package from any of your libraries or reports without having to attach it. However, you cannot reference its contents from within another product. For more information on the Oracle Reports package, including a complete list of included functions, procedures, and exceptions and details regarding their usage, see The Oracle Reports PL/SQL Package: SRW in Chapter 13 of the Reports Reference Manual.

Concepts

3 57

ReportLevel PL/SQL

Reportlevel PL/SQL (also called local PL/SQL) consists of functions or procedures that you can reference from groups, columns, frames, repeating frames, fields, boilerplate, parameters and report triggers. Each of the objects described below can be created using either the appropriate property sheet, or as a named function or procedure (using the PL/SQL editor accessed via Report>PL/SQL...) referenced from the appropriate property sheet. Group Filters Group filters enable you to restrict the data included in a group. Oracle Reports provides two group filters, First and Last, and enables you to write your own. You create a group filter in the group property sheet. Note: The data is restricted after it is fetched and before it is displayed. Group filters do not reduce the amount of data fetched by your query. For more information on group filters, see Group Properties in Chapter 6 of the Reports Reference Manual. Column Formulas Column formulas enable you to perform customized computations. You specify a column formula using the Program Unit editor as invoked from the property sheet of a formula column. For more information on formula columns, see Column Properties in Chapter 6 of the Reports Reference Manual. Column Placeholders Column placeholders enable you to set the values of placeholder columns from column formulas or user exits. You can also set the value of a placeholder column using the Program Unit editor as invoked from a placeholder column. For more information on placeholder columns, see Column Properties in Chapter 6 of the Reports Reference Manual. Frame, Repeating Frame, Field, and Boilerplate Triggers Formatting triggers enable you to conditionally modify or suppress the appearance of data contained within these layout objects. To create a format trigger, enter your PL/SQL code in the Program Unit editor as invoked from the objects property sheet. For more information on formatting triggers, see Format Triggers in Chapter 13 of the Reports Reference Manual. Validation Triggers Validation triggers enable you to test parameter values entered in the Runtime Parameter Form. If the values are not correct, Oracle Reports will stop processing. To create a validation trigger, enter your PL/SQL code in the Program Unit editor as invoked from the parameters property sheet. For more information on validation triggers, see Validation Triggers in Chapter 13 of the Reports Reference Manual.

3 58

Building Reports Manual

Report Triggers Report triggers enable you to check the status of an object or change the logic of the report. To create a report trigger, enter your PL/SQL code in the Program Unit editor as invoked from the report triggers property sheet. Oracle Reports provides five different report triggers, each firing (or executing) automatically at a different point in your report. For more information on report triggers, see Report Triggers in Chapter 13 of the Reports Reference Manual. To make tracking your reports PL/SQL easier, expand the Program Units node in the Object Navigator.. Under this node is a list all of PL/SQL that is local to the report (i.e., may be referenced by objects within the report only) and help you track what you have written. To see PL/SQL libraries, expand the Libraries node. To see available packages, expand the Builtin Packages node.

The Editors
An editor is a work area in which you can create, modify, and delete objects by manipulating their graphical representations and entering or changing values for settings in their property sheets. Oracle Reports has three editors:

Data Model editor Layout editor Parameter Form editor

When you first invoke Oracle Reports, the default is for only the Object Navigator to display. To access the editors, doubleclick on the icons in their respective nodes, or select them from the Tools menu.

The Data Model Editor Use the Data Model editor to create or modify your reports data
model. You can select data, define data relationships, and perform computations on database values. Oracle Reports uses the data model you create to retrieve and relate data from the database. The Data Model editor looks like this:

Concepts

3 59

The Layout Editor

Use the Layout editor to create or modify your reports format by adding or modifying layout objects. Oracle Reports uses the layout objects and their positioning in the editor to generate the layout of the report output and adds the data when the report is executed. The Layout editor looks like this:.

3 60

Building Reports Manual

Parameter Form Editor

Use the Parameter Form editor to define the appearance of the Runtime Parameter Form by adding, modifying, repositioning, etc., parameter form objects. For each parameter, Oracle Reports generates one boilerplate object (for a label) and one field (to display the parameter value). If no parameter form objects exist in the Parameter Form editor, Oracle Reports will generate a Runtime Parameter Form at runtime (you will not see any objects appear in the Parameter Form editor). Just as with the Layout editor, you can create a default parameter form, and modify the objects afterward, or create your own objects. Note: The Parameter Form editor and, therefore, the Runtime Parameter Form, may have multiple pages. The Parameter Form editor looks like this:

Concepts

3 61

The Previewer
Use the Previewer to view your report output in a window. You can design a report to:

display the Previewer automatically, without first displaying the Runtime Parameter Form display the Runtime Parameter Form with the DESTINATION TYPE field, so users can specify where to send the output (i.e., to the Previewer, a file, a printer, etc.) prevent the Previewer from appearing, by specifying a DESTINATION TYPE other than Screen or Preview.

While in the Previewer window, you can show two parts of one page at once (by splitting the window), page through the report, and print all or parts of the report.

You can scroll through pages, page through the report, navigate to the first or last page, or go immediately to a particular page.

3 62

Building Reports Manual

If you want to compare different parts of the report (e.g., if you want to contrast the data on one page with data on the next page), Oracle Reports supports splitting the screen: i.e., dividing the screen into two regions, either vertically or horizontally, and scrolling or paging through the report in each section independently of the other. Look at the figure below for an example of a Previewer that is split into two regions vertically.

You can also open new Previewers (via the New button) to get a fuller view of the same report. For details on navigation in the Previewer, see Navigation in Chapter 11 of the Reports Reference Manual.

Executables
Oracle Reports consists of the following executables:

R25CONV R25MREP R25RUN R25DES

Concepts

3 63

Note: The SQL*ReportWriter Version 1.1 program which was used to define terminal definitions, TERMDEF, is not part of Oracle Reports Version 2.5.

R25CONV

Use the R25CONV executable to convert one or more report definitions from one storage format to another. This executable replaces the SQL*ReportWriter Version 1.1 executables DUMPREP, GENREP, and LOADREP.

R25MREP

Use R25MREP to upgrade SQL*ReportWriter Version 1.1 report definitions and printer definition files to Oracle Reports Version 2.5 report definitions and printer definition files.
Note: For details on how to create your own printer definition files, see Creating or Modifying Printer Definitions in Appendix B of the Reports Reference Manual.

R25RUN

Use the R25RUN executable to run reports after you have defined them in the Oracle Reports designer. You can send your reports to the Previewer (i.e., the screen), a printer, a file, a standard output (SYSOUT), or attach the report to an Oracle*Mail electronic mail note. Use the R25DES executable to invoke the designer to design and run reports. You do so using the fillintheform interface and editors described in this chapter, and a comprehensive online help system. The designer stores report definitions in either a set of tables in an ORACLE database, or in an operating system file, whichever you prefer. Only one set of tables is needed in each ORACLE database to store the definitions for one or more users.

R25DES

3 64

Building Reports Manual

PART

III

Building Reports

CHAPTER

Visual Index
his chapter contains a sample output page for each report explained in this book. Below the sample output is a brief description pointing to features that make the output unique. Also included are pointers to the location of the reports explanation and to steps for building the report. Also included is a brief explanation of how to open the .rdf file shipped with Oracle Reports for each report so that you can open and examine finished versions of the reports explained in this book.

Visual Index

41

How to Access Demo Reports

The reports you will build in Chapters 5, 6, and 7 are also shipped with Oracle Reports. If you would like to open these reports, do the following: 1. 2. While in the demo directory, invoke Oracle Reports. When the Object Navigator appears select File>Connect and enter in the Connect dialog box, your userid, password, and any SQL*Net protocol necessary; e.g., scott/tiger@t:reports:R. Accept the dialog box. Select File>Open. Use the file dialog that appears to select demo\bitmap\repname.rdf, where repname.rdf is the report you want to open. Accept the dialog box. All report names can be found in the Concepts section of the corresponding report. All reports can be found in the bitmap directory. Other necessary files are in the reqfiles directory.

3.

A Note on Platform Specifics

During the course of building the introductory reports, you may be asked to create an object or objects of a certain specified dimension. These dimensions are merely guides. Due to the fact that font sizes, sizing algorithms, etc., differ from platform to platform, your object or objects may not appear exactly as is shown in this manual. Feel free to modify the sizes of the objects or choose a different font, as necessary. However, try to preserve the relative proportions of the objects shown. In addition, you may be asked to select certain fonts, text attributes, etc.for example, you may be instructed to create a report title using a typeface of Helvetica, a font size of 12, and a weight and style of bold italic. The method used to select fonts is dependent upon your platform, and some or all of the fonts and text attributes may not be available. Choose the font and text attributes youd like. If you have a color monitor, play with the colors. Have fun. Finally, since Oracle Reports conforms to the native look and feel of the platform on which it is running, slight differences in the names of options may occurfor example, to exit Oracle Reports, you may choose Quit or Exit, depending on your platform. These variations are slight, and you should have no problem determining what is appropriate for your platform.

42

Building Reports Manual

Tabular Report

A tabular report is the most basic type of report. Information appears in a multicolumn, multirow format. Each column corresponds to a column in the database table. In this example, all of the labels (for example, Deptno) are derived from the columns in your SQL SELECT statement. Level: Introductory. For details on building this report, see Tabular Report on page 5 3.

Visual Index

43

External Query Report

This report contains an external query that was stored in a file using Oracle Reports, then imported into the report. Level: Introductory. For details on building this report, see External Query Report on page 5 7.

44

Building Reports Manual

Introductory Mailing Label Report

This report automatically prints mailing labels in multiple columns on each page. The labels can be printed in one or many columns, and can begin at any position. You can make the labels print across the page and then down, or down and then across as in the report above (Every Mountain, Jocksports, Just Tennis, K + T Sports,. . .). Level: Introductory. For details on building this report, see Introductory Mailing Label Report on page 5 11.

Visual Index

45

Form Letter Report

Form letter reports contain database values embedded in boilerplate text. (Boilerplate text is any text that you enter or import into a painter.) In this example, employee information is displayed in various places in the letter. Level: Introductory. For details on building this report, see Form Letter Report on page 5 18.

46

Building Reports Manual

Master/Master Report

A master/master report displays at least two sets of data with no direct relationship to each other. In general, each set of data can contain any number of columns. Level: Introductory. For details on building this report, see Master/Master Report on page 5 22.

Visual Index

47

Break Report

Break reports divide rows of a table into sets, based on a common value in one of the columns. In the example shown above, all employees in department 10 are printed first, then those in department 20, etc. Furthermore, the department number is printed only once per set. You use this type of report when you to restrict a column from repeating its same value several times while values of related columns change. Level: Introductory. For details on building this report, see Break Report on page 5 25.

48

Building Reports Manual

Master/Detail Report

Master/detail reports contain two or more groups of data. For every value of the master group, the related values of the detail group(s) are fetched. In this example report, for every employee name and number in the first group, the employees related information from the other group (PRODNAME, AMOUNT, CUSTNAME) is printed. Level: Introductory. For details on building this report, see Master/Detail Report on page 5 35.

Visual Index

49

Summary Report

A summary report contains at least one column whose value is calculated using data retrieved from one or more other columns. This report includes the following summaries:

total salaries for each department grand total of all salaries in the report

Level: Introductory. For details on building this report, see Summary Report on page 5 40.

4 10

Building Reports Manual

Master/Detail/Summary Report

A master/detail/summary report is a master/detail report that contains one or more summaries. In this example, the top left rectangle is the master. The top right rectangle is the detail, and the bottom right rectangle is the summary. The summary calculates the detail item totals for each master record displayed. Level: Introductory. For details on building this report, see Master/Detail/Summary Report on page 5 51.

Visual Index

4 11

Formula Report

A formula report contains at least one column whose value is calculated using data retrieved from one or more other columns. This report includes the following formulas:

a computation that calculates the tax due for each total a computation that calculates the sum of the subtotal plus the tax calculated by the first computation

Level: Introductory. For details on building this report, see Formula Report on page 5 56.

4 12

Building Reports Manual

Across Break Report

An across report prints the values of a database column across the page instead of down (see the Ename values in the report above). When there are more values than will fit on a line, Oracle Reports wraps the line and prints the remaining values across the page on the next line. In Across reports with breaks, the master (or break) group prints top to bottom, i.e., as it would in other master/detail reports. However, the values in the detail group print across the page, from right to left. In this example, DEPTNO, DNAME, and LOC values print top to bottom, while ENAME values print left to right. Level: Introductory. For details on building this report, see Across Break Report on page 5 61.

Visual Index

4 13

Wrapped Break Report

This report is similar to a break report in that it contains a control break. The difference is that the break field is wrapped on word boundaries if it is too long to fit on one line. Level: Introductory. For details on building this report, see Wrapped Break Report on page 5 64.

4 14

Building Reports Manual

Header and Footer Report

Header and footer reports contain boilerplate and/or fields in its headers and/or footers. This report has a page header, Employee Summary and a footer , End of Dept. fieldvalue, which is printed at the end of each list of employee information for each department. Level: Introductory. For details on building this report, see Header and Footer Report on page 5 67.

Visual Index

4 15

Placing Database Values In Page Headings

In the Header and Footer Report, you learned how to place database values in headers and footers. However, you can place more than one database value in headers and footers. In this example report, the first and last department number found on each page is displayed in the page header. Level: Introductory. For details on building this report, see Placing Database Values In Page Headings on page 5 71.

4 16

Building Reports Manual

Graphics and Text Report

This report contains graphics created in Oracle Reports, including lines, ellipses, and boxes. It also displays boilerplate text in a different font and point size than normal, and includes an imported image. Level: Introductory. For details on building this report, see Graphics and Text Report on page 5 75.

Visual Index

4 17

Matrix Report

A matrix report is like a grid: it contains one row of labels, one column of labels, and information in a grid format that is related to both the row and column labels. (Matrix reports are also referred to as crosstab reports.) This example report also contains as options the following: three summaries, one of which sums the salaries by department (8750. . .), one that sums the salaries by job (6000. . .), and one that sums all salaries in the matrix (29025); zeroes in place of null values; and a visible grid overlaying the output. Matrix reports are different from tabular reports because the number of columns are not known in advance. Thus, this report would automatically be extended if a new job function, called RECEPTIONIST, was added to the underlying data tables. You can create matrix reports with any number of queries. In Method One, you create the matrix report shown above using one query. In Method Two, you use three queries to build the same report. Level: Introductory. For details on building this report, see Matrix Report on page 5 81.

4 18

Building Reports Manual

Time Series Calculations Report

Reports with time series calculations display and calculate values over a specified period of time. In this example, a fourmonth average of purchases for each customer is computed and displayed. The techniques described for this report can be used to produce other formats of time series calculations as well. Level: Advanced. For details on building this report, see Time Series Calculations Report on page 6 3.

Visual Index

4 19

Aggregating Data within Ranges

Values from the database are retrieved and formatted based on any aggregate range that you define. In this example report, the aggregate range is in increments of one thousand, starting at zero. Level: Advanced. For details on building this report, see Aggregating Data within Ranges on page 6 6.

4 20

Building Reports Manual

Renumbering Pages by Repeating Frame

In this report, the page number is reset whenever the customer information for a new sales representative is encountered. Level: Advanced. For details on building this report, see Renumbering Pages by Repeating Frame on page 6 9.

Visual Index

4 21

Anchors Report

This report displays the order information for each customer, per sales representative. The Summit Sporting Goods logo is anchored so that it appears centered alongside of the order information. Next to the sum amount of each customers orders, the credit limit of that customer appears. Level: Advanced. For details on building this report, see Anchors Report on page 6 14.

4 22

Building Reports Manual

Intermixing Fields from Different Repeating Frames

Normally, a break field appears to the left of fields that are related to it. In this example, the break field appears between its related fields. Level: Advanced. For details on building this report, see Intermixing Fields from Different Repeating Frames on page 6 20.

Visual Index

4 23

Check Printing Report

This check printing report is built so that the check appears on the left, and its related stub on the right. It could, however, be built so that the check appears above the stub. There is one interesting aspect to building any check printing report: canceling checks for stubs that require more than one page. The company name is printed on the check for the first page of the stub, and CANCELLED is printed on all checks thereafter for stubs that are continued onto more than one page. Level: Advanced. For details on building this report, see Check Printing Report on page 6 23.

4 24

Building Reports Manual

Spelling Out Cash Amounts On Checks

There are two ways to spell out the amount of a check: you can use the ORACLE DECODE function, or you can create a table to perform the conversion. The second method is discussed in this book, below. (This report is being explained separately from the Check Printing report for simplicity.) Level: Advanced. For details on building this report, see Spelling Out Cash Amounts On Checks on page 6 27.

Visual Index

4 25

Printing Reports On Preprinted Forms

This example report illustrates report formatting techniques for printing reports on preprinted forms. The report outlines the design methodology for printing reports on a company sales order form, in this case a mockup of a form for Summit Sporting Goods. Level: Advanced. For details on building this report, see Printing Reports On Preprinted Forms on page 6 30.

4 26

Building Reports Manual

Invoice Report

Invoice reports have several distinguishing characteristics:

The top section typically contains a customer name, address, and other related information which must print on specific line and column positions on the preprinted invoice form. The middle section in most invoices contains the lineitem details, including billing amounts. The number of items being printed will vary from customer to customer, and may require the invoice to span multiple pages. The bottom part of invoice reports contains customer billing information. Typically, this is a page total on all but the last page. On the last page, the page total is replaced with the total billing amount for that customer.

Level: Advanced. For details on building this report, see Invoice Report on page 6 35.

Visual Index

4 27

PL/SQL Report

This report uses an external PL/SQL library and PL/SQL within the report to calculate the total compensation (including bonuses) for all employees. Level: Advanced. For details on building this report, see PL/SQL Report on page 6 41.

4 28

Building Reports Manual

Ranking Report

This report ranks data in two different ways: by count, and by percentage. The upper section displays the names and total purchases of the top three customers; the lower section displays the names and total purchases of those customers who constitute 75% of all sales. The ranking criteria can be set by the user at runtime, or default to previously specified values. The reports explanation is split into two parts. The first tells you how to build the rankingbycount section, and the second discusses building the rankingbypercent section as an addition to the first section. Level: Advanced. For details on building this report, see Ranking Report on page 6 47.

Visual Index

4 29

Suppressing Labels When No Detail Records Are Retrieved

In master/detail reports, the labels appear for the detail group, even if no detail records are retrieved. This report shows how to suppress printing of these labels when no associated details exist. For example, the labels of the detail group (Ename and Job) are not displayed because department 40 has no employees. The techniques described in this report can also be used to suppress detail group summaries when no records are retrieved for the detail group. Level: Advanced. For details on building this report, see Suppressing Labels When No Detail Records Are Retrieved on page 6 53.

4 30

Building Reports Manual

Advanced Mailing Label Report

This report is similar to the introductory mailing label report. It has one added feature, however; it also displays each zip code in a graphical manner (i.e., as a barcode). It does this by including an Oracle Graphics display, to which it passes the zip code. The Oracle Graphics display converts the zip code to a bar code and displays it in the report. Level: Advanced. For details on building this report, see Advanced Mailing Label Report on page 6 57.

Visual Index

4 31

Mailing Reports to Multiple Users

This example report, in and of itself, has no real distinguishing features. It is a simple, onequery tabular report. What distinguishes this report is its destination. You will create another report that selects the users to which you wish to mail this report, then use the packaged procedure SRW.RUN_REPORT to run the report and mail it automatically to the selected users. Level: Advanced. For details on building this report, see Mailing Reports to Multiple Users on page 6 61.

4 32

Building Reports Manual

Conditional Form Letter Report

This example report displays sections of a report (form letter) based on whether certain criteria are met. In this example, Summit Sporting Goods is having a picnic for all employees on June 15. On the evening of that same day, a special dinner is also planned for Summits top sales representatives. Summit generates a form letter that does the following:

invites all employees to the picnic invites sales representatives with more than $500 in commissions to the dinner

Level: Advanced. For details on building this report, see Conditional Form Letter Report on page 6 66.

Visual Index

4 33

Conditional Highlighting Report

Conditional highlighting reports highlight database values and/or text when certain criteria are met. You use this type of report when you want database values to determine what parts of the report should be highlighted. In this example, Oracle Reports bolds the names and salaries of all employees whose salaries are greater than 2000. Level: Advanced. For details on building this report, see Conditional Highlighting Report on page 6 71.

4 34

Building Reports Manual

Static Graphics Report

This sales report includes an imported Summit logo as a letterhead, and also contains a graphic drawn within Oracle Reports. Level: Advanced. For details on building this report, see Static Graphics Report on page 6 76.

Visual Index

4 35

Dynamic Graphics Report

This employee report includes a linked bar chart that displays monthly revenues for the company up to the current month, and also shows a drawing created for each department. Level: Advanced. For details on building this report, see Dynamic Graphics Report on page 6 81.

4 36

Building Reports Manual

Nested Matrix Report

A nested matrix report is a matrix report in which at least one parent/child relationship appears within the actual matrix. This example nested matrix report contains a parent/child relationship in the two groups printing down the page. Level: Advanced. For details on building this report, see Nested Matrix Report on page 6 89.

Visual Index

4 37

Matrix Break Report

A matrix break report is a combination of matrix and break report formats. Essentially, a matrixformat report is printed for each master group value. This report shows department, job, and salary information for each employee by the year they were hired. Level: Advanced. For details on building this report, see Matrix Break Report on page 6 97.

4 38

Building Reports Manual

Matrix with Summaries Report

This matrix report has nearly the same data model as the nested matrix report (described in the previous section), except this report contains several summaries not computed in the previous report. Level: Advanced. For details on building this report, see Matrix with Summaries Report on page 6 100.

Visual Index

4 39

ASCII File Report

This report is essentially a dump of the order data for Summit Sporting Goods. The output, delimited by double quotes and commas, is written to a text file. No form feeds (i.e., page breaks) or other control characters appear in the output, ensuring that the data file contains an unbroken stream of records. This enables you to easily transfer the data file to another operating system or platform, ready to be loaded into another database or similar application. Level: Advanced. For details on building this report, see Data File Report on page 6 104.

4 40

Building Reports Manual

DrillDown Report with Parameter List of Values and Character Output

This is a simple matrix report with buttons in all the cells that contain values. When pressed, each button calls another report, effectively enabling you to drill down to a deeper level of detail. The output of the drilldown report is displayed in its own Previewer. These two reports use the following features new to Oracle Reports 2.5:

usercreated buttons capable of executing actions in the Previewer userdefined lists of values for parameters ASCII output generation

Level: Advanced with new features. For details on building this report, see DrillDown Report with Parameter List of Values on page 7 5.

Visual Index

4 41

Multimedia Report

This report consists of graphics and boilerplate created in the Layout editor as a frame for three buttons. These buttons, when pressed in the Previewer, display either an image or a short video clip. This reports uses the following feature new to Oracle Reports 2.5:

usercreated buttons capable of displaying multimedia objects in the Previewer

The button you created for the drilldown report executed a PL/SQL procedure. Buttons can also execute other actions; most notably, display multimedia files when pressed in the Previewer. Depending on your platform and the capabilities of your individual machine, these files can be images, sound files, or video clips. A major advantage of buttons is their portability. Reports containing buttons can be moved from platform to platform with no loss of functionality, if the multimedia files are relocated as well. Level: Advanced with new features. For details on building this report, see Multimedia Report on page 7 14.

4 42

Building Reports Manual

OLE2 Report

The images in the report output above are furnished by OLE2 objects stored in a database table. Oracle Reports V2.5 is an OLE2 container; i.e., it enables you to include OLE2 objects in a report in one of two ways:

in the data model in a boilerplate object

OLE2 Objects in the Data Model: OLE2 objects stored in files can be accessed via a column of filenames for which Read From File has been checked. When you default your layout, the appropriate layout object will be created for it (e.g., a field for an image, a button for a video). OLE2 Objects in Boilerplate: When you create a piece of OLE2 boilerplate using the OLE2 tool, you can either invoke any OLE2 servers to which you have access and create your object on the spot, or use an existing file. Once a file is embedded, you can activate it if you have access to the application used to create it. Level: Advanced with new features. For details on building this report, see OLE2 Report on page 7 19.

Visual Index

4 43

Tracing and Debugging Report Execution

Oracle Reports now has several tools for designtime debugging. For example, the Object Navigator can show data and layout objects either is a straight alphabetical list by type or in a hierarchical fashione.g., list columns under the groups to which they belong, or fields under the frames to which they belong. The Object Navigator can also show whether an object has attached PL/SQL, and to what it is anchored. Integration with a PL/SQL development environment via Oracle Procedure Builder gives you access to both the Program Unit editor, in which you can write and debug your functions and procedures, and the PL/SQL Interpreter, with which you can set breakpoints, step through the execution of your report, test your functions at design time, and more. Oracle Reports also has extensive tracing capabilities. You can capture and write to a trace file such aspects of report execution as errors and warnings, break points triggered, PL/SQL and SQL execution, and stepbystep execution of report objects. Level: Advanced with new features. For details on building this report, see Tracing and Debugging Report Execution on page 7 23.

4 44

Building Reports Manual

CHAPTER

Introductory Reports
his chapter describes the distinguishing features, concepts, organization, and steps to build each type of report listed below:

tabular report 5 3 external query report 5 7 introductory mailing label report 5 11 form letter report 5 18 master/master report 5 22 break report 5 25 master/detail report 5 35 summary report 5 40 master/detail/summary report 5 51 formula report 5 56 across break report 5 61 wrapped break report 5 64 header and footer report 5 67 placing database values in page headings 5 71 graphics and text report 5 75 matrix report 5 81

Introductory Reports

51

How to Use This Chapter

You can use this chapter in one of three ways:


Build any single report. Build all of the reports. This is an excellent way to learn how to build many types of reports and use the Oracle Reports settings. Refer to one or several reports containing features you would like to include in your reports, and use the steps listed to guide you in the creation of your own reports. For example, if you want to build a master/detail report, go to the section describing the master/detail report and follow the instructions. Note: The reports increase in complexity as the chapter progresses. If you start building the last few reports in this chapter, you may have difficulty following some of the steps.

If you have just finished the Tutorial in Chapter 2 and were previously unfamiliar with Oracle Reports, we recommend that you try building the first few reports in this chapter to get a feel for the reportbuilding process. Building all the reports is the best way to learn about the many functions and features available with Oracle Reports.

52

Building Reports Manual

Tabular Report

Distinguishing Features

A tabular report is the most basic type of report you can build. The report output is organized in a multicolumn, multirow format, with each column corresponding to a column in the database table. In this example, the column labels Deptno, Dname, and Loc, are derived from the columns in your SQL SELECT statement, but you can modify column labels as you wish. When you invoke Oracle Reports, it automatically creates a new report definition, which consists of Oracle Reports default settings stored in a report buffer. You create the report you want by customizing this report definition. Generally, the first step is to define the data Oracle Reports should fetch from the database by creating a query that contains a SELECT statement. Although the report in this section uses only one query, reports can contain any number of queries. For each query you create, Oracle Reports automatically creates one default group. The default name of the group is the query name with G_ prefixed to it. As shown by the data model in the next figure, weve named our query Q_Department. Therefore, the group created by Oracle Reports for this report is G_Department. If your query was named Accounts, the default group name would be G_Accounts. For each database column you specify in the querys SELECT statement, Oracle Reports creates a report column and assigns it to the group. By default, the columns appear in the order in which you enter them in your SELECT statement. The default column names are generated from the database column names or replaced by any aliases specified in your SELECT statement.

Concepts

Data Relationships

Introductory Reports

53

If you select two or more columns with the same name, the first column is given the default name, the second column is given the default name with a 1 appended to it (e.g., Deptno, Deptno1), etc. Layout Before you can run your report, youll need to specify the layout (i.e., the format) of the report output. If you dont, Oracle Reports will fetch the data but will not display it and you will receive an error message. For this report youll use the tabular layout style, which is one of six styles provided by Oracle Reports. The tabular layout displays data in a series of columns running down the page with the column headings displayed directly above the columns. To see a sample tabular report, open the Oracle Reports example report named tabularb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Youll build one query to select all of the columns displayed in this report. Oracle Reports will create all other necessary data objectsi.e., groups and columnsby default.

Steps to Build this Report

Queries

After you invoke Oracle Reports and display the Object Navigator, the next step is to specify the data. 1. Doubleclick on the Data Model icon in the Object Navigator. The Data Model editor appears.

Data Model Icon

54

Building Reports Manual

2.
Query Tool

Click once on the Query tool in the Tool palette to select it. Move the mouse cursor into the editing region and click once. A query object, represented by a rounded rectangle labelled Q_1, appears in the Data Model editor.

3.

Doubleclick on the query object to display its property sheet. An objects property sheet is a dialog containing a list of settings affecting that object. Almost every Oracle Reports object has an associated property sheet. To access an objects property sheet, either doubleclick on that object in the editor, or doubleclick on the icon representing that object in the Object Navigator.

4. 5.

Click in General:Name and replace Q_1 with Q_Department. Move the cursor to the SELECT Statement field and enter the following SQL SELECT statement:
SELECT * FROM DEPT ORDER BY DEPTNO

Remember, you can also create your SELECT statement via the list of values provided by the Table and Column Names dialog box. For details, see Creating a Query on page 2 8. Note: A carriage return was placed after DEPT to make the query easier to read. However, you can format a SQL statement in many different ways. Oracle Reports regards a query with one word on each line to be equivalent to a query entirely on one line. 6. Select OK to accept the Query property sheet. If you havent already connected to an ORACLE database, the Connect dialog box appears. Fill in the appropriate fields with your username, password, and SQL*Net protocol, if necessary. Default Layout Use the Default Layout dialog box to select the format for your report. 7. Select Tools>Default Layout... (or select the Default Layout tool). The Default Layout dialog box appears. Notice the icons on the Style tab. Each one represents one of the six different layout styles available with Oracle Reports. The radio button below Tabular is already filled in because Tabular is the default layout style.

Introductory Reports

55

Click on the Data/Selection tab and examine the available settings. Using this tab, you can determine which columns have corresponding fields created for them in the layout, the widths and heights of the fields, the field labels, and whether the fields in a group are formatted down or across a page. 8. Layout Editor Select OK, as none of the defaults need to be changed for this report.

The Layout editor appears, displaying the newlycreated layout.

Notice the order in which the fields appear. This order, when reckoned from left to right, matches the order of the columns in the default group when reckoned from top to bottom. 9. Select File>Run (or select the Run tool).

10. The Runtime Parameter Form appears, allowing you to enter runtime parameters. (For more information on parameters, see Runtime Parameter Form in Chapter 9 of the Reports Reference Manual.) The default parameters will do for now, so accept the Runtime Parameter Form and run the report by selecting Run Report. The Previewer appears, displaying the report output. (For details on the Previewer, see Previewer in Chapter 11 of the Reports Reference Manual.) When you select File>Run and accept the Runtime Parameter Form, Oracle Reports first generates the report, then fetches and displays the data accordingly. During formatting, Oracle Reports gives you the option of cancelling report execution via the Report Progress dialog. 11. Close the Previewer (select Close). Select File>Save (or the Save tool) to save your report.

56

Building Reports Manual

External Query Report

Distinguishing Features Concepts

This report fetches data using an external queryi.e., a query that is contained in a file external to the report and referenced by the report query, instead of being saved with the report definition. This report demonstrates Oracle Reports ability to access data from external sources such as text files. You can use external queries, PL/SQL, and graphics in your reports. To build this report, create a query and save it to a file. Then reference the file within your reports own query. Oracle Reports uses the query as if you had entered it in the SELECT Statement field of the Query property sheet. The report above is a default tabular report. You will modify one format mask. To see a sample external query report, open the Oracle Reports example report named externlb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Data Relationships

Layout

Organization

For this report, youll create one external query. Oracle Reports will create other necessary data objects shown in the next figure.

Introductory Reports

57

Steps to Build this Report

External Queries

1.

Access the External Query editor using one of the following methods:

select File>New>External Query, then doubleclick on the icon in the external query node select the External Queries node in the Object Navigator and select Navigator>Create (or the Create tool) to create a new external query node, then doubleclick on the icon in the external query node doubleclick on the External Queries node to create a new external query node, then doubleclick on the icon in the external query node

2.

The External Query editor appears. Enter the following SQL SELECT statement in the text field:
SELECT CUSTID, ORDID, SHIPDATE, TOTAL FROM ORD WHERE TOTAL > 1000 ORDER BY CUSTID

58

Building Reports Manual

3.

Save the external query as a file named external.sql. (Select either File>Save or the Save tool, then save the file as you do a report.) The file extension .sql is not required. However, it is the default extension provided by Oracle Reports in the Save to File dialog box. In this report you are saving the query to your current directory. You can also specify a full pathname if you wish, or save the file in the database. However, be aware that doing so reduces the portability of your report. Oracle Reports provides an environment variable you can set to specify where you want to store reportrelated files. This is the REPORTS25_PATH variable. For more information on this variable, see Oracle Reports Environment Variables in Chapter 18 of the Reports Reference Manual. Note: You are not required to use the External Query editor to create your query. You can use the text editor of your choice. However, if you use a text editor, be sure to save your file as text (e.g., ASCII or EBCDIC).

Data Model Icon

4.

Query Tool

Close the External Query editor (select File>Close.) Create a new report if necessary (the same options are available for creating a new report as for creating a new external query). Open the Data Model editor and create a query object. (Doubleclick on the Data Model icon in the Object Navigator to display the Data Model editor. Click once on the Query tool to select it, then click once in the Data Model editing region.) Open its property sheet (doubleclick on the rounded rectangle in the Data Model editor), click in the General:Name field and rename it Q_External.

5.

In the External field, enter external.sql, making sure to specify its exact location if you did not save it to the directory from which you invoked Oracle Reports. If you saved the query to the database, prefix the query name with DB: when entering it in the External Query field. The query in the file external.sql will now be used in the report. Click on Apply (the Apply button implements the specified settings without dismissing the property sheet). Notice that the SELECT statement you saved as external.sql appears in the property sheets SELECT Statement field but cannot be modified. If you wish to modify the SELECT statement, you need to edit the file.

6.

Accept the property sheet (select OK).

Introductory Reports

59

Default Layout

7.

Select Tools>Default Layout... (or use the Default Layout tool). Accept the default settings (select OK) to display the layout shown.

Save and run your report. Oracle Reports pulls the external query into the report and executes it as if it were entered in the Query property sheet. Examine the output for F_TOTAL. It does not display as a dollar amount. You can correct the appearance of F_TOTAL by specifying a format mask for the field. Each layout object, like each data model object, has properties you can modify. For example, you can modify the properties of fields to specify such settings as whether the value in the field is to be left or rightjustified, whether to force a page break before or after the field, etc. In the next steps, youll modify the F_TOTAL field so it displays as a dollar amount with all values properly aligned. Fields 8. 9. Close the Previewer (select Close). Doubleclick on the F_TOTAL field to display its property sheet. Click in Object:Display:Format Mask and enter NNNNN0.00, then accept the property sheet. This tells Oracle Reports to display the contents of the field with at least one number before and two numbers after the decimal point (as indicated by the positions of the zeroes) and to include a negative sign if the value is negative, but no sign if the value is positive. The character N tells Oracle Reports to display a number in that position if it exists, but not to pad with blanks if it does not. For more information on format masks, see Format Mask in Chapter 8 of the Reports Reference Manual. Save and run your report again. Notice the change in the appearance of the F_TOTAL column values.

5 10

Building Reports Manual

Introductory Mailing Label Report

Distinguishing Features

A mailing label report consists of data displayed in a format suitable for use as address labels on envelopes. The labels can be printed in one or many columns, and can begin at any position. You can make the labels print down the page, across the page, across the page and then down, or down and then across. Note: The report in the figure above is formatted to print the mailing labels down, and then across. In order to demonstrate this, the page length for the example report is shortened to force a second column of mailing labels to print. In addition, the text is spaced so that it is positioned correctly when printed onto the labels, as illustrated above.

Concepts
Data Relationships Layout

Mailing labels can be created using simple, onequery reports with a special layout style. To fetch the data for a mailing label report, all you need to do is create a query to select it. You do not need to create any other data objects. Oracle Reports provides a default mailing label layout in which the fields are positioned so that each field is directly below the preceding field. Field labels are not printed. For this report youll change the Print Direction of the labels from the default direction of Down to Down/Across. This will cause the mailing labels to print down the page until they reach the bottom, then begin a new column at the top of the page and to the right of the first column of labels.

Introductory Reports

5 11

If you prefer, you can keep the default print direction of Down, so all the labels print in a single column down the page, or Across/Down, so Oracle Reports will print as many labels as possible in a row across the page, then begin another row below the first, and so on. Youll also use the Vertical Spacing field, located on the repeating frame property sheet, to control the amount of blank space between each mailing label. The default spacing between repeating frames may not be sufficient, and you may want to specify that space be inserted between mailing labels in the layout so that they are correctly positioned when printing them onto labels. To see an example mailing label report, open the Oracle Reports example report named maillblb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Youll use one query to select all of the columns for this report. You dont need to create any other data objects; Oracle Reports will create all other necessary data objects by default.

Steps to Build this Report

Queries

1.

In the Data Model editor, create a query named Q_Customer. Click in General:SELECT Statement and enter the following SELECT statement:
SELECT NAME, ADDRESS, CITY || , || STATE || || ZIP CITY_STATE_ZIP FROM CUSTOMER ORDER BY NAME

5 12

Building Reports Manual

Default Layout

Oracle Reports is shipped with a default mailing label layout. This layout creates fields positioned one below the other in a repeating frame; no labels are created for the fields. 2. 3. Select Tools>Default Layout... (or use the Default Layout tool). Select Style:Mailing Label as the default layout style. Click and hold the mouse button on the Data/Selection:Repeat field next to G_Customer to see the list of available print directions. Change the print direction of G_Customer to Down/Across. Changing the print direction causes one column of labels to be printed from the top to the bottom of the page. Then, if necessary, and if enough room remains on the right side of the page, another column prints to the right of the first column. 4. Move to the W (Width) column and change the widths of NAME, ADDRESS, and CITY_STATE_ZIP to 30. Changing the field widths ensures that the first column of labels does not extend so far to the right that it prevents the printing of another column of labels. 5. Accept the Default Layout dialog box. The mailing label layout appears in the Layout editor (see the figure below).

Notice the manner in which the fields are positioned: one above the other in a single repeating frame. Also notice that no column labels have been generated for the fields. Now, increase the vertical spacing between labels. Repeating Frames 6. Open the repeating frame property sheet for R_Customer by doubleclicking on it (the repeating frame is represented in the Layout editor by the box surrounding the fields and boilerplate). Click in Object:Spacing:Vertical and enter 0.25. This ensures that a quarterinch of blank space appears between each label.

Introductory Reports

5 13

Notice the Print Direction field. It specifies a print direction of Down/Across. This field provides an alternative to the Repeat field in the Default Layout dialog box for specifying print direction. 7. 8. Accept the property sheet (select OK). Go to the Object Navigator. Display the Report Properties property sheet for your report by doubleclicking on the icon representing your report. Report Properties is like a property sheet for your whole report. Using Report Properties you can change such settings for the report as page width and height, the maximum number of pages the report can contain, and the unit of measurement with which the report objects are measured. 9. Change Report:Page Height to 5.5 and accept the property sheet.

Save and run your report. Depending on your default fonts and the sizing algorithm of your environment, your output may not look exactly like that the output of the example report. However, you should see two columns of labels printing down the page. You can display the Report Properties dialog and change the Page Height again to see how it affects the spacing of the columns. Note that you can also change the font, font size, and weight of the text used to print the labels if you feel the default font is not readable enough. To do so, select the fields in the layout and use the various options under the Format menu. For more details on how to do so, refer to Lesson III, Add Boilerplate Text and Line Drawings to the Report on page 2 30.

5 14

Building Reports Manual

Related Concepts: Suppressing Blank Lines

Distinguishing Features

This report is similar to the introductory mailing label report, but also enables you to print addresses that are not all the same number of lines. Youll use a query that selects several lines, then suppress any blank lines retrieved. The previous mailing label report, maillblb.rdf, selects and prints only three lines for each address. If an address contains a fourth linefor instance, a suite number and buildingthe query will not select it, and it will not appear in the output. Adding another column to the SELECT statement wont solve the problem because, in the event the address only contains three lines, the report will print a blank line for the null value retrieved from the database. This report selects all possible lines for each address and uses format triggers to suppress the blank lines. Format triggers are PL/SQL constructs used to conditionally control report output, based on the data fetched for a layout object. In this example, if a null value is fetched from the database, the format trigger will instruct Oracle Reports not to print its associated field. Instead, the next line will be pushed up so that no blank lines appear in the middle of the label.

Concepts

Data Relationships Layout

This report uses one query. This report also uses the default mailing label layout style. Youll add format triggers to two of the fields to prevent their display if their values are null, then make the vertical spacing between them variable so that no blank lines are left in the layout.

Introductory Reports

5 15

To see a sample mailing label report that suppresses blank lines, open the Oracle Reports example report named maillb2b.rdf. For details on how to it, see How to Access Demo Reports on page 4 2.

Organization

One query selects all of the columns displayed in this report. All other data model objects will be created by default.

Steps to Build this Report

The SELECT statement shown below directly references the Names table. An alternative technique is to create a view based on the SELECT statement shown, and then use the view in this report. Doing so will enable you to change your underlying table(s) and column(s) in the future, without being forced to change your report. 1. In the Data Model editor, create a query named Q_Labels. Click in General:SELECT Statement and enter the following:
SELECT CUSTNAME, ADDRESS1, ADDRESS2, ADDRESS3, ADDRESS4 FROM NAMES ORDER BY CUSTNAME

Queries

Default Layout

2.

Select the default layout style Mailing Label. Go to Data/Selection:Repeat, display the list of values for G_Labels, and select Across/Down. Accept the dialog box. Change the vertical spacing of R_Labels to 0.25 inch. (Display the property sheet for R_Labels and enter 0.25 in the Object:Spacing:Vertical field.)

Repeating Frames

3.

5 16

Building Reports Manual

Fields

4.

Select both F_ADDRESS2 and F_ADDRESS3, then select Tools>Common Properties.... This displays the Common Properties sheet, which enables you to modify properties common to multiple objects for all selected objects with one action. Display the list for General Layout:Sizing:Vertical and select Variable. Accept the Common Properties property sheet. This ensures that, if the fields have a null value, they will contract vertically, and not take up any space in the report output.

5.

Display the property sheet for F_ADDRESS2 and go to General Layout:Format Trigger.... Select Edit... and modify the template already provided in the Program Unit editor as follows:
function F_address2FormatTrigger return boolean is begin if :address2 is null then return (FALSE); else return (TRUE); end if; end;

This function states that if the ADDRESS2 column returns a null value, the field should not be formatted in the output. Compile the trigger and close the Program Unit editor, then accept the property sheet. Display the property sheet for F_ADDRESS3 and add the same format trigger. Remember to substitute 3 for n. Your report layout should look similar to the figure below. For more information on using the Program Unit Editor, see the Oracle Procedure Builder Users Guide and Reference

Compile, save, and run your report.

Introductory Reports

5 17

Form Letter Report

Distinguishing Features

Form letter reports contain database values embedded in boilerplate text (boilerplate text can be defined as any text that appears each time the report is run). It can be text generated by Oracle Reports, text you create, or text you import from a file. The example report shown prints the data for one employee on one page, mixing the data with the boilerplate text. Individual fields (e.g., employee name, employee number, and department number), are referenced more than once.

Concepts
Data Relationships Layout

A form letter report is similar to a mailing label report in that it is a simple report with a special layout style. There are no special restrictions on data relationships for a form letter report. A default form letter layout style is provided by Oracle Reports. It consists of the field names for the columns youve selected, prefixed by ampersands (&s). The ampersands indicate that they are hidden fields, and are contained within boilerplate and repeating frame objects. You then add the text of the letter to the layout. Oracle Reports prints one recordi.e., one letterper page.

5 18

Building Reports Manual

Hidden fields, which are the default for a form letter layout, appear in the layout but not the output until referenced. To do so type its name, prefixed by an ampersand, in the Layout editor where you want the field to appear. Oracle Reports treats the reference as a normal field. In general, if you are embedding a field within boilerplate text (as in a form letter), it is best to hide the field and reference it where desired. The field values will then flow with the text. A field can appear in a report both where placed by default and where referenced, and can be referenced even when not initially hidden. Fields can also be referenced more than once in the same piece of boilerplate text. To see a sample form letter report, open the Oracle Reports example report named frmlttrb.rdf. For details on how to it, see How to Access Demo Reports on page 4 2.

Organization

This report uses one query. Oracle Reports will create all other necessary data objects by default.

Steps to Build This Report

Queries

1.

Create a query named Q_Letter. Click in General:SELECT Statement and enter the following SELECT statement:
SELECT ENAME, EMPNO, DEPTNO, JOB FROM EMP ORDER BY EMPNO

Introductory Reports

5 19

Default Layout

2.

Select Tools>Default Layout... (or the Default Layout tool). In the Default Layout dialog box, select Style:Form Letter. Accept the dialog box. The form letter layout appears in the Layout editor. Notice that Oracle Reports has created a boilerplate object to enclose the fields. Next, youll add the text of the form letter.

3.
Text Tool

Select the Text tool, click on the ampersand of &F_Ename, and then begin typing text exactly as shown, adding carriage returns where indicated by blank lines:
Employee: Emp. #: Department: &F_ename &F_empno &F_deptno

&F_ename: The Human Resources department is updating its records of the companys employees. Currently, our records show your employee number as &F_empno, and that you hold the position of &F_job in department &F_deptno. If any of this information is incorrect, please contact the Human Resources department. Thank you, Human Resources

The boilerplate object expands as you type. 4. When youve finished typing, click once in an empty section of the Layout editor. Notice the behavior of the boilerplate object. It reverts to its original size, and the text of the letter disappears. However, your letter still exists. The boilerplate object B_Letter is vertically variable, which means that it will expand during formatting to accommodate the text of the letter. Repeating Frames 5. Although the full text of your letter will print, you may wish to display it in the Layout editor. Select the R_Letter repeating frame, grab its lower right handle, and increase its height. The boilerplate object is directly above the repeating frame, so you may need to select it first and shorten it slightly to reveal the edge of the repeating frame. Then you can select the repeating frame and resize it.

5 20

Building Reports Manual

6.

Select the boilerplate object and drag a lower handle down until all of the text is visible. The layout of your report should resemble the next figure.

Save and run your report.

Introductory Reports

5 21

Master/Master Report

Distinguishing Features Concepts

A master/master report displays at least two sets of data which are not directly relatedthat is, the records constituting the data are fetched using at least two separate queries. A master/master report (also called a parent/parent report) contains two or more queries with no links (parent/child relationships). Although the data may be conceptually related, the queries make no attempt to relate it by the manner in which it is fetched. To select the data for a master/master report, create two or more unrelated queries. This report uses the default tabular layout style. Youll move the layout objects associated with the second query to insert more space between the information fetched by the two queries and make your report easier to read. For this report youll create a format mask and change some of the default column labels to clarify their meanings. To see a sample master/master report, open the Oracle Reports example report named masterb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Data Relationships Layout

Optional

Organization

Youll create two unrelated queries in this report. Oracle Reports will create all other necessary data objects by default.

5 22

Building Reports Manual

Steps to Build this Report

Queries

1.

Create a query named Q_Dept. Click in General:SELECT Statement and enter the following SELECT statement:
SELECT DEPTNO, DNAME, LOC FROM DEPT

2.

Select the Query tool again. Create a second query named Q_Emp about an inch to the right of Q_Dept and enter the following SELECT statement:
SELECT ENAME, JOB, SAL FROM EMP ORDER BY ENAME

Default Layout

3. 4.

Select Tools>Default Layout... (or use the Default Layout tool). Keep Tabular as the layout style. Go to Data/Selection:Label and change the labels for the columns listed below: Default Column Name Deptno Dname Loc Sal New Column Name Dept. # Dept. Name Location Salary

This makes the column labels more readable.

Introductory Reports

5 23

Select OK to accept the dialog box and display the default layout. The figure below shows how the layout should appear.

Notice in the layout that the field labels from the second query, Q_Emp, are located directly below the fields from the first query, Q_Dept. For this report, youll move all the layout objects belonging to Q_Dept by dragging them to the new location. 5. While still in the Layout editor, clickandhold on M_Emp_GRPFR (the large outer frame surrounding the fields, labels, and repeating frame from your second query). Drag down about half an inch in the Layout editor. Release the mouse button. Notice that you have moved not only M_Emp_GRPFR but also all the layout objects within it.
Confine Mode On

Here you take advantage of Confine mode, the default mode for the Layout editor. With Confine mode on, an object cannot be moved outside of or placed behind its parent. Such a situation renders the layout invalid and no output is produced. Sometimes moving an object outside of its parent is a valid action. If you need to do so, you can turn off Confine mode by toggling off the Confine tool in the toolbar. Save and run your report. Notice the SAL column. The values are neither aligned nor displayed as dollar amounts. 6. Close the Previewer. Display F_SALs property sheet and give the column a format mask of NNNN0.00.

Confine Mode Off

Save and run your report again to verify the format of F_SALs values.

5 24

Building Reports Manual

Break Report

Distinguishing Features

Break reports divide the rows of a table into sets, based on a common value in one of the columns, such as the department number in the example above. Notice that each department number prints only once. If the report above was not a break report, the number 10 would print three times under Deptno (once for each record containing information about department 10), the number 20 would print five times, etc. Create a break report when you want to prevent a column from repeatedly displaying the same value while other column values in the rows change. A break report resembles a master/detail (or parent/child) report in that one master record prints, followed by all the detail records with which the master has something in common. A break report usually runs faster than a master/detail report (for details, see Performance and Tuning in Chapter 17 of the Reports Reference Manual).

Concepts

Data Relationships

A break report only requires one query. Youll need to make sure your SELECT statement includes a column, called a break column, containing at least one value which repeats over multiple records (e.g., Deptno in the example report above). With the break column, youll create a second group, called a break group, to create the breaks in the data.

Introductory Reports

5 25

Layout

This report uses a default tabular format. Youll improve the readability of the report by changing the vertical spacing for a repeating frame to insert a space between each set of department information (e.g., between the last record of Department 10 and the first record of Department 20, as shown in the example report above). Youll also add a format mask. To see a sample break report, open the Oracle Reports example report named breakb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

In addition to the default group G_Employee, youll create a break group (G_Dept), containing the break column, DEPTNO. The rest of the columns, EMPNO, ENAME, JOB, and SAL, will remain assigned to the default group.

Steps to Build this Report

Queries

1.

Create a query named Q_Employee and enter the following SELECT statement:
SELECT EMPNO, ENAME, DEPTNO, JOB, SAL FROM EMP ORDER BY DEPTNO

Accept the Query property sheet. Groups Next create the break groupa second group that is also associated with the Q_Employee query.

5 26

Building Reports Manual

2.

Drag the G_Employee group down about one inch to give yourself more room to create a new group. When you select or grab a group, remember to click in the rectangle in which the name appears. If you click on a column in the group by mistake, youll select the column rather than the group.

3.

Drag the DEPTNO column above the G_Employee group. This creates a new group with the default name of G_1. You need to position the new group above the existing group to ensure that the new group is placed above G_Employee in the data hierarchy of the report. If you place the new group after G_Employee and assign it a column, the column cannot function effectively as a break column, because it cannot break until all values in all columns higher in the data hierarchy than itself, as well as its own values, have repeated.

4. Default Layout 5. 6.

Display the new groups property sheet and rename it G_Dept (enter G_Dept in the Name field). Accept the property sheet. Select Tools>Default Layout... (or the Default Layout tool). The Default Layout dialog box appears. Accept Tabular as the default layout style, as none of the defaults need to be changed for this report. The Layout editor appears, displaying the following layout.

The break column appears in the layout as a default tabular columns. You will not see the effect of creating a break group until you run the report. 7. Doubleclick on F_SAL to display its property sheet. Click in Object:Display:Format Mask and enter NNNN0.00. This will ensure that the column values format as dollar amounts. Save and run your report. The break is now evident, but to further delineate between information sets, you can add more space between groups by modifying a repeating frame.

Introductory Reports

5 27

Repeating Frames

Repeating frames are layout objects that contain fields, and repeat as many times as necessary to display all field values. This report contains two repeating frames: R_Dept and R_Employee.

To insert a space between each break group, modify the repeating frame containing the break column (in this case, R_Dept). 8. Doubleclick on R_Dept, the outer repeating frame, to display its property sheet. Click in Object:Spacing:Vertical and enter 0.25. This will place a quarter inch of blank space between occurrences of the R_Dept repeating frame in the report output. Accept the property sheet and save and run your report.

5 28

Building Reports Manual

Related Concepts I: Multiple Columns in a Break Group

Distinguishing Features

The report above looks similar to the break report you just built. However, notice that DEPTNO prints more frequently than it did in the previous report. This occurs because DEPTNO is now grouped with another column, JOB, and must print with JOB. While DEPTNO repeats several times, not until the position of Analyst in Department 20 does a job repeat, and not until that point can the break group actually break. You can specify that your report break on certain combinations of information by varying the columns you include in the break group. You can modify your break report into the one shown above by placing two columnsDEPTNO and JOBin the break group instead of one. After changing the data model, redefault the layout to incorporate your changes, then specify the format mask again. Dont modify the repeating frame for this report. To see a sample break report with multiple columns in the break group, open the Oracle Reports example report named break2b.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Concepts
Data Relationships Layout

Organization

Below is the data model for this report. Notice its similarity to the data model for breakb.rdf.

Introductory Reports

5 29

One query selects all columns. The group G_Employee is created by default, while you create the group G_Dept. The only difference is in the assignment of JOB to G_Dept.

Steps to Build This Report

Data Model

1.

Display the Data Model editor. It should still contain the data model from your previous break report. Select the JOB column. Draganddrop it into the G_Dept group. Note: Be careful of the placement of columns when you drag them from group to group. For example, if you drop JOB too close to DEPTNO, it may move to a position above DEPTNO and change column hierarchy. Enlarge G_Dept go have more room for JOB.

12. Display the property sheet for Q_Employee. Add the column JOB to the ORDER BY clause, so that it reads:
ORDER BY DEPTNO, JOB

13. Select Tools>Default Layout... (or the Default Layout tool), and accept a default tabular layout. An alert will ask if you want to overwrite your existing layout body. Select Yes.

5 30

Building Reports Manual

14. Display the F_SAL field property sheet and specify a format mask of NNNN0.00. (Hint: Select List... next to Object:Format Mask..., select the format mask you want to use, and select Insert.) Accept the property sheet. 15. Select File>Save As... to save your new break report under a different name. Run your report. Now the values for both DEPTNO and JOB must repeat before the report will break. This is because both are contained within the same repeating frame, R_Dept, as shown in the figure below.

Introductory Reports

5 31

Related Concepts II: Multiple Break Groups

Distinguishing Features

The figure above shows a further modification of your original break report. In this version, DEPTNO prints only once for each department. JOB prints only once when more than one employee in a department has the same job. Both columns are now in separate break groups. You can also create reports that include multiple break groups and assign one or more columns to each break group. Youll further modify the data model to include two break groupsG_Dept and G_Job. Regenerate a default tabular layout to incorporate changes to the data model, and specify the format mask again. Once again, dont modify the repeating frame. To see a sample break report with multiple break groups, open the Oracle Reports example report named break3b.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Concepts
Data Relationships Layout

Organization

Below is the data model for this report. One query selects all columns displayed. One groupG_Employeeis created by default, while you create the other two groupsG_Dept and G_Job. Each of the usercreated groups has one column assigned to it.

5 32

Building Reports Manual

Steps to Build This Report

1. 2.

Go to the Data Model editor. It should still contain the data model from your previous break report. Drag the G_Employee group down about an inch to give you enough room to create another group. Drag the JOB column between G_Dept and G_Employee and release it. Doubleclick on the new group to display its property sheet and name it G_Job. Select Tools>Default Layout... (or the Default Layout tool) and accept the default layout. An alert will ask if you want to overwrite your existing layout body. Select Yes. Display the property sheet for F_SAL a give it a format mask of NNNN0.00. Accept the property sheet. Select File>Save As... and save your new break report under a different name.

3.

4. 5.

Run your report.

Introductory Reports

5 33

DEPTNO and JOB are now assigned to different groups and enclosed by different repeating frames. When DEPTNO breaks is now based solely on its own values. Similarly, the frequency with which JOB breaks depends solely on its own values.

5 34

Building Reports Manual

Master/Detail Report

Distinguishing Features

A simple master/detail report contains two groups of data: the master group and the detail group. For each master record fetched (Ename, and Empno in the example shown above), the related detail records (Prodname, Amount, and Custname). Master/detail reports are similar to break reports in the way they fetch data; for every master or break group, related detail records are fetched. In addition, if you use the Master/Detail default layout style to format a break report, the output will look like a master/detail report as defined by Oracle Reports (the master records will appear above the detail records and print across the page) and if you use the Tabular default layout style to format a master/detail report, the output will look like a break report (the master records will appear to the left of the detail records and print down the page). Performance is the key issue when contrasting break reports with master/detail reports. For details on how to determine whether a break report or a master/detail report will run more efficiently under given circumstance, see Performance and Tuning in Chapter 17 of the Reports Reference Manual.

Concepts

Break reports and master/detail reports can result in similar outputs but require different data models. A break report uses one query and two groups, while a master/detail report uses two queries, each of which has one group. A relationship between the two queries is established using a data link.

Introductory Reports

5 35

A data link is a data model object which enables you to relate multiple queries. For a simple master/detail report, you relate the two queries using the primary and foreign keys of the tables from which you are selecting data. A primary key is a column for which each value uniquely identifies the record in which it is found. A foreign key is a column which contains the same values as the primary key for another table, and is used to reference records in that table. (For more information on primary and foreign keys, see Linking the Queries on page 2 56.) Linking two tables via primary and foreign keys is similar to specifying a join condition. In fact, the data link causes Oracle Reports to create a SQL clause defining a join, based on information specified when creating the link. This clause is added to the child querys SELECT statement at run time. The join defined by a default data link is an outer joinin addition to returning all rows that satisfy the links condition, an outer join returns all rows from one table that do not match a row from the second table. Data Relationships Layout This report is built using two queries related by a data link. This report uses a default master/detail layout style in which master records display across the page with the labels to the left of their fields and the detail records appear below the master records in standard tabular format. Youll deselect one default column to keep it from appearing in the report, change some field widths to ensure the fields fit across the page, and create a format mask. You will also specify a maximum of 1 record per page to ensure that only one master record and its associated detail records are displayed per page of report output. To see a sample master/detail report, open the Oracle Reports example report named mastdetb.rdf. For details on how to it, see How to Access Demo Reports on page 4 2.

Organization

For this report, youll create two queries, Q_Salesrep and Q_Product. You will also need to create a data link defining G_Salesrep, the master group, as the parent of Q_Product, the detail query, represented below by the line pointing from the column EMPNO to the column REPID. EMPNO is the primary key for the Emp table; i.e., each employee listed in the table is uniquely identified by employee number, or EMPNO. REPID is the foreign key for the Sales table; i.e., it allows the Sales table to reference the Emp table.

5 36

Building Reports Manual

Steps to Build this Report

Queries

1.

Create a query named Q_Salesrep with the following SELECT statement:


SELECT ENAME, EMPNO FROM EMP WHERE JOB = SALESMAN

Note: Although the SELECT statement above is shown in uppercase, the only element which must be entered in uppercase is SALESMAN, because it appears in the database table in uppercase. 2. Create a second query approximately two inches to the right of the Q_Salesrep query. Name it Q_Product, click in General:SELECT Statement, and type the following:
SELECT REPID, PRODNAME, AMOUNT, CUSTNAME FROM SALES ORDER BY REPID, CUSTNAME Data Link Tool

3.

Return to the Data Model editor (select OK to accept the query property sheet). Select the Data Link tool and clickandhold on the EMPNO column. Drag the mouse pointer to the REPID column and release. A data link (arrow) appears in the editor. Notice the copy of the EMPNO column at the bottom of the master group, and the copy of the REPID column in the detail query.

4.

Open the Data Link property sheet (doubleclick on the arrow).

Introductory Reports

5 37

Examine the settings in the property sheet. G_Salesrep is identified as the parent, while Q_Product listed as the child. In terms of the data, the sales reps name and employee number make up the master record and should print once for the associated product information retrieved by the Q_Product query. Notice that WHERE already appears in the SQL Clause field. WHERE is the default clause used in master/detail relationships. You can replace WHERE with other SQL clauses such as HAVING and START WITH, but for this report the default is correct. Finally, notice that an equal sign (=) appears in the Condition field. An equality (i.e., table1.columnname = table2.columnname) is the default condition for master/detail relationships defined via a data link. You can replace the equal sign with any other supported conditional operator (to see whats supported, click on the field), but for this report the default is the proper condition. Linking the group G_Salesrep and the query Q_Product via the EMPNO and REPID columns is analogous to writing both queries as the single query shown below:
SELECT ENAME, EMPNO, REPID, PRODNAME, AMOUNT, CUSTNAME FROM EMP, SALES WHERE JOB = SALESMAN AND EMPNO = REPID (+) ORDER BY REPID, CUSTNAME

Whether you should use joins or multiple queries depends on the distribution of master and detail records. For more information, as well as information on other performance topics, see Performance and Tuning in Chapter 17 of the Reports Reference Manual. Default Layout 5. 6. Select Tools>Default Layout... (or the Default Layout tool). Select Style:Master/Detail. Click on Data/Selection:Column:REPID to deselect it. Deselecting a column prevents the creation of a corresponding field in the default layout (i.e., it prevents the columns data from being displayed). Change the widths of PRODNAME to 22, AMOUNT to 10, and CUSTNAME to 15, then accept the dialog box. In this report, you need to change the widths of the fields to ensure that they fit in the layout. The next figure illustrates how your report layout should appear.

7.

5 38

Building Reports Manual

Notice how the master/detail default layout creates master records across the page with the labels to the left of their fields, and the detail records below the master records in standard tabular format. 8. 9. Display the property sheet for F_AMOUNT and specify a format mask of NNNN0. Accept the property sheet. Display the property sheet for R_Salesrep, then click in Object:Maximum Records per Page and enter a 1. Accept the property sheet. Specifying a maximum of one record per page tells Oracle Reports to place only one master record on each page. Save and run your report.

Introductory Reports

5 39

Summary Report

Distinguishing Features

A summary report contains at least one column whose value or values consist of a summary of other data. A column that totals sales, a column that averages a list of commissions, and a column that shows the maximum amounts found in a series of purchase orders are all examples of summary columns. This report includes the following summaries:

REP_TOTAL, which computes the total of all orders from all customers for each sales representative PERCENT, which computes the percentage value of each customers orders in relation to each sales representatives total orders CORP_TOTAL, which computes the grand total of all orders in the report Note: In order to display the final summary column CORP_TOTAL, the figure above shows the end portion of the report output.

Concepts

The value or values in a summary column are calculated by summarizing data retrieved from another column. Oracle Reports provides packaged summary functions you can use to compute the values of summary columns.

5 40

Building Reports Manual

By default, the values of a column summarizing data on a recordbyrecord basis appear in a default report column, as in the example above, where Percent displays as a default tabular column. The values of a column summarizing data once per set of information (one summary for each break group in a break report) appear under the column of values it summarizes (Rep Total, above). The result of a column calculating one final result appears once at the bottom of the report (Corp Total, above). Data Relationships The difference between a summary column and the columns in previous introductory reports is that you do not select summary columns from the database. You create the summary columns and add them to groups in your report. To create a summary column, you need to define three properties:

source column function reset level

Source Column

The source column contains the data on which the summary column performs its computations. The source column remains unchanged. Your report can display columns containing both the data being summarized and the summary itself. The function tells Oracle Reports how to compute summary column values. Functions provided with Oracle Reports are Average, Count, First, Last, Maximum, Minimum, % of Total, Standard Deviation, Sum, Variance, and corresponding running functions. (If none of the Oracle Reports summary functions performs the computation you need for your report, you can create your own functions using PL/SQL. For details, see Formula Report on page 5 56.) The reset level, also known as the reset group, determines when to reset the value of the summary column to zeroin other words, how much of the source column to summarize. You can specify that the summary column summarize all values of the source column for the entire report, you can summarize column values in a break group, or you can summarize column values on a recordbyrecord basis. This report uses a master/detail layout style. Youll modify a repeating frame to add space between instances of its occurrence, shorten some field widths, move a label and a field in the Layout editor,. edit a field label, assign some format masks.

Function

Reset Level

Layout

Introductory Reports

5 41

To see a sample summary report, open the Oracle Reports example report named summaryb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

One query selects all of the database columns in this report. Youll create a break group, G_Rep, to break a report into sets of information that can be summarized individually.

Youll also create three summary columns. The first, REP_TOTAL, will belong to the break group G_Rep. The second, PERCENT, will belong to the default group G_Sale. The third column, CORP_TOTAL, will belong to the report as a whole.

Steps to Build this Report

Queries

1.

Create a query named Q_Sales. Click in General:SELECT Statement and enter the following:
SELECT REPID, CUSTOMER.CUSTID, SUM(TOTAL) DOLLARS FROM CUSTOMER, ORD WHERE ORD.CUSTID = CUSTOMER.CUSTID GROUP BY REPID, CUSTOMER.CUSTID ORDER BY REPID, SUM(TOTAL) DESC

Groups

2. 3.

Drag the G_Sales group down about an inch to give yourself more room to create a new group. Drag the REPID column above the G_Sales group to create a new group. Display its property sheet and rename it G_Rep.

5 42

Building Reports Manual

Youve created a new group, G_Rep, with one column, REPID, assigned to it. This creates a break in your report. (If you need to review break reports, see Break Report on page 5 25.) Columns Add the following summaries:

the totals of all customers orders for each sales representative each customers percentage of each sales representatives total the grand total of all orders

4.

Enlarge the G_Rep group by first selecting it, then grabbing one of the lower handles and dragging the bottom edge down until you have enough room for another column. Select the Summary Column tool from the Tool palette and click in the space below REPID. This creates a new column in G_Rep named CS_1. Doubleclick on CS_1 to display the new columns property sheet, and rename the column REP_TOTAL. By creating REP_TOTAL inside the G_Rep group, you have assigned it to G_Rep, and REP_TOTAL will print each time REPID, the other column belonging to the G_Rep group, prints.

Summary Column Tool

5.

6.

Notice that Sum already appears by default in the Function field. Sum is the default function for a summary column. Sum calculates the total of the values in the specified column and is the correct function for this column.

7.

Go to Data/Selection:Source, and examine the possible values. Select DOLLARS. REP_TOTAL will sum the values of the DOLLARS column.

8.

Move the cursor to the Reset At field, and select G_Rep. The value of REP_TOTAL will reset to zero for each new value of the column REPID. This means that REP_TOTAL will sum the values in DOLLARS for each individual sales representative.

9.

Accept the property sheet for REP_TOTAL to return to the Data Model editor. Deselect REP_TOTAL, then again select the Summary Column tool and click under DOLLARS in the G_Sales group. This creates another new summary column, this time belonging to the G_Sales group.

10. Doubleclick on CS_1 to display the property sheet for the new column, and rename it PERCENT.

Introductory Reports

5 43

PERCENT will print each time CUSTID and DOLLARS print. 11. Display the list of values for General:Function and select % of Total. Go to Data/Selection:Source and select DOLLARS. Select a Reset At value of G_Sales. The value of PERCENT will reset to zero after each record in G_Sales. PERCENT will perform its calculation on each individual value in the DOLLARS column, by calculating what percentage that value constitutes of a specific total, determined next. 12. Move to the Compute At field, examine the available values, and select G_Rep. A compute level of G_Rep means that the PERCENT column will base its percentages on the sum of the DOLLARS column for each break group. 13. Accept the property sheet, then deselect PERCENT and again select the Summary Column tool. Click in an empty area of the Data Model editor to create another summary column. Doubleclick on CS_1 to display its property sheet, and rename it CORP_TOTAL. By placing CORP_TOTAL in an empty section of the Layout editor, you have assigned it to the report as a whole. CORP_TOTAL will summarize all values of the source column and display once at the end of the report. 14. Keep Sum as the function, select REP_TOTAL as the source, and make sure Report is the specified reset level. Notice that you could also specify DOLLARS as source for CORP_TOTAL. Default Layout 15. Select Tools>Default Layout... (or the Default Layout tool) to display the Default Layout dialog box. Select Style:Master/Detail. You do not need to specify a master/detail data model to use a master/detail layout. 16. Go to Data/Selection:Label and replace Repid with Sales Rep. This makes the column heading more understandable. 17. Move to the W (Width) field for the DOLLARS column. Change the current value of 40 to 10. Then change the width of REP_TOTAL, PERCENT, and CORP_TOTAL to 10. When generating a default layout, Oracle Reports assigns widths to column fields based on the datatypes and widths of their source columns. In this report, the datatype of DOLLARS is Number and its width is 38, so Oracle Reports assigns the DOLLARS field a width of 40 (including a space for a decimal point and a space for a negative sign, if necessary).

5 44

Building Reports Manual

Oracle Reports assigns the same widths to REP_TOTAL, PERCENT, and CORP_TOTAL, as they are all based on the DOLLARS column. However, if they remain at this width, they will not fit in the layout, so you need to shorten them. You can specify an even shorter value for the field widths but be aware that doing so may truncate column values. 18. Select OK. The default layout appears in the Layout editor (shown in the next figure).

Save and run your report. The output is shown in the next figure.

Introductory Reports

5 45

Scroll through the output until you reach CORP_TOTAL, as in the figure above. Notice that each set of information for a sales representative follows immediately after the previous set, with little space separating them. Also, the dollar amounts and the percentage are not displayed in the proper format. You can improve the readability of your report by modifying the spacing between repeating frames and modifying the DOLLARS, REP_TOTAL, CORP_TOTAL, and PERCENT fields so they display correctly. Repeating Frames 19. Display the property sheet for R_Rep. Click in Object:Spacing:Vertical and enter 0.25 inches. Accept the property sheet. This will place a quarter of an inch between each instance of the R_Rep repeating frame. Layout Editor Once youve inserted spaces between each set of information, you need to add a space between the final value for REP_TOTAL and the value for CORP_TOTAL. In this report, the objects you need to move (the label and field for CORP_TOTAL and the footer frame enclosing them) are at the bottom of the report. You can use Flex mode to move all the objects at once.

Flex Mode On

20. Toggle Flex mode on using the Flex tool in the toolbar. Select the M_Rep_FTR (the footer frame enclosing the CORP_TOTAL field and boilerplate) and drag it down about .5 inch. Click in an open area of the Layout editor. Notice that Flex mode, in conjunction with Confine mode, enabled you to enlarge the group frame while repositioning all objects within the footer. This is because the default mode for the Layout editor is Confine mode. When you drag an object all child objects enclosed by it must stay within the parent.

Flex Mode Off

Toggle Flex mode off. When creating a field for DOLLARS, Oracle Reports based the format on the datatype and specifications for the TOTAL column from the Ord table because the values in DOLLARS were computed using the TOTAL column. The summary columns REP_TOTAL and CORP_TOTAL are both formatted like their source, DOLLARS.

Fields

5 46

Building Reports Manual

To format them as dollar amounts, youll need to modify their format masks. 21. Select F_DOLLARS, F_REP_TOTAL, and F_CORP_TOTAL using the method appropriate to your platform for selecting multiple objects. With all three fields selected, select Tools>Common Properties.... Click in Field:Format Mask and enter a format mask of NNNNN0.00. Accept the property sheet. 22. Doubleclick on the F_PERCENT field and enter a format mask of NN0. Accept the property sheet. Save and run your report.

Introductory Reports

5 47

Related Concepts: Running Summaries

Distinguishing Features

The example report above appears similar to the summary report you just completed. However, there are a few major differences. Notice the PERCENT column. Its values within each sales representatives set of information now add up to 100. There is also a new column, RUN_TOTAL, whose values continually increase through the entire report. These two columns are called running summaries. (Once again, only the end of the report output is shown above to enable you to see CORP_TOTAL.)

Concepts

Each of the summary functions provided by Oracle Reports can also be used to create running summaries. A running summary is like an incremental update of the summary being computed. How often a running summary displays and how many values a running summary summarizes is determined by the group to which you assign it and the reset level you specify.

Data Relationships

You can easily change the report youve just finished to include running summaries. Weve added one running summary and changed one column from a summary to a running summary:

the RUN_TOTAL column provides a running total of values in the DOLLARS column the PERCENT column now displays a running % of total

5 48

Building Reports Manual

To make RUN_TOTAL tally all values of DOLLARS for the entire report, specify a reset level of Report. The value of RUN_TOTAL will never reset to zero. To ensure that it displays in every record, assign RUN_TOTAL to G_Sales, the same group to which DOLLARS is assigned. Changing an existing summary column into its corresponding running summary, as you will for PERCENT, generally requires that you simply change the reset level. For example, to change the PERCENT column into its corresponding running summary, change the reset group for the PERCENT column from G_Sales to G_Rep. Layout For this report youll regenerate a default master/detail layout and modify it as you did for the original report by adding the vertical spacing between repeating frames, moving the CORP_TOTAL field and label, and changing the format masks. To see a sample report with running summaries, open the Oracle Reports example report named runsumrb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Below is the data model for this report.

No change to the data model is required to modify PERCENT into a running summary. RUN_TOTAL will be assigned to the default group, G_Sales.

Introductory Reports

5 49

Steps to Build This Report

1. 2.

Go to the Data Model editor. It should still contain the data model from your previous break report. Doubleclick on PERCENT. Go to Data/Selection:Reset At and change the reset level from G_Sales to G_Rep. Accept the property sheet. Select the Summary Column tool from the Tool palette and click in the G_Sales group below PERCENT. Doubleclick on CS_1 to display the property sheet for the new column and rename it RUN_TOTAL. Specify for the new summary column a function of Sum, a source of DOLLARS, and a reset level of Report. Select Tools>Default Layout... (or the Default Layout tool). Ensure that Master/Detail is still selected. Change the width of RUN_TOTAL to 10 and accept the new layout. Follow the steps you took while building the original summary report to modify the spacing between repeating frames, move CORP_TOTAL, and change the format masks. Include RUN_TOTAL when changing format masks for dollar amounts. Select File>Save As... and save your report under a different name.

Summary Column Tool

3.

4. 5.

6.

7.

Run your report. Notice that the last value of RUN_TOTAL is the same as the value for CORP_TOTAL. RUN_TOTAL is the running summary that corresponds to the summary CORP_TOTAL. They both sum the same values, but RUN_TOTAL shows, step by step, how the sum is reached. Compare the PERCENT column in the figure above with the PERCENT column shown at the beginning of this section. While the values for RUN_TOTAL demonstrate, step by step, how CORP_TOTAL is reached, the values in the PERCENT column now show step by step how all the customer orders for each sales representative add up to 100%.

5 50

Building Reports Manual

Master/Detail/Summary Report

Distinguishing Features

This report consists of master records (Name, at the upper left of the figure above), detail records (Product, Itemtot, and Orderdate, to the upper right), and summary records (Product, and Sum Total). The summary calculates totals for the details under each master record. Notice that the column Product appears twice. With Oracle Reports, you can display columns any number of times.

Concepts
Data Relationships

A master/detail/summary report is a master/detail report that also contains one or more summaries. This report will use two queries to select data from four tables. The master query will select the customer name, while the detail query will select the information associated with the products ordered by each customer. Because the detail query will select data from several tables, youll need to specify joins to link the information in the tables together. Youll drag a column out of the detail group to further group the data. Youll also create a summary column to calculate the item totals.

Introductory Reports

5 51

Layout

The layout for this report is constructed in two parts. The top portion contains the master and detail information, and is created using the default tabular layout. The second portion is constructed by hand in the Layout editor and formats the summary. Youll also resize two groups in the Layout editor to ensure that the new, usercreated bottom portion of the layout is integrated into the top portion, omit some columns from the layout that were queried only to join the tables, and include more space between instances of a repeating frame.

Optional

Youll change a column label generated by Oracle Reports to make it more understandable, shorten two field lengths to ensure the fields fit in the layout, and change the format masks of two of the fields. For more information on Master/Detail reports, see Master/Detail Report on page 5 35. To see a sample Master/Detail/Summary Report, open the Oracle Reports example report named masdtsmb.rdf. For details on how open it, see How to Access Demo Reports on page 4 2.

Organization

Two queries select the data for this report. Three groups are associated with the queries; the master query has only a single default group, while the detail owns two groups, one of which is a usercreated break group. The G_Customer group is the parent of the Q_Item query.

5 52

Building Reports Manual

Steps to Build this Report

Queries

1.

Create a query named Q_Customer. Click in General:SELECT Statement and enter the following:
SELECT CUSTID, NAME FROM CUSTOMER ORDER BY NAME

2.

Create a second query named Q_Item approximately two inches to the right of the Q_Customer query. Give it the following SELECT statement:
SELECT CUSTID, DESCRIP, ITEMTOT, ORDERDATE, ITEM.ORDID FROM ORD, PRODUCT, ITEM WHERE ITEM.ORDID = ORD.ORDID AND ITEM.PRODID = PRODUCT.PRODID ORDER BY CUSTID, DESCRIP, ORDERDATE

Data Link Tool

3.

Select the Data Link tool, clickandhold on the CUSTID column, and drag the mouse pointer over the CUSTID1 column. Release the mouse button. A data link (arrow) appears in the editor. This establishes a master/detail relationship between G_Customer and Q_Item by linking the parent group, G_Customer, and the child query, Q_Item. For each record in the G_Customer group, the Q_Item query will be executed, fetching all related information.

4.

Drag G_Item down about 3 inches to give yourself more room in which to create a new group. Select and drag the CUSTID1 column above G_Item and release the mouse button. Oracle Reports creates a new group around the CUSTID1 column. Display the property sheet for the new group and rename it
G_Product.

5.

Drag the DESCRIP column into group G_Product and below the CUSTID1 column. (You dont have to enlarge G_Product, but you may want to do so, so you can see both columns.) Now the customer ID and the product description will appear in the break group. Note: If you had placed the DESCRIP column above the CUSTID1 column, Oracle Reports would display the product descriptions before the customer IDs in the report output.

Introductory Reports

5 53

6.

Select the Summary Column tool and click in the G_Product group below the existing columns. Display the summary columns property sheet (doubleclick on CS_1), click in General:Name and rename it SUM_TOTAL, go to Data/Selection:Source and select ITEMTOT, then choose a reset level of G_Product. Accept the property sheet. Select Tools>Default Layout... (or the Default Layout tool). Keep Tabular as the default layout style. Go to Data/Selection:Column and deselect the CUSTID, CUSTID1, SUM_TOTAL, and ORDID columns. Change the label for the DESCRIP column to Product. Accept the dialog box. Notice that defining a master/detail relationship for your data does not require you to choose a master/detail format for your report. Deselecting these columns prevents the creation of any corresponding fields in the default layout. The columns CUSTID, CUSTID1, and ORDID were included in your SELECT statements to enable you to join tables and select the necessary information for the report. You do not need to include them in your report. Also, the column SUM_TOTAL will be displayed in the second layout youll create below. You do not need to display it now. Note: Its possible that, on the system youre using, the default layout will not fit in your Layout editor using the prescribed settings. If this happens, select Tools>Default Layout... (or the Default Layout tool) and decrease the width of some of the columnsfor example, change the widths of NAME to 15 and DESCRIP to 20.

7.

Additional Default Layout Tool

8.

Select the Additional Default Layout tool from the Tool Palette. Move to a point about 2 inches across and 1.5 inches down the page. Clickanddrag the mouse down about 2 inches and to the right about 4.5 inches. Release the mouse button. The Default Layout dialog box appears. In the dialog box, go to Data/Selection:Group and deselect both G_Customer and G_Item, leaving only Report and G_Product. Move to the Column section and select only SUM_TOTAL. The DESCRIP column should already be selected. Accept the dialog box to create a second layout beneath the first in the Layout editor. Notice, as you deselect the groups G_Customer and G_Item, that the columns owned by these groups disappear from the Column section of the Default Layout dialog box.

9.

5 54

Building Reports Manual

Layout Editor

Combine the two layouts into one integrated whole by surrounding the new layout with the frame and repeating frame of the first layouts master group. This will cause Oracle Reports to print the product description and summary for each master record. 10. Turn Confine mode off and Flex mode on. Select the R_Customer repeating frame and drag one of its lower handles down until the frame surrounds the product description and summary, including their group frame, header frame, and repeating frame. When you release the mouse button, the resized frames will push the summary information down farther in the layout. Next youll need to move it back. 11. Turn Flex mode off. Select the M_Product_GRPFR1 frame and drag it and its children back up into the R_Customer repeating frame. The figure below shows your Layout editor.

Repeating Frames Fields

12. Display the Repeating Frame property sheet for R_Customer, click in Object:Spacing:Vertical and enter 0.25. 13. Select F_ITEMTOT and F_SUM_TOTAL, then select Tools>Common Properties... to display the Common Properties dialog. Go to Field:Format Mask and enter $NN,NN0.00 so that F_ITEMTOT and F_SUM_TOTAL display as dollar amounts. Save and run your report.

Introductory Reports

5 55

Formula Report

Distinguishing Features

A formula column, like a summary column, is a computational column you create yourself. Unlike a summary, its values are calculated based on a PL/SQL formula you provide. The formula may use data from another column in the report, but is not required to do so. This report includes the following formulas:

TAX, a computation that calculates the tax due for each order SALES_TOTAL, a computation that calculates the sum of the order total plus the tax calculated by the first computation

Concepts

A formula report contains at least one column whose value or values are computed using a PL/SQL formula. Formula columns are similar in usage to summary columns (for more details on summaries, see Summary Report on page 5 40). To create a formula report, create a query and select your data. Next, create additional columns and add them to groups in your report. Specify their formulas in the column property sheets.

Data Relationships

5 56

Building Reports Manual

As with summaries, you do not select formulas from the database. Unlike summaries, which use packaged computations shipped with Oracle Reports, formula columns use formulas you provide by referencing PL/SQL functions. These formulas can be any legal PL/SQL constructs. This allows a great deal of flexibility in the formulas you use. Also, a formula performs computations using data from a single record which can span multiple columns. This is in contrast to a summary, which summarizes the data from multiple records in a single column. Layout Optional This report uses the default tabular format with no modifications. Youll give the two formula columns format masks to ensure that they display as dollar values. To see a sample formula report, open the Oracle Reports example report named formulab.rdf. For details on how to open it, see How to Access Demo Reports, on page 4 2.

Organization

One query selects all necessary database columns. Youll create a break group and two formula columns. The break group is not required for creating formula reports, but it breaks the report into sets of information and makes it easier to read.

Introductory Reports

5 57

Steps to Build this Report

Queries

1.

Create a query object named Q_Custinfo. Click in General:SELECT Statement and enter the following:
SELECT CUSTID, ORDID, TOTAL FROM ORD ORDER BY CUSTID

Accept the property sheet and return to the Data Model editor. Groups 2. Drag the G_Custinfo group down about one inch, then drag the CUSTID column above G_Custinfo to create a new group. Display the new groups property sheet and rename it G_Cust. Select OK to accept the property sheet. Youve now assigned the column CUSTID to the new group, G_CUST. This creates a break in your report. Formula Columns Add two formula columns that calculate the following values:

the tax on each order the grand total for each customer, including tax

Formula Column Tool

3.

Click on the Formula Column tool, then click in the G_Custinfo group below TOTAL. A new column (initially named CF_1) appears in G_Custinfo. Doubleclick on CF_1 to display its property sheet, and change the name of the new column to TAX.

4.

Select Formula:Edit.... The Program Unit editor appears. Modify the template provided in the source text field to include your formula. When you are finished, the formula should appear as follows:
function TAXFormula return Number is tax number; begin tax := :TOTAL * .07; return (tax); end;

5.

Select Compile. If youve typed in the formula correctly, the status line at the bottom of the editor reports, Successfully Compiled. If you made a mistake, the appropriate error message will be displayed. Fix the error, recompile, then select Close. Accept the column property sheet. Deselect TAX.

5 58

Building Reports Manual

6.

Repeat step 3: click on the Formula Column tool, click in the G_Custinfo group below TAX, and doubleclick on the new column to display its property sheet. Name the column SALES_TOTAL. Select Formula:Edit... to display the Program Unit editor and modify the template provided. When you are finished, the formula should appear as follows:
function SALES_TOTALFormula return Number is sales_total number; begin sales_total := :TOTAL + :TAX; return (sales_total); end;

This formula calculates the sales total for each order by adding the order total and the tax due on that order. Close the editor and accept the property sheet. For more information on using PL/SQL with Oracle Reports, see PL/SQL Interface in Chapter 13 of the Reports Reference Manual. Default Layout 7. Select Tools>Default Layout... (or the Default Layout tool). Go to Data/Selection:W and change the widths of TAX and SALES_TOTAL to 10 to match the width of TOTAL, then accept the dialog box. The default layout appears in the Layout editor. The formula columns, TAX and SALES_TOTAL, appear in the layout as default tabular columns.

Run your report. The output for this report is shown below. Notice that the TOTAL, TAX and SALES_TOTAL columns do not display as dollar values.

Introductory Reports

5 59

As previously mentioned, when Oracle Reports generates a default report layout, it formats fields based on the datatype and width of a fields source column. However, when creating fields for the formula columns TAX and SALES_TOTAL, Oracle Reports had no source columns to use. Thus, it did not assign the fields any format masks at all (the default action). Here you will change the format masks of F_TOTAL, F_TAX and F_SALES_TOTAL so they display as dollar amounts, with at least one number before and two numbers after a decimal point. Fields 8. Select F_TAX, F_SALES_TOTAL, and F_TOTAL, then select Tools>Common Properties.... Select Field:Format Mask and give all three columns a format mask of NNNNN0.00. Accept the property sheet.

Save and run your report.

5 60

Building Reports Manual

Across Break Report

Distinguishing Features Concepts

An across report prints the values of a database column across the page instead of down. In this example, DEPTNO, DNAME, and LOC values print top to bottom, while ENAME values print left to right. In across reports with breaks, the master (or break) group prints top to bottom; i.e., as it would in other master/detail reports. However, the values in the detail group print across the page, from left to right. When there are more values than will fit on a line, Oracle Reports wraps the line and prints the remaining values across the page on the next line. The break in this report is created via a data link between a master group and a detail query. To create the layout used in this report, youll select the master/detail layout style, then modify the Print Direction setting for one of the groups to ensure it prints across the page instead of down the page. Youll also modify the vertical spacing setting for a repeating frame to add spaces between sets of information and make the report easier to read, and increase the width of a report page to 11 inches. To see a sample across report with control breaks, open the Oracle Reports example report named acrsscbb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Data Relationships Layout

Organization

This report uses two queries that select all of the columns displayed. Youll link them to establish a master/detail relationship. Oracle Reports creates all other necessary data objects by default.

Introductory Reports

5 61

Steps to Build this Report

Queries

1.

Create the following query named Q_Dept:


SELECT * FROM DEPT

2.

Create the following query, named Q_Emp, about two inches to the right of Q_Dept:
SELECT ENAME, DEPTNO FROM EMP ORDER BY ENAME

Link Q_Emp to its parent group, G_Dept, via parent column DEPTNO and child column DEPTNO1. Default Layout 3. 4. Select Tools>Default Layout... (or the Default Layout tool) and select Style:Master/Detail. Go to Data/Selection:Repeat, and change G_Emp from Down to Across. Then deselect the DEPTNO1 column. Changing the Repeat setting for G_Emp to Across ensures that it prints across the page. Also, both DEPTNO and DEPTNO1 are not necessary. 5. Accept the Default Layout dialog box. Your report layout should look like the figure below.

5 62

Building Reports Manual

Repeating Frames Report Properties

6. 7.

Display R_Depts property sheet, click in Object:Spacing:Vertical and enter 0.25. Go to the Object Navigator. Doubleclick on the Report icon representing your current report to display the Report Properties property sheet. Click in Report:Page Width and enter 11. Accept the property sheet.

Save and run your report.

Introductory Reports

5 63

Wrapped Break Report

Distinguishing Features

This type of break report differs from a simple break report in that the break field is wrapped on word boundaries if it is too long to fit on one line. (Note: What is shown above is not the first page of the report. The display has been scrolled down to show a wrapped field.) This report contains a field which is of a fixed horizontal width but can expand vertically if the contents of the break field are longer than the specified width (for example, North Woods Health..., above). The fields contents are not truncated; rather, the contents will wrap within the specified width of the field and the field will expand vertically. This is a simple, onequery break report. In addition, youll add three summary columns. This is formatted as a master/detail report. Youll modify the layout to add space between sets of information and change the width of a field (this is done to insure that the break field will, indeed, wrap). Youll change the format masks of three fields. Youll also use Page Protect in this report. Page Protect causes all objects within a frame or repeating frame to remain together. By specifying Page Protect for the master repeating frame, the customer name and all of its related records will always appear on the same page. To see a sample wrapped break report, open the Oracle Reports example report named wrpbreab.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Concepts

Data Relationships Layout

Optional

5 64

Building Reports Manual

Organization

This report is organized like a simple break report: one query and two groups, one of which is usercreated. In addition, youll create three summary columns.

Steps to Build this Report

Queries

1.

Create a query named Q_Customer with a SELECT statement of:


SELECT TOTAL, NAME FROM ORD O, CUSTOMER C WHERE O.CUSTID = C.CUSTID ORDER BY NAME

Groups

2.

Drag G_Customer down about an inch, then drag the NAME column out of and above G_Customer to create a new group. Rename the new group G_Name, then accept its property sheet. Using the Summary Column tool, add the following columns:

3.

in G_Customer add the column PCT, with a function of % of Total, a source of TOTAL, a reset level of G_Customer, and a compute level of Report. in G_Name add the column CUST_TOTAL, with a function of Sum, a source of TOTAL, and a reset level of G_Name. in G_Name add the column PCT_TOTAL_SALES, with a function of Sum, a source of PCT, and a reset level of G_Name.

Introductory Reports

5 65

Default Layout

4.

Select Tools>Default Layout... (or the Default Layout tool). Choose Style:Master/Detail, click in Data/Selection:W and change NAME to 15, to force a field to wrap. Select OK. Doubleclick on R_Name (the larger outer repeating frame) to display its property sheet, and change its vertical spacing to 0.25. Go to General Layout:Pagination and select the Page Protect check box. This ensures that all related records formatted within R_Name will always appear on the same page, rather than split across pages. Accept the property sheet. Notice the Page Protect icon that now appears on the border of R_Name, as shown below.

Repeating Frames

5. 6.

7.

Open the F_NAME property sheet and go to General Layout:Sizing. Notice that Vertical Sizing is set to Expand. When you specify the width of a field in the Default Layout dialog box, you are only specifying how wide the field will appear in the report layout. When the Vertical Sizing setting of F_NAME is set to Expand, Oracle Reports will expand the field downward to handle widths of greater than 15 characters. The field will wrap on word boundaries whenever possible.

8.

Use the Common Properties dialog box to give fields F_PCT and F_PCT_TOTAL_SALES format masks of NN0.00%. Next, use the Common Properties dialog box to give fields F_TOTAL and F_CUST_TOTAL format masks of NNNNN0.00.

Save and run your report. When in the Previewer, scroll or page down, as necessary, to see the customer name wordwrapped.

5 66

Building Reports Manual

Header and Footer Report

Distinguishing Features

This report has a page header, Employee Summary, printed in the upper margin area of every page of the report, and a footer , End of Dept. fieldvalue , printed at the end of the list of employee information for each department. A header and footer report contains boilerplate or fields in its header or footer. To create headers and footers in your report, add the boilerplate or field in the Layout editor. If you create a field, make sure there is only one value for it. Otherwise, Oracle Reports will not know which of the different values you want to print. How often the boilerplate and fields appear and whether they are headers or footers depends on where you position them in the layout. Any boilerplate that is positioned within a repeating frame will print once every time the repeating frame prints. Boilerplate that is outside of all repeating frames will print once for the entire report.

Concepts

Data Relationships

This report uses one query to select all necessary columns. Youll add a break by assigning a column to a second group.

Introductory Reports

5 67

Layout

The report uses a default tabular layout with modifications. Youll increase the size of a repeating frame and the frame enclosing it to ensure they are large enough to contain a footer, then add the footer. Then youll modify the vertical spacing of a repeating frame to add space between each instance of it. To see a sample header and footer report, open the Oracle Reports example report named headfoob.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Below is the data model for this report.

Steps to Build this Report

Queries

1.

Create a query named Q_Employee with a SELECT statement of:


SELECT DEPTNO, EMPNO, ENAME, SAL FROM EMP ORDER BY DEPTNO, EMPNO

Groups

2.

Drag G_Employee down an inch or two to give yourself more room, then drag the DEPTNO column out of and above the G_Employee group to create a new group. Rename the group
G_Dept.

5 68

Building Reports Manual

Default Layout Layout Editor

3. 4.

Select Tools>Default Layout... (or the Default Layout tool). Select OK to accept the default settings. Toggle Confine mode off and Flex mode on. Select the R_Dept repeating frame, grab its lower right handle, and drag its corner about .5 inch down and .5 inch to the right to resize both outer frames. (Note: Flex mode does not allow you to resize on the diagonal, so be sure to drag in first one direction, then the other. Also, Flex mode only works on one selected object, so be sure to only select R_Dept.) Enlarging these two objects gives you more room to add the footer text. Move to an open space and click the mouse button to deselect the resized repeating frame.

Line Color Tool

5.

Select the Line Color tool. Display the color palette and select No Line. This ensures that no border appears around the boilerplate text youll create in the next few steps.

Text Tool

6.

Select the Text tool in the Tool palette, then move to a point below R_Employee but still inside R_Dept and enter the following text:
End of Department &F_DEPTNO

Exit text mode and deselect the boilerplate when you finish typing. The R_Dept repeating frame is associated with the group to which the DEPTNO column belongs. Entering the footer text inside of the repeating frame, ensures the footer will print once at the end of every department listing. The F_DEPTNO field already appears in the body of the report itself so you need to reference F_DEPTNO in the footer using &F_DEPTNO.
Margin Tool

7. 8.

Select the Margin tool in the toolbar to display the margin areas of your layout. Select the Text tool. Center the following text in the margin above the report body:
EMPLOYEE SUMMARY

Get out of text mode and deselect the boilerplate when you finish typing. Your report layout, in margin mode, should look similar to the next figure.

Introductory Reports

5 69

Body Tool

9.

Select the Body tool in the toolbar to redisplay the report body.

Repeating Frames

10. Doubleclick on R_Dept (the larger outer repeating frame) to display its property sheet, and in Object:Spacing:Vertical: enter 0.25. Accept the property sheet. 11. Change the format mask for F_SAL to NNNN0.00. Save and run your report.

5 70

Building Reports Manual

Placing Database Values In Page Headings

Distinguishing Features Concepts

In this example report, both the first and last department numbers found on each page are displayed in the page header. In the Header and Footer Report, on page 5 67, the report footer contained a single database value. However, headers and footers can contain more than one database value, while the values can be based on conditions you specify. This report uses one query and two groups. Youll also create two summary columns to provide the values for the header fields. To ensure unique field values for each page, youll compute the values using the First and Last functions. The First function will return the first database value selected for a group, page, or report, and the Last function will return the last database value selected for a group, page, or report. This report uses a default tabular layout, with modifications. Youll specify that no column labels be created for the header fields, then hide the fields themselves and reference them in the header.

Data Relationships

Layout

Introductory Reports

5 71

For more information on hidden fields, see Form Letter Report on page 5 18. Optional Youll shorten the page length to illustrate how the summary fields change, based on database values fetched on each page. To see a sample report with multiple database values in the page headings, open the Oracle Reports example report named headingb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Below is the data model for this report. Youll reassign a column to a break group and create two reportlevel summary columns.

Steps to Build this Report

Queries

1.

Create a query named Q_Detail with a SELECT statement of:


SELECT DEPTNO, ENAME, JOB, SAL FROM EMP ORDER BY DEPTNO, ENAME

Groups

2.

Drag G_Detail down an inch or two to give yourself more room, then drag the DEPTNO column out of and above the G_Detail group to create a new group. Rename the new group G_Deptno.

5 72

Building Reports Manual

Columns

3.

Using the Summary Column tool, create the following summary columns in an open area of the Layout editor:
FIRSTDEPTREC, LASTDEPTREC,

with a function of First, a source of DEPTNO, and a reset level of Page.

with a function of Last, a source of DEPTNO, and a reset level of Page.

You create FIRSTDEPTREC and LASTDEPTREC in an open area of the Layout editor so that they are reportlevel columns; i.e., they will summarize the specified values over the entire report. Default Layout 4. Select Tools>Default Layout... (or the Default Layout tool). Keep Style:Tabular. In Data/Selection:Column, deselect both FIRSTDEPTREC and LASTDEPTREC. Select OK. The default layout appears in the Layout editor. Notice that fields were not created for columns FIRSTDEPTREC and LASTDEPTREC. By deselecting the two columns in the Default Layout dialog box, you prevented column labels and fields from being created for them in the default layout. 5. 6.
Field Tool

Change the format mask of F_SAL to NNNN0.00. Select the Margin tool from the toolbar to show the margins in the Layout editor. In the Layout editor, select the Field tool in the Tool palette and, in the upper left corner of the margin, create a new field named F_FIRSTDEPTREC. Under Object:Source select FIRSTDEPTREC. Check F_FIRSTDEPTRECs Hidden check box, then go to General Layout:Sizing:Horizontal and select Variable. This will keep the field from appearing in the output except where its referenced. It also ensures that, when it does appear, the length of the field used to display FIRSTDEPTREC is determined by the length of the value it displays, and thus will take up only as much space in the layout as necessary.

7.

8.

9.

With FIRSTDEPTREC still selected, select Edit>Duplicate to copy the field. Move the copy to an open area of the margin and display its property sheet. Rename the copy F_LASTDEPTREC and change the source to LASTDEPTREC. Accept the property sheet. Since F_LASTDEPTREC is a copy of F_FIRSTDEPTREC, only the name and source need be changed. All other settings (i.e., Hidden) are copied from F_FIRSTDEPTREC.

Introductory Reports

5 73

10. Select the Line Color tool to display the color grid and select No Line. This ensures that no border will appear around the text youll create next. 11. Select the Text tool, position the cursor about one inch across the page and directly above the report body and type Departments
found on this page: &F_FIRSTDEPTREC through &F_LASTDEPTREC. If necessary, you can increase the size of the

margin to give you more room for the text by selecting the report body and dragging it down about onehalf inch. Get out of text mode and deselect the boilerplate when you finish typing. A field name preceded by an ampersand (for example, &F_FIRSTDEPTREC) references that field in the layout. 12. In the Object Navigator, doubleclick on the report icon representing your report. The Report Properties property sheet appears. Change Page Height to 3.0 inches. Your report layout in margin mode should look similar to the figure below.

Save and run your report. Page through the output to see the values in the page header change dynamically. 13. Return to the Report Properties property sheet and change the page height to a smaller or larger number to see how this affects the values in the page headers. Save and run your report again.

5 74

Building Reports Manual

Graphics, Text, and Color Report

Distinguishing Features

This report contains several visual enhancements added to the default layout. A company logo is imported into the reports margin, while the reports title is displayed in reverse video and set off from the data by a horizontal line. In addition, the data are surrounded by a border, while the master labels and fields are displayed in a different font and text style and set off using bullets. This report shows you how to enhance your reports with graphics by:

Concepts

using the Layout editors drawing tools importing an image highlighting boilerplate text appearing in the output using different colors (if available) and patterns for boilerplate

Introductory Reports

5 75

Data Relationships Layout

This is a onequery break report. This report uses a default master/detail layout which youll modify it in the Layout editor to make room for the title and company logo. Then youll import the logo, create the report title, and add the rest of the graphics shown above. To see a sample report with graphics and highlighted text, open the Oracle Reports example report named graphicb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Youll create one query which selects all the columns for this report. Youll also assign a column to a new break group.

Steps to Build this Report

Queries

1.

Create a query named Q_Employee with a SELECT statement of:


SELECT DEPTNO, ENAME, JOB, SAL FROM EMP ORDER BY DEPTNO

Groups

2.

Create a break group containing the DEPTNO column and rename the new group G_Dept.

5 76

Building Reports Manual

Default Layout

3.

Select Tools>Default Layout... (or the Default Layout tool). Choose Style:Master/Detail. In Data/Selection:Label, change Deptno to Department, Ename to Emp. Name, and Sal to Salary. Accept the dialog box. Verify that Confine mode is on. Select M_Dept_GRPFR (the large outer frame that encloses all other layout objects) and drag it about two inches down and about three inches to the right. All of the group frames child objects move with the group frame. Toggle Flex mode on and Confine mode off. Select R_Dept (the repeating frame immediately inside the M_Dept_GRPFR) and enlarge the two outermost frames about .5 inch on each side. Youll also need a slight gap between them, so toggle Flex mode off and make R_Dept slightly smaller on each side. Enlarging the frames leaves enough room for the coming modifications. Leaving a slight gap between the frames ensures that, when you add a border to the group frame in the next step, the border will not intersect the repeating frame.

Layout Editor

4.

5.

Line Color Tool

6.

Select M_Dept_GRPFR, then select the Line Color tool. Display the color palette and select the solid black square. Next, select Format>Line and choose a line width. Were using the one point line. This give M_Dept_GRPFR a border of the specified width.

7.

Select both Department and the F_DEPTNO field in the R_Dept repeating frame. Use the choices under the Format menu to select a new font, size, and style for the text. Weve chosen 12point italic Arial. Get out of text mode and deselect the boilerplate. The boilerplate is now highlighted. Note: Depending on the method you use to highlight the text, the size of the boilerplate object created to display Department may no longer be large enough, and the label may be truncated. If this happens, enlarge the boilerplate object.

Ellipse Tool

8.

Select the Ellipse tool. Hold down the constrain key (usually the shift key; check your product documentation) and draw a small circle next to the Department boilerplate label. Creating the circle in R_Dept means it will appear in each instance of the repeating frame. This is a quick way to create bullets. Holding down the constrain key as you draw the boilerplate object places the selected tool in a constrained mode, which, in the case of the Ellipse tool, means you can use the tool to draw circles.

Introductory Reports

5 77

Fill Color Tool

The constrained modes of other tools follow a similar paradigm; for example, the constrained mode of the rectangle tool draws squares. For more information on the Layout editor tools and their various modes of operation, see Tool Palette in Chapter 7. 9. Select the Fill Color tool, display the color palette, and give the circle a black fill.

Line Tool

10. Select the Line tool in the Tool palette and draw a line across R_Dept below M_Employee_GRPFR. As you havent changed your line attributes since creating the border for the M_Dept_GRPFR, the new line appears with the same attributes. You can change them using the Format menu. Weve selected a dashed pattern from the choices under Format>Dash. 11. Select the Line tool again, and draw a line across the width of the report page directly above M_Dept_GRPFR. Using the choices under the Format menu, modify its appearance as desired. Weve created a solid, black, four point line. 12. Select the Text tool and type EMPLOYEE LISTING. Center it above your layout. The text will have the same attributes you assigned to the Department boilerplate label and the F_DEPT field. While still in text mode, highlight the text you just typed and use the choices under the Format menu to customize it as desired. We enlarged it two point sizes to 14point type and gave it a weight of Bold. 13. Click once outside the boilerplate to get out of text mode but leave the text object selected. Notice that the object inherited not only the attributes of the last text object you created, but the last two boilerplate objects you drew, as wellin this case, a heavy black border from the black line, and a black fill from the small circle. Select the Line Color tool, display the color palette, and select No Line. The heavy black border disappears. Select the Fill Color tool, display the color palette, and select No Fill. The fill disappears, leaving your text displayed.

Text Color Tool

14. Next, change the color of the text in the selected boilerplate object. Click on the Text Color tool to display the color palette and choose a color for the text. Well use white, but select any color you want. 15. Click outside the text object to deselect it, then select the Ellipse tool again. Create an ellipse over the title you just created. At first, nothing appears; this ellipse has inherited the transparent border and transparent fill you gave the text object. 16. Select the Fill Color tool.

5 78

Building Reports Manual

At this point you have several options. Weve given the ellipse a black fill, but feel free to experiment. If you have a monochrome monitor, you can choose a pattern for the ellipse by selecting Pattern... to display the Fill Pattern palette. To select a pattern for the ellipse, simply click on on of the patterns in the palette. If you have a color monitor, you can select a pattern and specify two colors for the ellipse. Notice the two buttons under the Fill Pattern Palette. Each button displays in one of the colors assigned to the patterns. To change these colors, select one of the buttons to display a secondary color grid, and select the color you want for your pattern. The button, as well as all patterns in the palette, take on that color. Once you have settled on a pattern and color(s), close the Fill Pattern palette. 17. Select Arrange>Send to Back to place the ellipse behind the text. When you are satisfied with the combination, select both objects and select Arrange>Group. Grouping the objects makes Oracle Reports treat them as one object when moving, resizing, etc. Now you can select the text and ellipse as one to center it over your frames. To split the grouped object back into its component parts, select it and choose Arrange>Ungroup from the menu.
Margin Tool

18. Now you can import an image into the report margin. To do so, display the margin using the Margin tool in the toolbar. The Layout editor now displays the report margin. 19. Select Edit>Import>Image... to display the Import Image dialog box. Here you specify the location and format of the item youll import. Notice the defaults. File indicates that you want to import the image from your file system. A value of Any in the Format field indicates that Oracle Reports will interpret the file format of the image you select and display it accordingly. A value of Good in the Quality field indicates the relative quality of the image. You can choose a higher quality image, but be aware the higher the quality, the larger the file. 20. Select Browse.... The Import from File dialog box appears.

Introductory Reports

5 79

21. Change the directory listing to show the files available in the reqfiles directory and enter summitsg.tif in the Import field. Select Import. The company logo is imported into the margin. Resize it to resemble the layout shown below. The image summitsg.tif has now been added to your report definition. It will appear in the report margin even if the original TIFF image is deleted or moved from its current location in the file system.

Repeating Frames
Body Tool

22. Redisplay the report body using the Body tool from the toolbar. Change the vertical spacing for the R_Dept repeating frame to 0.25 inches. 23. Give the F_SAL column a format mask of NNNN0.00. Save and run your report.

5 80

Building Reports Manual

Matrix Report

Distinguishing Features

A matrix report looks like a grid. As shown by the example report above, it contains one row of labels, one column of labels, and information in a grid format that is related to both the row and column labels. (Matrix reports are also referred to as crosstab reports.) Our sample matrix also contains three additions to the basic matrix: zeroes replace nonexistent values in the cells, and summaries have been added. The cells themselves are surrounded by grid lines. Of the summaries, one sums the salaries by department (8750. . .), one sums the salaries by job (6000. . .), and one summary is a grand total of all salaries in the matrix (29025). For more information on how to add the zeroes, see Related Concepts I: Zeroes in Place of Null Values on page 5 88. For more information on how to add summary columns to the basic matrix report, see Related Concepts II: Matrix With Summaries on page 5 90. For more information on how to add the grid, see Related Concepts III: Adding a Grid on page 5 93.

Concepts

Certain requirements exist for building matrix reports:


You must have at least four groups in your data model. One group must be a cross product group. At least two of the groups must be within the cross product group. These groups furnish the labels of the matrix report. At least one group must be a cell group; i.e., it must provide the information related to the labels. The values from this group fill the cells created by the matrix.

Introductory Reports

5 81

These requirements can be seen in the example above. It contains four groupsone group supplies the vertical labels (10, 20, etc.) and one group supplies the horizontal labels (Analyst, Clerk, etc.). These two groups are the children of the third group, called the cross product group, which creates the grid. The fourth group provides the values that fill in the grid. Matrix reports are different from tabular reports because the number of columns is not known in advance; i.e., the number of columns in your report is not determined by the number of columns you specify in your SELECT statement plus the columns you create yourself. The number of columns in your report depends on the number of values contained in the columns providing the horizontal and vertical labels. Thus, the report would automatically be extended if a new job function, called RECEPTIONIST, was added to the underlying data tables. Note: The queries used to select data for these sample matrix reports are not intended as definitive examples of matrix queries. If you are concerned with performance issues, for example, there are alternate methods of querying data that can improve the performance of a matrix report. For more information, see Data Model Suggestions in Chapter 17 of the Reports Reference Manual. Data Relationships You can create matrix reports with any number of queries. The OneQuery Method explains how to create the matrix report using one query. The ThreeQuery Method explains how to create the same report using three queries. These two methods yield the same results. They are presented as options; feel free to try both methods and settle on a favorite. This report uses the matrix layout style. Youll modify some default settings to ensure that the column and row labels display correctly. Youll also modify some field widths to ensure that the fields fit across the page. Youll change the alignment for a field. To see a sample matrix report built using one query, open the Oracle Reports example report named matrx1qb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Layout

Optional

OneQuery Method Organization


This report uses one query and four groups. Youll create three of the groups: the cross product, and the two children of the cross product. The fourth group, created by default for the query, is the child cell group.

5 82

Building Reports Manual

Steps to Build the OneQuery Report

Queries

1.

Create a query named Q_Matrix with a SELECT statement of:


SELECT DEPTNO, JOB, SUM(SAL) FROM EMP GROUP BY DEPTNO, JOB ORDER BY DEPTNO, JOB

Groups

2. 3.

Drag G_Matrix down an inch or two to give yourself more room. Drag the DEPTNO column above and to the left of G_Matrix to create a new group. Rename the new group G_Dept. Drag the JOB column above and to the right of G_Matrix to create a new group. Rename the new group G_Job. Select the Cross Product tool from the Tool palette. Draw a box around G_Dept and G_Job to create the third group. Name this new group G_Cross. G_Cross is the cross product group in the matrix. G_Dept and G_Job are now the child groups of the cross product. G_Matrix, which is not in the cross product, remains a child group below the cross product in the group hierarchy.

CrossProduct Tool

4.

Introductory Reports

5 83

Default Layout

5. 6.

Select Tools>Default Layout... (or the Default Layout tool). Select Style:Matrix. Go to Data/Selection:Repeat and change the setting for G_Job to Across. Delete the labels for all of the columns, and change the width of SUM_SAL to 10. The labels generated by Oracle Reports are unnecessary because the values of DEPTNO and JOB, the two columns belonging to the child groups of the cross product, furnish the labels for your report. G_Dept prints down by default, and furnishes the vertical row of labels. Specifying that G_Job print Across ensures that its values provide the horizontal row of labels. Your report layout should look similar to the figure below.

Save and run your report. Notice that the F_JOB fields (for example, ANALYST) are not quite aligned with the salaries. This is because the default alignment is Left for CHAR fields and Right for NUMBER fields. 7. Select the field F_JOB, then select Format>Alignment. Select Right as the alignment for F_JOB.

Save and run your report.

5 84

Building Reports Manual

It shows a grid of salaries with blank spaces where no values exist and no summaries included. For more information on how to replace the blank spaces with text, see Related Concepts I: Zeroes in Place of NonExistent Values on page 5 88. For more information on how to include summaries in your matrix report, see Related Concepts II: Matrix with Summaries, on page 5 90.

ThreeQuery Method

To see a sample matrix report built using three queries, open the Oracle Reports example report named matrx3qb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2. This report is exactly the same as the onequery matrix report, except that this matrix report uses three queries to retrieve the data.

Organization

Steps to Build the ThreeQuery Report

Queries

1.

Create a query named Q_Dept with a SELECT statement of:


SELECT DISTINCT DEPTNO FROM EMP

2.

To the right of Q_Dept, create a second query named Q_Job with a SELECT statement of:
SELECT DISTINCT JOB FROM EMP

Introductory Reports

5 85

3.

Centered below Q_Dept and Q_Job, create a third query named Q_Matrix with a SELECT statement of:
SELECT DEPTNO, JOB, SUM(SAL) FROM EMP GROUP BY DEPTNO, JOB ORDER BY DEPTNO, JOB

Groups

4.

Select the Cross Product tool in the Tool palette. Draw a box around G_Dept and G_Job to create a new group. Name this new group G_Cross. G_Cross is the cross product group in the matrix. Select the Data Link tool in the Tool palette, then create a link between DEPTNO and DEPTNO1. Select the Data Link tool again and create a second link between JOB and JOB1. Select Tools>Default Layout... (or the Default Layout tool). Select Style:Matrix. In Data/Selection change the repeat setting for G_Job to Across, deselect columns DEPTNO1 and JOB1, delete the labels for all of the columns, and change the width of SUM_SAL to 10. Accept the dialog box. The labels generated by Oracle Reports are unnecessary because the values of DEPTNO and JOB furnish the labels for your report. G_Dept prints down by default, and furnishes the vertical row of labels. You specify that G_Job prints Across so that its values provide the horizontal row of labels. Your report layout should look similar to the figure below.

5.

Default Layout

6. 7.

8.

Select the field F_JOB, then select Format>Alignment. Select Right as the alignment for F_JOB.

Save and run your report. The report output is shown in the figure below.

5 86

Building Reports Manual

It shows a grid of salaries with blank spaces where no values exist and no summaries included. Replacing the blank spaces with text is explained below in Related Concepts I: Zeroes in Place of NonExistent Values. For more information on how to include summaries in your matrix report, see Related Concepts II: Matrix with Summaries, on page 5 90. For more information on how to create a visible grid surrounding the matrix cells, see Related Concepts III: Adding a Grid on page 5 93.

Introductory Reports

5 87

Related Concepts I: Zeroes in Place of NonExistent Values

Distinguishing Features

The example report above displays the same matrix as in the one and threequery matrix reports you just built. However, this report fills in the holes in the matrixi.e., it inserts zeroes in the matrix cells which do not contain values. A matrix report displays a juxtaposition of datain other words, the values held in common by two different categories of data. These categories are indicated by the row and column labels. The matrix displays this juxtaposition of values using a gridlike format. If the two categories have nothing in common, the grid at that point is empty. The matrix appears to be full of holes. You can fill the holes using boilerplate text. Note: Do not confuse empty spaces in the grid with null values. A null value is an actual value fetched from the database. The spaces in a matrix report are empty because nothing has been fetched to fill them.

Concepts

Data Relationships Layout

This report has the same data model as your onequery matrix report. For this report youll modify the layout from your basic matrix report by creating a piece of boilerplate text containing a 0 (zero) to fill in the holes in the matrix. To see a sample matrix report with zeroes in place of null values, open the Oracle Reports example report named mtrxnllb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

To see the data model for this report, refer to OneQuery Method on page 5 82. Note: You can also use this technique for the threequery matrix.

5 88

Building Reports Manual

Steps to Build This Report

Layout Editor

1.

Open the onequery matrix report and go to the Layout editor. Select the Text tool. Click the mouse button to position the cursor directly on top of the F_SUM_SAL field. Type 0 (zero). Click once on an empty portion of the editor to get out of text mode but leave the new piece of boilerplate selected. Select the Line Color tool and select No Line to prevent borders from being created around the zeroes. If necessary, use the mouse to drag the piece of boilerplate into the desired position in relation to F_SUM_SAL (i.e., center it, position it flush right, etc.). Click once in an empty area of the Layout editor to deselect the boilerplate. Select both F_SUM_SAL and the R_Matrix repeating frame, then select Arrange>Move Forward. (Hint: Use the Magnify tool to enlarge hardtosee objects.) This moves both F_SUM_SAL and the R_Matrix repeating frame in front of the piece of boilerplate. If you place the boilerplate behind only F_SUM_SAL, the zero will still be above (i.e., a child of) the R_Matrix repeating frame. If no values are fetched, R_Matrix will not appear. Because it is dependent upon R_Matrix, the boilerplate will not appear either. Examine the layout objects carefully. Since the default fill for Oracle Reportscreated objects is transparent the zero is probably still visible behind both the F_SUM_SAL field and the R_Matrix repeating frame. Run the report and you can see the zero, even when the F_SUM_SAL field contains a value. To remedy this, you can give an opaque fill to either of the layout objects above the zero. Well give R_Matrix an opaque fill.

2.

3.

Magnify Tool

4.

5.

Select the R_Matrix repeating frame. Select the Fill Color tool to display the color palette, then select the white fill. A white fill will hide the boilerplate behind the repeating frame.

6.

Select File>Save As... and save your report under a new name.

Run your report. Notice the appearance of zeroes in the matrix. A zero has actually been placed in every square in the grid. In the squares where SUM_SAL appears, the zeroes are hidden beneath an instance of the R_Matrix repeating frame. Where the zeroes appear, no values for SUM_SAL exist, and thus no instance of the R_Matrix repeating frame has been created.

Introductory Reports

5 89

Related Concepts II Matrix With Summaries

Distinguishing Features

The example report above displays the same matrix as the one and threequery matrix reports you just built. However, this report also contains summaries: a column summing salaries by department (across), a column summing salaries by job (down), and a reportlevel summary that computes a grand total. Your matrix report can include summary columns that sum values in both the columns printing down and the columns printing across. You can also include a summary column that computes the grand total of the report (the value shown in the lower right corner above). However, summaries in a matrix report are slightly different than summaries in reports using other layout styles. Any summary you include in a cross product group will count all of the values within the cross product unless you restrict them using a Product Order setting. The product Order tells Oracle Reports which groups to evaluate when computing a summary, and in what order.

Concepts

Data Relationships

For this report youll add three summary columns to your existing matrixtwo within the cross product group, and one reportlevel summary to computes a grand total for the entire matrix. For this report youll select a matrix layout style, change the widths of the new columns, and delete their labels. To see a sample matrix report with summary columns, open the Oracle Reports example report named mtrxsm1b.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Layout

Organization

Below is the onequery data model for this report. Notice how the summary columns, SUM_DEPT and SUM_JOB, are inside the G_Cross cross product group.

5 90

Building Reports Manual

Note: The summaries for a threequery matrix report would also appear in the cross product group.

Steps to Build This Report


Data Model Editor 1. In the Data Model editor., select the Summary Column tool from the Tool palette, click in the bar that extends horizontally across the top of the G_Cross group and contains the name G_Cross (you must click in this title bar), display the property sheet of the new column, and specify the following:

for SUM_DEPT, specify a function of Sum, a source of SUM_SAL, a reset level of G_Dept, and a product order of G_Dept for SUM_JOB, specify a function of Sum, a source of SUM_SAL, a reset level of G_Job, and a product order of G_Job

Note: Specify the same settings for the summary columns in both the onequery and threequery versions of the matrix report.

Introductory Reports

5 91

Notice the Product Order setting. This is required for summary columns belonging to the cross product. The Product Order tells Oracle Reports which groups to evaluate when computing a summary and in what order. In other words, you specify a Product Order of G_Dept for SUM_DEPT so the summary will include only the values for each department in the matrix, and a Product Order of G_Job for SUM_JOB so the summary will include only the values per job. 2. Select the Summary Column tool, click in an empty area of the Layout editor, display the new columns property sheet, and create SUM_TOTAL. Include a function of Sum, a source of SUM_SAL, and a reset level of Report. A value for Product Order is not necessary, as you are not assigning the column to the cross product group. Return to the Object Navigator and doubleclick on the report icon representing the current report to display the Report Properties property sheet. Change Report:Page Width to 9.5 inches. Accept the property sheet. This is a good precaution to take because adding SUM_DEPT may increase the width of your report beyond the default page width. 4. Select Tools>Default Layout... (or select the Default Layout tool) and specify Style:Matrix. Delete the new column labels and change the widths of the new columns to 10. Accept the Default Layout dialog box. Redefaulting the layout has caused you to lose the boilerplate 0 (zero). Select the Text tool, type 0 directly over the F_SUM_SAL field, and move the field and repeating frame forward. Then give R_Matrix an opaque white fill and change the alignment of F_JOB to Right. 5. Select File>Save As... and save your report under a new name.

3.

Run your report.

5 92

Building Reports Manual

Related Concepts III: Adding a Grid

Distinguishing Features Concepts

This report continues to build on the simple Matrix Report discussed previously; to the matrix, summaries, and zeroes replacing null values, a grid overlaying the numerical output has been added. Adding a grid to a matrix is a simple matter of selecting the matrix object and specifying a border for it. The matrix object, since it appears at each intersection of the across and down dimensions, will actually print as a series of rectangles. Taken together, they appear as a grid. There is no change to the data. For this report, youll select a matrix object and specify a border for it. To see a sample matrix report with a grid, open the Oracle Reports example report named matgridb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Data Relationships Layout

Organization Steps to Build this Report

The data model has no bearing on this report.

Object Navigator

1.

In the Object Navigator, select Navigator>Navigator Options... to display the Object Navigator Options dialog box. Go to the Layout tab and deselect the View by Structure checkbox. Accept the dialog box. The Object Navigator Options dialog box enables you to customize the way Oracle Reports presents the list of report objects. You can have the Object Navigator display both data and layout objects either by hierarchical structure (the default) or by type of object.

Introductory Reports

5 93

In this instance, you need to find X_Cross, a matrix object. Therefore, you need to view the layout nodes by object, not by structure. 2. Expand the Layout heading node (click on the plus sign). Heading nodes prefixed with an enabled plus sign can be expanded to show a deeper level of report objects. 3. Scroll down until you see the Matrix heading node. Click on the plus sign next to it. The node expands to show a list of the matrix objects in the report. Click on the X_Cross node to select it. Note: A new matrix object is created for each intersection of an across and down dimension. In addition, multiple matrix objects are created based on the hierarchy of dimensions. If your matrix report contains more than one intersection of across and down dimensions, be sure to select the correct matrix object. 4. Selecting a node in the Object Navigator selects the corresponding object in the appropriate painter. Therefore, the X_Cross matrix object is now selected. Select the Line Color tool to display the line color palette and make the border of the matrix object black. A matrix object is a specialized type of frame that repeats for each instance of an intersection between the across and down dimensions. You can assign a border to it. In addition, if you have a color display, you can choose a color for the border. Save and run your report. Notice that the grid does not extend to the sums. These are not included in the matrix object. If you want to enclose the sums in the grid, simply the across and down repeating frames R_Dept and R_Job and make their borders black. Be aware, though, that the grid will include not only the sums, but the column and row headers, as well. In addition, any reportlevel sum, such as SUM_TOTAL, is not contained by any repeating frame, and will not be in the grid.

5 94

Building Reports Manual

CHAPTER

Advanced Reports
his chapter contains the distinguishing features, concepts, organization, and building steps for each of the following advanced reports:

time series calculations 6 3 aggregating data within ranges 6 6 renumbering pages by repeating frame 6 9 anchors report 6 14 intermixing fields from different repeating frames 6 20 check printing report 6 23 spelling out cash amounts 6 27 printing reports on preprinted forms 6 30 invoice report 6 35 PL/SQL report 6 41 ranking report 6 47 suppressing labels when no detail records are retrieved 6 53 advanced mailing label report (with Oracle Graphics) 6 57 mailing reports to multiple users 6 61 conditional form letter report 6 66 conditional highlighting report 6 71

Advanced Reports

61

static graphics report 6 76 dynamic graphics report 6 81 nested matrix report 6 89 matrix break report 6 97 matrix with summaries report 6 100 data file report 6 104

How to Use this Chapter

You can use this chapter in one of three ways:


Build any single report in this chapter. Build all of the reports in this chapter. This is an excellent way to become familiar with a wide variety of Oracle Reports advanced features. Note: This chapter assumes that you have gained some familiarity with building reports using Oracle Reports. Instructions for accomplishing common tasks are not provided. In addition, the icons representing the tools in the tool palettes are only shown twice.

Refer to one or several reports that contain features you would like to include in one of your own reports, and use the steps listed to guide you in the creation of your own reports.

62

Building Reports Manual

Time Series Calculations Report

Distinguishing Features Concepts

In this example, a fourmonth average of purchases for each customer is computed and displayed. Reports with time series calculations calculate values over a specified period of time. The techniques described for this report can be used to produce other formats of time series calculations as well. This time series calculations report uses a query that will compute fourmonth moving averages of customer purchases. The SELECT statement will sum the current purchase (TOTAL) with purchases made by that customer in the previous four months and then average that sum through use of a selfjoin. For example, if the date queried is 30JUL86, Oracle Reports will average all purchases the customer made between 30MAR86 and 30JUL86. This report uses the default tabular layout style. To see a sample time series calculations report, open the Oracle Reports example report named timeserb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Data Relationships

Layout

Organization

The next figure shows the data model for this report.

Advanced Reports

63

Steps to Build this Report

Queries

1.

Create a query named Q_MovingAvg with a SELECT statement of:


SELECT O.CUSTID, O.SHIPDATE, O.TOTAL, AVG(A.TOTAL) MAVG FROM ORD O, ORD A WHERE A.CUSTID = O.CUSTID AND A.SHIPDATE BETWEEN O.SHIPDATE 123 AND O.SHIPDATE GROUP BY O.CUSTID, O.SHIPDATE, O.TOTAL

Groups

2. 3.

Above G_MovingAvg, create a new group, G_Customer, containing the CUSTID column. In the Default Layout dialog box, go to the Data/Selection tab. Change the label for MAVG to 4Month Moving Average, and change its width to 10. Accept the dialog box. The figure below show the layout for your report.

Default Layout

64

Building Reports Manual

Fields

4.

Select both F_TOTAL and F_MAVG and use the Common Properties dialog to give them format masks of $NN,NN0.00. Save and run your report. Notice that the values for CUSTID are rightjustified, while the values for SHIPDATE are leftjustified. Also, some of the values for TOTAL are long enough that they take up almost the full field width. You can improve the readability by using a preference to increase the spacing between fields.

Preferences

5.

Select Tools>Tools Options... and in Preferences:Default Layout, change the value of Horizontal Interfield to 4. This setting, and the similar settings Vertical Interfield, Horizontal Gap, and Vertical Gap, govern spacing between layout objects. The distance between fields and layout objects in a report is measured in characters, and is dependent on the default font. Thus, changing the value of Horizontal Interfield from 2 to 4 increases the space between each field (measured across the page) from two characters to four. Changing the value for Vertical Interfield would adjust the spacing between fields measured down the page, and changing the values for Vertical and Horizontal Gap would adjust the spacing between all frames. The new settings are saved with your report layout, but will not apply to your next report unless you save them in a preferences file.

6.

The changed preference will not be visible until you redefault the layout. Then reenter the format masks for F_TOTAL and F_MAVG.

Save and run your report.

Advanced Reports

65

Aggregating Data within Ranges

Distinguishing Features

The report above fetches and displays data based on an aggregate range of increments of one thousand starting at zero; i.e., it collects and displays the names of all employees whose salaries fall within the range of 0 to 999, then it collects and displays all employees whose salaries fall within the range of 1000 to 1999, etc. You can specify any aggregate range you need. In a report that aggregates, or collects, data within ranges, values from the database are retrieved and formatted based on an aggregate range that you define. You can even use parameters to specify the range over which the data should be collected. This report uses two functions in its SELECT statement to specify the aggregate range. The functions are (FLOOR ((SAL + 1)/1000) * 1000), which calculates the lowest salary, and (CEIL ((SAL + 1)/1000)*1000 1), which calculates the highest salary. The columns that receive the values of these functions are placed into a break group to produce the control break format of the report shown above. This report uses the default tabular layout style. To see a sample report that aggregates data within ranges, open the Oracle Reports example report named aggregab.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Concepts

Data Relationships

Layout

66

Building Reports Manual

Organization

Below is the data model for this report.

Steps to Build this Report

Queries

1.

Create a query named Q_Aggregate with a SELECT statement of:


SELECT FLOOR((SAL + 1)/1000) * 1000 BOTTOM, CEIL ((SAL + 1)/1000)*1000 1 TOP, ENAME, DEPTNO FROM EMP ORDER BY 1, 2, SAL

Groups Default Layout

2. 3.

Create a new group named G_SalRanges above G_Aggregate, using the columns BOTTOM and TOP. In the Default Layout dialog box, go to the Data/Selection tab, change the label for BOTTOM to Salary Range and delete the label for TOP. Change the widths of BOTTOM and TOP to 5. Accept the dialog box to create the default layout in the Layout editor. Select the Text tool, and type a hyphen () between the fields F_BOTTOM and F_TOP. Get out of text mode.

Layout Editor

4.

Advanced Reports

67

5.

With the hyphen still selected, select the Line Color tool and display the color palette. Select No Line. This prevents a border from appearing around the hyphen. Select and move the F_BOTTOM and F_TOP fields and the hyphen (use the method appropriate to your platform to select multiple objects) until they are positioned below the Salary Range label. The figure below shows how your report layout should appear.

6.

Fields

7.

Change the alignment of the F_BOTTOM field to Left, and use the Common Properties dialog to give F_BOTTOM and F_TOP format masks of NNN0.

Save and run your report.

68

Building Reports Manual

Renumbering Pages By Repeating Frame

Distinguishing Features

This report uses two page numbers for each page. The first number corresponds to the current page for each parent record (i.e., each sales representative). This page number is reset to 1 for each sales representative, thus tracking the statistics of each representative separately. The second number is the total pages required to display the customer information for each sales representative. This field is also reset with each new parent record.

Concepts

The Page Numbering dialog box enables you to specify that the page number either reset at a particular repeating frame or increment over the entire report. However, if you decide to use a page total that repeats on several pages, as with the second number in the example report, you need to be aware of certain rules that apply when formatting a field that contains a count of other objects. To be able to display such a value, called a pagedependent reference, on the first pageor any page prior to the final pageof the report, Oracle Reports must format the field that will contain the value before it knows the value. As a result, any field displaying a value of this type must be fixed, so that Oracle Reports knows how much space to reserve for it when formatting the report. Even if you specify a horizontal or vertical sizing of Expand, Contract, or Variable for such a field, Oracle Reports considers it fixed.

Advanced Reports

69

When you create a such a field, you must ensure that it is large enough to contain the value. An alternative is to hide the field and reference it from a piece of boilerplate. When using this method the field can be variable, but the boilerplate remains fixed, so be sure to create a boilerplate object of sufficient size to hold the field. Some values that are treated in this fashion by Oracle Reports are &TOTAL LOGICAL PAGES, &TOTAL PANELS, and &TOTAL PHYSICAL PAGES, and any summaries or formulas that reference them. Summaries with either a compute level or reset level of Page and formulas that reference them are also considered pagedependent references. For a complete list of such values and a comprehensive discussion of Oracle Reports treatment of them, see Vertical Sizing in Chapter 8 of the Reports Reference Manual. Data Relationships This report contains both a master/detail relationship and a break. This results in two levels of data differentiation. The top level (the break) will determine when page numbers reset. This report uses the master/detail layout style, with modifications. In addition, youll create two hidden fields for the page numbers, then reference them in a piece of boilerplate. This will ensure the field displaying the total number of pages is the proper size. Then youll check the Maximum Records Per Page setting for the break groups repeating frame to ensure that your pages are numbered correctly. To see a sample report that renumbers pages by repeating frame, open the Oracle Reports example report named renumbrb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Layout

Organization

The next figure shows the data model for this report.

6 10

Building Reports Manual

Steps to Build This Report

Queries

1.

Create a query named Q_Customer with a SELECT statement of:


SELECT ENAME, REPID, CUSTID, NAME, ADDRESS, CITY || , || STATE || || ZIP LOCATION, AREA || || PHONE, CREDITLIMIT FROM EMP, CUSTOMER WHERE EMPNO = REPID ORDER BY REPID

2.

Create a second query named Q_Sales with a SELECT statement of:


SELECT CUSTID, PRODNAME, AMOUNT FROM SALES ORDER BY CUSTID

Link Q_Sales to its parent group, G_Customer, via CUSTID and CUSTID1. Groups Default Layout 3. 4. Above G_Customer, create a new group named G_Employee that contains the columns ENAME and REPID. Select Master/Detail as the default layout style, then go to the Data/Selection tab. Deselect CUSTID and CUSTID1, and change AREA_PHONEs label to Phone#. Make the following width changes:

Advanced Reports

6 11

Column NAME ADDRESS LOCATION AREA_PHONE AMOUNT

Width 30 30 30 15 11

Accept the dialog box to create the default layout. Layout Editor
Field Tool

5. 6. 7.

Select the Margin tool from the toolbar to show the margin areas of your report layout. Select the Field tool from the Tool palette and draw a field about two characters long in the center of your margin. Rename the field F_TOTAL_PAGENO. Go to Object:Source and display the list of values. Choose &Total Logical Pages. Next, under Display, check the Hidden checkbox. Go to General Layout:Sizing and make its horizontal sizing Variable. Hiding both this field and the field youll create below ensures that theyll appear only where you reference them. Changing the horizontal sizing to Variable ensures that the fields can expand to accommodate large page ranges.

8. 9.

Go to Object:Display and select Page Numbering... to display the Page Numbering dialog box. Select a reset level of R_Employee. This states that F_PAGENO should reset for each new sales representative. Accept the dialog box and property sheet.

10. The F_PAGENO field should still be selected. Select Edit>Duplicate. A new field with the same dimensions as F_PAGENO is created next to F_PAGENO. Drag the new field named F_PAGENO1 to an open portion of the margin. 11. Rename it F_PAGENO and select as its source &Logical Page Number. As it is a duplicate of F_TOTAL_PAGENO, its horizontal sizing should be Variable and its Hidden checkbox checked. 12. Select Page Numbering... to display the Page Numbering dialog box. Make sure R_Employee is selected as the reset level. Accept the dialog box and property sheet.

6 12

Building Reports Manual

13. Select the Line Color tool, then display the color palette and select No Line. Next, select the Text tool in the Tool palette. Starting about a halfway down the margin and above the last fifth of the layout (shown in the body of the report below the margin), type Page &F_PAGENO of &F_TOTAL_PAGENO. In the report output, the current page number will appear where you reference the field F_PAGENO, while the total number of pages for each master will appear where you reference the field F_TOTAL_PAGENO. If you wish, you can select the new piece of boilerplate and lengthen it a little more. This will ensure that no values for F_TOTAL_PAGENO get truncated. Report Properties 14. Change Page Height to 5.8 inches. Your report layout (including the margin area) should look similar to the figure shown below.

Repeating Frames

15. Redisplay the body of the report, then open the property sheet for R_Customer. Change R_Customers vertical spacing to 0.25. Go to General Layout:Pagination and select the Page Protect checkbox. 16. Display the property sheet for R_Employee and change Maximum Records per Page to 1. This causes each sales representatives customer information to begin on a new page.

Fields

17. Use the Common Properties dialog to change the format masks of F_CREDITLIMIT and F_AMOUNT to $NN,NN0.00. Save and run your report.

Advanced Reports

6 13

Anchors Report

Distinguishing Features

This report displays order information for each customer, per sales representative. The Summit Sporting Goods logo will always appear centered beside the order information. The credit limit of each customer appears next to the sum of that customers orders. The locations of these objects are set by anchors. Anchors determine the relative positioning of all objects in the output of a report. They attach one layout object to another by defining the vertical and horizontal positioning of the first (known as a child) relative to the second (known as the parent). Oracle Reports uses implicit anchors to anchor all objects created in the Layout editor. In addition, you can create explicit anchors to override an objects implicit anchoring and determine how you want your output to format. One way of using anchors is to explicitly anchor a field or piece of boilerplate to an expanding objectfor example, a group frame or repeating frame. Another way of using anchors is to anchor a field outside of a repeating frame to a field within the repeating frame, or to the repeating frame itself. This enables you to format the field as if it were positioned within the repeating frame.

Concepts

6 14

Building Reports Manual

For this report, youll create anchors that use both methods. Data Relationships Layout This report contains both a master/detail relationship and a break. Youll also create a summary computation that sums customer orders. This report uses a master/detail layout style. Youll link to a piece of external boilerplate (an external TIFF image), then anchor the boilerplate to the edge of a vertically expanding repeating frame. Left to its own defaults, Oracle Reports will print the sum of all customer orders at the bottom of the AMOUNT column. However, to quickly compare each customers credit limit to the sum, you want the credit limit to print just to the right of the sum. Your second anchor will explicitly anchor the edge of the credit limit field to the edge of the sum field. To see a sample anchors report, open the Oracle Reports example report named anchorsb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Below is the data model for this report.

Advanced Reports

6 15

Steps to Build this Report

Queries

1.

Create a query named Q_Customer with a SELECT statement of:


SELECT ENAME, REPID, NAME, AREA || || PHONE, CREDITLIMIT, COMMENTS FROM EMP, CUSTOMER WHERE EMPNO=REPID ORDER BY REPID, NAME

2.

To the right of Q_Customer, create a second query named Q_Sales with a SELECT statement of:
SELECT REPID, CUSTNAME, PRODID, AMOUNT FROM SALES ORDER BY REPID, CUSTNAME, PRODID

Link Q_Sales to its parent group, G_Customer, via two links: one between REPID and REPID1, the other between NAME and CUSTNAME. Groups Columns Default Layout 3. 4. 5. Drag ENAME above G_Customer to create a new group. Name it
G_Rep.

Add a summary named TOTAL to G_Customer. Give it a function of Sum, a source of AMOUNT, and a reset level of G_Customer. Select Master/Detail as the default layout style, deselect REPID, REPID1 and CUSTNAME, change the label of AREA_PHONE to Phone # and the label of COMMENTS to Comments:, delete the label for CREDITLIMIT, and change the following widths: Column Name NAME AREA_PHONE COMMENTS TOTAL AMOUNT Width 45 30 30 12 11

Accept the default layout dialog box to create the default layout. Layout Editor 6. Toggle Confine mode off and Flex mode on. Select R_Customer (the repeating frame around the customer information) and pull its bottom edge down to make a rectangle of about 6.5 inches high.

6 16

Building Reports Manual

This also enlarges the M_Customer_GRPFR frame, the R_Rep repeating frame, and the M_Rep_GRPFR frame. (Note: Only select R_Customer. Flex mode only works with a single selected object.) 7. Toggle Confine mode on and Flex mode off. Select the M_Sales_GRPFR frame (the smaller group frame around the sales information). Move the frame, and thus all of the objects within the frame, so that the upperleft corner of the group frame is located about halfway across M_Rep_GRPFR and about two inches down. Select the Link File tool in the Tool palette. Starting just within the left edge of the R_Customer repeating frame and about 1.5 inches down the page, create a rectangular boilerplate object about 2.5 by 2.25 inches. The lower portion of the boilerplate object should be to the left of the M_Sales_GRPFR. 9. Open the property sheet for the boilerplate object and rename it B_LOGO. Notice that fields for file name and format are automatically provided. When you create a piece of boilerplate using the Link File tool, Oracle Reports automatically knows that the object will link to text, a drawing, or an image created outside of Oracle Reports and stored in either a database or file. 10. Select List... to display the File dialog box. Change the directory list to show the images directory and select summitsg.tif. Accept the dialog box. 11. Select a format of Image from the list of values. Format defines the type of file to which youre linkingwhether its a CGM file, an image, an object in Oracle drawing format, or a text file. Accept the property sheet.
Anchor Tool

Link File Tool

8.

12. Select the Anchor tool. Draw an anchor from the middle of the right edge of B_LOGO to the middle of the left edge of R_Sales. (Click once on the right edge of B_LOGO, then doubleclick on the left edge of R_Sales to position the end of the anchor.) This creates an anchor from the child object, B_LOGO, to the parent object, R_Sales. The position of R_Sales will now determine the position of B_LOGO when the report is run.

Magnify Tool

Hint: Use the Magnify tool to enlarge hardtosee objects. To use the Magnify tool, select it, then click in the Layout editor.

Advanced Reports

6 17

13. If necessary, modify the placement of the anchor. Doubleclick on the midpoint of the anchor to display its property sheet. For the child, B_LOGO, verify that the right edge is selected, and enter 50 in the % (Percentage) field. For R_Sales, the parent, ensure the left edge is selected and enter 50 in the % field. 14. Toggle Confine mode off. Drag F_CREDITLIMIT from its default position and place it just to the right of F_TOTAL, outside of M_Sales_GRPFR but still within R_Customer. Toggle Confine mode on. 15. Select the Anchor tool again, then draw an anchor from the middle of the left edge of F_CREDITLIMIT (the child) to the middle of the right edge of F_TOTAL (the parent). Now the location of F_TOTAL determines the location of F_CREDITLIMIT.
Reshaping Tool

Once again, ensure the anchor endpoints are in the proper position. You can use the property sheet again, or use the tool, called the Reshaping tool, that Oracle Reports provides for this purpose. For information about how to use the Reshaping tool, see Tool Palette in Chapter 7 of the Reports Reference Manual.. 16. Use the Line Color tool to make B_LOGOs border transparent.

Frames

17. Select M_Sales_GRPFR and enlarge it to enclose B_LOGO as well as the detail objects it already encloses. Then, display M_Sales_GRPFRs property sheet and change its horizontal sizing to Variable. When you anchor B_LOGO to R_Sales, you need to ensure that the object that encloses R_Sales (namely, M_Sales_GRPFR) can expand enough to enclose the objects within it, as well as any objects anchored to its children. By resizing M_Sales_GRPFR and changing its horizontal sizing to Variable, you ensure that the group frame will enclose both its children and the anchored object, B_LOGO. 18. Display M_Sales_FTRs property sheet and change its horizontal sizing to Variable. Again, changing this setting enables the footer frame to expand horizontally, thus enclosing not only F_TOTAL and its boilerplate label, but also F_CREDITLIMITthe field anchored to F_TOTAL. Your report layout should appear as shown in the next figure.

6 18

Building Reports Manual

Repeating Frames

19. Display the property sheets for R_Rep (the largest repeating frame) and R_Customer (the next largest repeating frame) and activate Page Protect on both. Also, change the vertical spacing of R_Customer to 0.25 inches, and change the value of Maximum Records per Page for R_Rep to 1. 20. Use the Common Properties dialog to change the format masks of F_AMOUNT and F_CREDITLIMIT to $NN,NN0.00. Then display the F_TOTAL property sheet and change its format mask to
$NNN,NN0.00.

Fields

Save and run your report.

Advanced Reports

6 19

Intermixing Fields from Different Repeating Frames

Distinguishing Features Concepts

Normally, a break field appears to the left of related fields. In this example, the break field appears between its related fields. To create this type of report you need to move a field of one repeating frame between two fields in their own repeating frames. Move the two fields out of the way and reduce the size of one of the repeating frames (Step 2 below). Then switch the positions of two of the fields, and create a third repeating frame.

Data Relationships Layout

This is a simple onequery report with a break. This report uses a tabular layout style. To see a sample report intermixing fields, open the Oracle Reports example report named intermxb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

6 20

Building Reports Manual

Organization

Below is the data model for this report.

Steps to Build this Report

Queries

1.

Create one query named Q_DeptSal with a SELECT statement of:


SELECT ENAME, SAL, DNAME FROM EMP, DEPT WHERE EMP.DEPTNO = DEPT.DEPTNO ORDER BY DNAME, ENAME

Groups Default Layout Layout Editor

2. 3. 4.

Above G_DeptSal, create a group named G_Department that contains column DNAME. Accept the default layout settings to create a tabular layout. In the Layout editor, toggle off Confine mode. Select the F_ENAME field, its boilerplate label (B_ENAME), and the line below the label (B_ENAME1). Drag the objects out of the way so you can rearrange the remaining layout objects within the break groups frame. Hint: Use the Magnify tool to enlarge hardtosee layout objects.

Magnify Tool

5.

One at a time, select the following objectsR_DeptSal repeating frame, M_DeptSal_HDR frame, M_DeptSal_GRPFR frameand

Advanced Reports

6 21

resize each of the selected objects to enclose only the F_SAL field and its label.
Frame Select Tool

6.

Select the Frame Select tool in the Tool palette, then click on the M_Department_HDR frame. The header frame and the objects it encloses (F_DNAMEs boilerplate label and the line beneath the label) are selected. Now, use the method appropriate to your platform to select the F_DNAME field in addition to the M_Department_HDR frame.

7.

Move all of the selected objects to the right, positioning them next to the F_SAL field and its boilerplate label and line. (Remember, Confine mode has been toggled off. You need to select all the objects so that they will move together.) Select the R_DeptSal repeating frame. Select Edit>Duplicate to create an exact copy of R_DeptSal. Move the copy to F_ENAME and resize it to surround the field. Rename it R_DeptEname. Select the B_ENAME boilerplate label, the R_DeptEname repeating frame, and the enclosed F_ENAME field.

8.

9.

10. Move the selected objects to the left of the F_DNAME field and its boilerplate label and line. Then deselect all objects. 11. Select the three fields, then choose Arrange>Align Objects... to display the Alignment Settings dialog box. Select the Align Top radio button to align the tops of all three fields. The next figure shows how your report layout should appear.

12. Display the property sheet for the F_SAL field and change its format mask to NNN0.00. Accept the property sheet. Save and run your report.

6 22

Building Reports Manual

Check Printing Report

Distinguishing Features

This check printing report is built so that the check appears on the left, and its related stub on the right. It could also be built so that the check appears above the stub. The company name is printed on the check for the first page of the stub, and CANCELLED is printed on all checks thereafter for stubs that require additional pages. One interesting aspect to building a check printing report is cancelling checks for stubs that require more than one page. One way to solve this problem is to define two objects as appearing in the same location. The first, a field, contains the customer name. The second, a boilerplate text object, contains the word CANCELLED. The field is defined to print only on the first page of a multipage check stub, while the boilerplate text is defined to print on all but the first page. Thus, page one will contain the name of the customer (right next to the Pay to the Order of line in the check), while all subsequent pages will contain the word CANCELLED. This report uses two queries linked together in a master/detail relationship. The basis for this reports layout is the default tabular layout style. Youll make several modifications, including deselecting columns and deleting a column label. Youll also create or modify several objects, then modify the necessary settings so that only one check and check stub are printed per page.

Concepts

Data Relationships Layout

Advanced Reports

6 23

To see a sample check printing report, open the Oracle Reports example report named checkprb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Below is the data model for this report.

Steps to Build this Report

Queries

1.

Create the following two queries: Q_Customer and Q_Stub.


Q_Customer: Q_Stub: SELECT RPAD(NAME, 30) CUSTNAME, CUSTID FROM CUSTOMER ORDER BY CUSTID SELECT CUSTID, ORDID, SHIPDATE, TOTAL FROM ORD ORDER BY ORDID

Link Q_Stub to G_Customer via CUSTID and CUSTID1. Report Properties Default Layout Layout Editor 2. 3. 4. Change the reports page height to 2.5 inches. Retain the default layout style of Tabular. Deselect columns CUSTID and CUSTID1 and delete the label for CUSTNAME. Use the Field tool to create a field, long enough to contain the current date, that is rightaligned with F_CUSTNAME and topaligned with the Ordid label. Rename it F_DATE and assign it a source of &Current Date and a format mask of DDMONYY. Go to General Layout:Print Condition, and assign a print condition type of All.

Field Tool

6 24

Building Reports Manual

5. 6. 7.

Make F_DATEs border transparent. Select the Text tool and type CANCELLED directly atop the F_CUSTNAME field. Select and resize the M_Customer_GRPFR frame and R_Customer repeating frame downward, enlarging them enough to enclose the boilerplate text youll type in the following step. Starting about one inch down the page and directly beneath F_CUSTNAME, type the following boilerplate text:
xxxx and xx/100 yyyy

8.

Boilerplate

9.

Display the property sheet for the boilerplate CANCELLED and rename it B_CANCELLED. Change the print condition for B_CANCELLED to All but First. This will make the boilerplate print on all but the first page of a multipage check stub.

10. For boilerplate B_2 (the text that contains xxxx and xx/100 and yyy), change the print condition to All so it will print on every page of the report. Repeating Frames Fields 11. Enter 1 for R_Customers Maximum Records per Page. 12. Enter a format mask of $NNN,NN0.00 for the F_TOTAL field. 13. Go to General Layout:Print Condition in F_CUSTNAMEs property sheet and assign a print condition of First. F_CUSTNAME will now print on only the first page of a multipage check stub. Your report layout should look similar to the figure below.

Save and run your report.

Advanced Reports

6 25

The best page size for viewing the effects of this report may vary according to platform. If none of the records has yet been forced to a twopage check stub, you may need to change the Page Height to an even smaller page. Feel free to experiment with the setting. Note: When viewing this report on your display, you may wish to specify a destination type of Preview on the Runtime Parameter form. Your report will display as though using Postscript fonts instead of your screen display fonts, and you can get a clearer indication of the appearance (e.g., line wrapping) of the printed report.

6 26

Building Reports Manual

Spelling Out Cash Amounts On Checks

Distinguishing Features Concepts

The output for this report spells out a numerical value for each check amount. (This report is being explained separately from the Check Printing report for simplicity.) To spell out the value of a check, you can use the ORACLE DECODE function to split the number into its constituent numerals, then use a lookup table to perform the conversion from numeral to word. This report uses two queries. Youll link them without specifying columns by which to link to establish a relationship between the two queries without establishing a hierarchy to the data. As a result, all column values will be returnedeven repetitions of previous values. One of the queries youll create assumes that the numbers to be spelled are stored in the TOTAL column of the Ord table. The text of the spelledout number will be fetched from the table called Lookup and returned in the Thousands_Text, Thousands_Symbol, Ones_Text, and Decimal_Text columns.

Data Relationships

Layout

This report uses a default master/detail layout style. To see a sample report spelling out cash amounts on checks, open the Oracle Reports example report named spellamb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Below is the data model for this report.

Advanced Reports

6 27

Steps to Build this Report

Queries

1.

Create a query named Q_Sum with a SELECT statement of:


SELECT NAME, SUM(TOTAL), FLOOR(SUM(TOTAL)/1000) THOU, TRUNC(SUM(TOTAL) TRUNC(SUM(TOTAL),3),0) ONES, (SUM(TOTAL) TRUNC(SUM(TOTAL),0))*100 DEC FROM CUSTOMER, ORD WHERE CUSTOMER.CUSTID = ORD.CUSTID GROUP BY NAME ORDER BY NAME

2.

Create a query named Q_Spell with a SELECT statement of:


SELECT DECODE(:THOU,0,,A.NUMBERTEXT || THOUSAND ) || DECODE(:ONES,0, DECODE(:THOU,0,ZERO AND || TO_CHAR (:DEC) || /100,AND || TO_CHAR (:DEC) || /100),B.NUMBERTEXT || AND || TO_CHAR (:DEC) || /100) SPELLED_VAL FROM LOOKUP A, LOOKUP B WHERE A.NUMBERVALUE = :THOU AND B.NUMBERVALUE = :ONES

6 28

Building Reports Manual

Link Q_Spell to its parent group, G_Sum, without specifying any columns by which to link. (Select the Data Link tool. Click in the title bar of G_Sum, then drag the mouse pointer to the title bar of G_Spell and release.) Default Layout 3. Select the default layout style Master/Detail, deselect columns THOU, ONES, and DEC, delete the label for SPELLED_VAL, and change the widths of NAME to 35, of SUM_TOTAL to 12, and of SPELLED_VAL to 65. Change the vertical spacing of R_Sum to 0.5 inch. Change the alignment of F_SUM_TOTAL to Right and give it a format mask of $NNN,NN0.00. Your report layout should look similar to the figure below.

Repeating Frames Fields

4. 5.

Save and run your report. You may want to modify its appearance. Note: When viewing this report on your screen, you may wish to specify a destination type of Preview on the Runtime Parameter form. Your report will display as though using the Postscript fonts instead of your screen display fonts, and will give you a clearer indication of the appearance (e.g., line wrapping) of the printed report.

Advanced Reports

6 29

Printing Reports On Preprinted Forms

Distinguishing Features

This report consists of data formatted such that all values fall precisely within the corresponding fields of a preprinted sales order. The form length is 24 lines per page. The customer name and address must begin on line 2, column 15; the customer name must wordwrap if it is longer than 15 characters; the item listing must start on line 8, column 3, and print no more than 12 lines (the rest spilling over to subsequent pages); and the page item totals must begin on line 22, column 65.

Concepts

This example report illustrates formatting techniques for printing reports on preprinted forms. Such reports must be designed so that the data prints in exact positions on the form. This report uses two queries linked in a master/detail relationship. Youll create a break in the detail group and a summary column in the master group.

Data Relationships

6 30

Building Reports Manual

Layout

This report consists of two partial default layouts, one with a mailing label format and one with a tabular format. Youll move fields to the correct positions on the page and restrict the master repeating frame to appearing once per form. To see a sample report that prints on preprinted forms, open the Oracle Reports example report named preprntb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Below is the data model for this report.

Steps to Build this Report

Queries

1.

Create two queries, Q_Name and Q_Orders, with the following SELECT statements:
Q_Name: SELECT ENAME, NAME, ADDRESS, CITY || , || STATE || || ZIP CITY_STATE_ZIP, CUSTID FROM EMP, CUSTOMER WHERE EMPNO = REPID ORDER BY ENAME, NAME

Advanced Reports

6 31

Q_Orders: SELECT ORDERDATE, I.PRODID, DESCRIP, QTY, ACTUALPRICE, ITEMTOT, CUSTID FROM ORD O, ITEM I, PRODUCT P WHERE O.ORDID = I.ORDID AND I.PRODID = P.PRODID ORDER BY ORDERDATE, I.PRODID

Link the Q_Orders query to its parent group, G_Name, via CUSTID and CUSTID1. Groups Columns Layout Editor 2. 3. 4. Create a group above G_Orders by moving the ORDERDATE column. Rename the group G_Date. In G_Name, create a running summary named SUMITEMTOT with a source of ITEMTOT and a reset level of Page. Go to the Object Navigator and doubleclick on the Layout node icon to display the Layout editor without creating a layout. Show the margins of your report layout. Select the top left corner of the body and drag it to the upperleft corner of the editor to remove the top margin. Select the bottom right corner of the body and drag it to the lowerright corner of the editor to remove the bottom margin. Redisplay the report body. Select the Additional Default Layout tool in the Tool palette. Starting about two inches across the page and about .25 inches down the page, draw a region about 3.5 inches long and about 1.5 inches high. In the Default Layout dialog box, enter the following settings: Default Layout Style Mailing Label Groups Report G_Name ENAME NAME ADDRESS CITY_STATE_ZIP 10 15 15 25 Column Width

5.

Additional Default Layout Tool

6.

Accept the dialog box to display a default layout in the specified region of the Layout editor. 7. Select and resize the R_Name repeating frame to fill the entire page in the Layout editor.

6 32

Building Reports Manual

8.

Select the Additional Default Layout tool. Starting about .5 inch below F_CITY_STATE_ZIP and about .25 inch across the page, draw a region about 8 inches long and about 2 inches high. In the Default Layout dialog box, enter the following settings: Default Layout Style Tabular Groups Report G_Date G_Orders ORDERDATE PRODID DESCRIP QTY ACTUALPRICE ITEMTOT Blank Blank Blank Blank Blank Blank 9 6 20 4 6 10 Columns Label Width

Accept the dialog box to display a default layout for these groups in the specified region of the Layout editor. 9. Select F_ITEMTOT then select Edit>Duplicate. Drag the new field to a point about 6.5 inches across the page and about 6.5 inches down the page (if necessary, toggle Confine mode off for this step). Increase the width of the field by about two characters. Display its property sheet, rename it F_SUMITEMTOT, and assign it a source of SUMITEMTOT and a format mask of $NN,NN0.00. In General Layout:Print Condition, assign a print condition of All. Accept the property sheet. Rightalign it. Note: When you create F_SUMITEMTOT, you should increase the width of the field by a few characters because the source of the field, SUMITEMTOT, is a pagedependent reference; i.e., as the sum total of a pages contents it depends upon what is formatted for that page. As a result, Oracle Reports is forced to format the layout object that will display this value before the value itself is determined, and must reserve a fixed area in which to do so. Therefore, F_SUMITEMTOT is fixed, both horizontally and vertically, and cannot be changed. Another option to ensure that the values of the column are not truncated is to hide the field and reference it in a piece of boilerplate that is large enough to hold the largest possible column value. In this case, the field, because it is hidden, can be variable. However, the boilerplate in which it is referenced will be fixed.

Advanced Reports

6 33

For details on using this method of accommodating a pagedependent reference, see Renumbering Pages by Repeating Frame on page 6 9. For more information about pagedependent references, refer to Vertical Sizing in Chapter 8 of the Reports Reference Manual. 10. Change the vertical sizing of M_Date_GRPFR to Fixed and enlarge it until it is about 0.5 inches above F_SUMITEMTOT. This will will limit the number of records that can fit in the frame. Repeating Frames Fields 11. Change Maximum Records per Page for R_Name to 1, so that each customer will print on a new page. 12. Give F_NAME a horizontal sizing of Variable. Next, use the Common Properties dialog box to change the print condition types of F_NAME, F_ENAME, F_ADDRESS, and F_CITY_STATE_ZIP to All, and give the F_ACTUALPRICE and F_ITEMTOT fields format masks of $NN,NN0.00. The next figure shows how your report layout should appear.

Save and run your report. Note: To get a clearer indication of the appearance of the report output, specify a destination of Preview. Your report will display as though using Postscript fonts instead of screen display fonts.

6 34

Building Reports Manual

Invoice Report

Distinguishing Features Concepts

The example report above displays several distinguishing characteristics of a typical invoice, such as customer name and address, sales order number, billing information, and billing totals. Invoice reports are master/detail reports with billing amounts that print conditionally. The customer name, address, and related information are derived from the master query (or group, if there is only one query). The lineitems come from the detail query. The billing amounts are printed in the page footer. This information must all print on specific line and column positions on the preprinted invoice form. To format your information correctly, youll use many of the same techniques as you used in the Preprinted Forms report. (To review these techniques, see Printing Reports on Preprinted Forms on page 6 30.) As an additional aid to formatting this report, you will link to a TIFF image of the invoice. This will enable you to position your fields more precisely.

Advanced Reports

6 35

Data Relationships

The data for this report is fetched using two queries, linked together in a master/detail relationship. Youll also define a break and two summaries. This layout is similar to the layout for the Preprinted Form report, but in this case you will also link to a TIFF image of your form to use as a guide while adjusting the positions of several fields. To see a sample invoice report, open the Oracle Reports example report named invoiceb.rdf if you have a monochrome monitor. If you have a color monitor, open the report named invoicec.rdf. For details on how to open them, see How to Access Demo Reports on page 4 2.

Layout

Organization

The next figure shows the data model for this report.

Steps to Build this Report

Queries

1.

Create the following two queries: Q_Name and Q_Orders.


Q_Name: SELECT ENAME, NAME, ADDRESS, CITY || , || STATE || || ZIP CITY_STATE_ZIP, CUSTID FROM EMP, CUSTOMER WHERE EMPNO = REPID ORDER BY ENAME, NAME

6 36

Building Reports Manual

Q_Orders: SELECT ORDERDATE, I.PRODID, DESCRIP, ITEMTOT, CUSTID FROM ORD O, ITEM I, PRODUCT P WHERE O.ORDID = I.ORDID AND I.PRODID = P.PRODID ORDER BY ORDERDATE

Link Q_Orders to parent group G_Name via CUSTID and CUSTID1. Groups Columns 2. 3. Create a group above G_Orders using the ORDERDATE column. Rename the group G_Date. Create the following summaries in group G_Name:
PAGETOTAL,

with a function of Sum, a source of ITEMTOT, and a reset group of Page. with a function of Sum, a source of ITEMTOT, and a reset group of G_Name.

CUSTOMERTOTAL,

4.

Go to the Object Navigator. Doubleclick on the icon in the Layout editor node to display the Layout editor without creating a default layout. Show the margin areas of your report layout. Select the top left corner of the body and drag it to the upperleft corner of the editor to remove the top margin area. Then select the bottom right corner of the body and drag it to the lowerright corner of the editor to remove the bottom margin area. Redisplay the report body in the Layout editor. Select the Additional Default Layout tool in the Tool palette. Starting about 1.5 inches across the page and about 1 inch down, draw a region about 3 inches long and about 2 inches high. In the Default Layout dialog box, enter the following settings: Default Layout Style Mailing Label Groups Report G_Name ENAME NAME ADDRESS CITY_STATE_ZIP Accept the dialog box. 10 15 15 25 Columns Width

5.

Additional Default Layout Tool

6.

Advanced Reports

6 37

7. 8.

Resize the R_Name repeating frame to fill the entire page in the Layout editor. Select the Additional Default Layout tool in the Tool palette. Starting about 2.5 inches down the page and about .25 inches across, draw a region about 7 inches long and 3 inches high. In the Default Layout dialog box, enter the following settings: Default Layout Style Tabular Groups Report G_Date G_Orders ORDERDATE PRODID DESCRIP ITEMTOT Accept the dialog box. Blank Blank Blank Blank 9 6 20 10 Columns Label Width

Boilerplate

9.

Link File Tool

Select the Link File tool in the Tool Palette. Starting at the upper left corner of your layout, create a boilerplate object 8 inches wide by 6 inches high. Open the property sheet for the boilerplate object and rename it B_INVOICE.

10. Select the List... button, then change the directory list in the Open File dialog box to show the reqfiles directory. If you are using a monochrome monitor, select invoice.tif. If you are using a color monitor, select invoicec.tif. Accept the dialog box. For format, choose Image from the list of values. If you want the image to display on every page of output, change the print condition type to All. Accept the property sheet. By linking to the TIFF file, you incorporate into your layout an image of the invoice which you can use as a guide when positioning fields. This image will not become a part of your report definition, as it would if it were being imported. Instead, the boilerplate object links to the TIFF file. Your report will therefore incorporate any changes to the image, so long as it continues to have the same filename and location. 11. Toggle Confine mode off to enable you to freely manipulate layout objects. With B_INVOICE still selected, select Arrange>Send to Back to place the boilerplate object on the bottom of the layout (an operation that would not be allowed if Confine mode remained in effect). Make sure it remains selected, then select Arrange>Move Forward.

6 38

Building Reports Manual

This places the boilerplate object youve created above and within R_Name, the outermost frame, but below all other layout objects, ensuring that all data will be laid out on top of the image and the image will print with the proper frequency. 12. Now position the fields more precisely within the spaces allotted by the invoice form by simply selecting them and moving them. Toggle Confine mode back on so that you do not move any objects beyond the boundaries of their parent frames. Note: Remember to turn Flex mode on if moving a field necessitates enlarging its surrounding frames. This prevents you from having to select and resize frames individually. Frames 13. Enlarge M_Date_GRPFR to fit the space provided by the invoice, then change its vertical sizing to Fixed so that the number of records displayed does not overrun the invoice. 14. Change R_Names maximum records per page to 1, and its vertical sizing to Variable. 15. Enter Variable in the Horizontal Sizing field for F_NAME, change the print conditions of F_NAME, F_ENAME, F_ADDRESS, and F_CITY_STATE_ZIP to All, and enter a format mask of $NN,NN0.00 for F_ITEMTOT. 16. Select F_ITEMTOT and duplicate it (select Edit >Duplicate). Move the new field into the patterned area next to the Total label. Temporarily toggle off Confine mode to do so. Rename the new field F_PAGETOTAL and assign it a source of PAGETOTAL, a print condition of All but Last, a print condition object of Anchoring Object, and a format mask of $NN,NN0.00. You may wish to increase its width by about two characters as you do so, as F_PAGETOTAL is a pagedependent reference. (For details on pagedependent references, refer to Vertical Sizing in Chapter 8 of the Reports Reference Manual. If necessary, rightalign it. 17. Select F_PAGETOTAL, then paste a copy of the field directly over itself. (Copy, then paste, the field without moving the cursor.) Rename the field F_CUSTOMERTOTAL, and assign it a source of CUSTOMERTOTAL, a print condition of Last, a print condition object of Anchoring Object, and a format mask of $NNN,NN0.00. If necessary, rightalign it.
Anchor Tool

Repeating Frames Fields

18. Anchor the top left edges of both F_PAGETOTAL and F_CUSTOMERTOTAL to the bottom right edge M_Date_GRPFR.

Advanced Reports

6 39

Save and run your report. Your report displays the form as well as the data. If you have preprinted forms and only wish to use the image of the form to aid in formatting the report, you no longer need the boilerplate. 19. In the Layout editor, select the B_INVOICE boilerplate object. Then select Edit>Clear to remove the boilerplate object Note: When viewing this report on your screen, you may wish to specify a destination type of Preview on the Runtime Parameter form. Your report will display as though using the Postscript fonts instead of your screen display fonts, and you can get a clearer indication of the appearance (e.g., line wrapping) of the printed report.

6 40

Building Reports Manual

PL/SQL Report

Distinguishing Features

This report uses an external PL/SQL library and PL/SQL within the report to modify formatting and calculate the total compensation for each employee. Notice the spacing between records (e.g., between the record for Ford and the record for Jones). This space is not due to a break. It is the result of using a PL/SQL procedure in a format trigger. There are a variety of ways to incorporate PL/SQL into your reports. Youve already created formula columns that used simple PL/SQL expressions to compute their values, and format triggers that used PL/SQL to conditionally determine the formatting of mailing labels. Next youll create external libraries and local functions and procedures. External PL/SQL libraries are modules that contain named PL/SQL functions and procedures. They may be stored either in the database or in a file, and can be referenced from not only any report, but from other Oracle products. External libraries eliminate the need to reenter commonlyused PL/SQL constructs, whether in reports, forms, or charts. This is turn eliminates the problem of maintaining several versions of the same PL/SQL code.

Concepts

Advanced Reports

6 41

Local PL/SQL consists of named PL/SQL functions and procedures that are saved in a report definition. Local PL/SQL may be referenced only by objects within the report (e.g., group filters, formula columns, format triggers, etc.). However, the usefulness of storing PL/SQL in a single location still applies. Data Relationships This report uses one query. You will add a function stored in an external library, a reportlevel function, two formula columns, and a parameter governing the number of records to display before inserting a space. This report uses the tabular layout style, with minor modifications. To see a sample PL/SQL report, open the Oracle Reports example report named plsqlb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Layout

Organization

Below is the data model for this report.

Steps to Build this Report

External PL/SQL Libraries

1.

In the Object Navigator, select the Libraries node, then select Navigator>Create. (Alternatively, select the Libraries node, then select the Create tool, or, with no nodes selected, select File>New>External PL/SQL Library.) A node for a new library appears under the Libraries heading node.

6 42

Building Reports Manual

2.

Expand the node for the new library to show two subnodes: Program Units and Attached Libraries. Select the Program Units node, then select Navigator>Create (or the Create tool). Enter BONUS_PAY in the Name field of the New Program Unit dialog box. Select the Function radio button to indicate that you are going to create a function, then select OK. The Program Unit editor appears, containing a template for your function. Edit the template to create the function shown below.
FUNCTION BONUS_PAY (JOB IN CHAR, SAL IN NUMBER, COMM IN NUMBER) RETURN NUMBER IS BEGIN IF JOB != SALESMAN THEN RETURN (SAL * 0.15); END IF; IF JOB = SALESMAN AND COMM >= 500 THEN RETURN ((SAL + COMM) * 0.15); ELSE RETURN ((SAL + COMM) * 0.10); END IF; END;

3.

4.

This function states that the total compensation calculated for all employees other than salesmen (analysts, managers, etc.) should consist of salary plus a 15% bonus. The bonus for salesmen whose commissions are equal to or greater than $500 should be 15% of the sum of salary plus commission. Salesman with commissions of less than $500 receive a 10% bonus. 5. Select Compile to compile the function, then select Close to accept the Program Unit editor. The Object Navigator reappears, displaying BONUS_PAY (Function Body). The node is selected in the Object Navigator. Select File>Save... and the Save Library dialog box appears, containing the Oracle Reportsgenerated name of the library you initially created. Rename the library bonus.pll, and include path information if you want to save it to a directory other than the current directory or the defined working directory. Select OK to save the library and display the Object Navigator. Select the Attached Libraries node, then select Navigator>Create (or the Create tool). The Attach Library dialog box is displayed. Use this dialog to attach the library you just created. Make sure the File System radio button is selected, then select Find.... Locate bonus.pll and select it.

6.

Attached Libraries

7.

Advanced Reports

6 43

8.

Select OK to redisplay the Attach Library list. Select Attach to add the external PL/SQL library and accept the dialog. Note: If you attach a library whose specification also includes a path, Oracle Procedure Builder will inform you that path names are not portable and give you the option of deleting the path. If you choose to continue using a path specification, Oracle Procedure Builder will only look in that location for the library. If the library has been moved, it will not use paths set by environment variables to locate it. If you delete the path, Oracle Procedure Builder will use the standard search path to locate the library.

Queries

9.

Create a query named Q_Employee with a SELECT statement of:


SELECT ENAME, JOB, SAL, COMM FROM EMP ORDER BY ENAME

Columns

10. Below COMM, create a summary column named CNT_COLUMN with a function of Count, a source of ENAME, and a reset level of Report. Youll use this column as a counter; i.e., its value in any given record will be the number of records fetched. Youll use this value when including extra spaces in your formatting. 11. Below CNT_COLUMN, create a formula column named BONUS. Select Formula:Edit... to display the Program Unit editor. Edit the template provided to create the following function:
function BONUS return number is begin return BONUS_PAY(:JOB, :SAL, :COMM); end;

12. In the Object Navigator, select the Program Unit node and select Navigator>Create (or the Create tool) to display the New Program Unit dialog box. Enter FINAL_CALC in the Name field, make sure the Function radio button is selected, and select OK. The Program Unit editor is once again displayed. 13. Modify the template provided to enter the following function:
FUNCTION FINAL_CALC RETURN NUMBER IS BEGIN IF :JOB = SALESMAN THEN RETURN (:BONUS + :SAL + :COMM); ELSE RETURN (:BONUS + :SAL); END IF; END;

6 44

Building Reports Manual

This reportlevel function returns the total compensation for sales reps (the values of the columns SALARY plus COMM plus BONUS) as well as all other employees (SALARY plus BONUS). 14. Select Compile to compile the function, then Close to close the Program Unit editor. FINAL_CALC now appears in the Object Navigator under the Program Units node. 15. Below BONUS, create a second formula column named TOTAL_COMP. Select Formula:Edit... and edit the template provided.
function TOTAL_COMP return Number is begin return FINAL_CALC; end;

The value calculated by the function FINAL_CALC will be assigned to the column TOTAL_COMP. Parameters 16. Select the User Parameter node in the Object Navigator (expand the Data Model node if necessary) and select Navigator>Create (or the Create tool). A parameter, P_1, is created. Doubleclick on the parameter icon to display the its property sheet and name it SPACE. Give it a datatype of Number and an initial value of 5. This parameter will determine how many records are displayed before an extra space is printed. 17. Keep Tabular as the default layout, but change the widths of ENAME to 8, BONUS to 10, and TOTAL_COMP to 10. Deselect CNT_COLUMN so that it does not appear in the layout. 18. Toggle Confine mode off and Flex mode on. Select the R_Employee repeating frame and enlarge it (and M_Employee_GRPFR) until the extra space in the frames is slightly larger than the amount of extra space you want to include in your formatting. Display the repeating frames property sheet and make its vertical sizing Variable. 19. Select the Rectangle tool from the Tool palette. Draw a rectangular piece of boilerplate in the empty space youve created under the F_ENAME, F_JOB, etc. fields. Open its property sheet and go to General Layout:Format Trigger.... Select Edit... to display the Program Unit editor. Edit the template provided.

User Parameters Icon

Default Layout

Frames

Rectangle Tool

Advanced Reports

6 45

FUNCTION SPACING RETURN BOOLEAN IS BEGIN IF :CNT_COLUMN MOD :SPACE = 0 THEN RETURN (TRUE); ELSE RETURN (FALSE); END IF; END;

This format trigger tells Oracle Reports to display the boilerplate only when the value of CNT_COLUMN divided by the value of SPACE leaves no remainder. 20. Make sure the rectangle has no border. The figure below shows how your report layout should appear.

Fields

Change the format masks of F_SAL, F_COMM, F_BONUS, and F_TOTAL_COMP to $NN,NN0.00. Compile, save, and run your report. See where the extra spacing appears. Run it again, changing the value for SPACE, and see what affect the changing value has on the appearance of the report.

6 46

Building Reports Manual

Ranking Report

Distinguishing Features

This report ranks data two different ways: by count and by percentage. The upper portion displays the names and total purchases of the top three customers; the lower portion displays the names and total purchases of those customers who constitute 75% of all sales. You can set the ranking criteria at runtime, or let them default to previously specified values. The ranking by count portion will be explained first.

Concepts, Part I: Ranking by Count


Data Relationships

This example report ranks the data by comparing it to a userspecified bind parameter. This report requires one query to fetch the data. To rank the data, youll create the following objects:

A bind parameter that gives you the option of setting the cutoff point at runtime. A bind parameter that increments by 1 each time a record is fetched from the database. The value in this parameter will be compared to the cutoff bind parameter A customized group filter to include only records within the cutoff value. Using a customized filter rather than a packaged filter allows you to parameterize your cutoff values.

Layout

This report uses the default tabular layout style, with modifications.

Advanced Reports

6 47

To see a sample ranking by count report, open the Oracle Reports example report named rankng1b.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

The next figure shows the data model for this report.

Steps to Build this Report

Queries

1.

Create a query named Q_Rank with a SELECT statement of:


SELECT CUSTNAME CNAME, SUM(AMOUNT) SUM_AMT FROM SALES GROUP BY CUSTNAME ORDER BY SUM(AMOUNT) DESC

Parameters

2.

User Parameters Icon

Under the Data Model node in the Object Navigator, select the User Parameters node, then select Navigator>Create (or the Create tool) to create a new parameter. Doubleclick on the icon to display the parameters property sheet and name it CUTOFF_CNT with a datatype of Number, a width of 1, and an initial value of 3. Create a second parameter named INCR_CNT with a datatype of Number, a width of 3, and an initial value of 0.

3.

6 48

Building Reports Manual

4.

For G_Rank, select the Condition radio button under General:Filter, then select Edit. Edit the template provided:
function G_RankGroupFilter return boolean is begin :incr_cnt := :incr_cnt + 1; if :incr_cnt <= :cutoff_cnt then return (TRUE); else return(FALSE); end if; end;

Compile the condition, close the editor, and accept the group property sheet. This filter increments the counter by 1 each time a record in G_Rank is fetched, then compares the counters value to the specified cutoff. When the counter exceeds the cutoff, no more records are fetched. Default Layout 5. Create a tabular layout, first changing the labels of CNAME to Customer Name and of SUM_AMT to Total Purchases, and changing the widths of CNAME to 35 and of SUM_AMT to 15. Grab M_Rank_GRPFR and pull it, and all enclosed objects, down about one inch. Then enter the following text above the labels for F_CNAME and F_SUM_AMT, beginning directly above Customer Name:
Top &F_CUTOFF_CNT Customers:

Layout Editor

6.

Get out of text mode, and with the new boilerplate text still selected, select the Line Color tool. Select No Line. Fields 7. Select the Field tool in the Tool palette, then create a field anywhere in the editing region with a width of at least 1 and a height of at least 1. Name the field F_CUTOFF_CNT and assign it a source of CUTOFF_CNT and a horizontal sizing of Variable. Check F_CUTOFF_CNTs Hidden check box so the field will not appear except when referenced. Accept the property sheet. Your report layout should look similar to the next figure.

Advanced Reports

6 49

8.

Display the property sheet for F_SUM_AMT and change its format mask to $NNN,NN0.00.

Compile, save, and run your report. Parameters 9. Change the initial value of CUTOFF_CNT and run the report again to see the effect on report output.

Another way to rank customers is by a percentage of total sales. The Concepts, Part II: Ranking by Percentage idea is the same as ranking by count, but with an important difference. Since you need to fetch all of the data in order to compute a running percent of total summary, you dont want to use a group filter to weed out data. Rather, use a format trigger on the repeating frame to compare the running total to your cutoff parameter. Data Relationships Layout This section of the report uses the same query, but the columns are given different aliases. Since you are adding this report to the rank by count report, youll need to create a small default layout in the Layout editor and deselect the groups and columns from the first report. To see a sample ranking by percent report, open the Oracle Reports example report rankng2b.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Below is the data model for this report, added to the data model for the rank by count report.

6 50

Building Reports Manual

Steps to Build this Report

Queries

1.

Create a query named Q_Percent with a SELECT statement of:


SELECT CUSTNAME CNAME2, SUM(AMOUNT) SUM_AMT2 FROM SALES GROUP BY CUSTNAME ORDER BY SUM(AMOUNT) DESC

Parameters Columns

2. 3.

Create a parameter named CUTOFF_PCT with a datatype of Number, a width of 2, and an initial value of 75. Below SUM_AMT2 create a summary column named R_PCT with a datatype of Number, a width of 10, a function of % of Total, a source of SUM_AMT2, and reset and compute levels of Report. In the layout, select the Additional Default Layout tool. Starting about 1 inch below the lower left corner of M_Rank_GRPFR, draw a region about the same size as the original layout. Deselect the G_Rank group and the R_PCT column, change the labels for CNAME2 to Customer Name and for SUM_AMT2 to Total Purchases, and change the width of CNAME2 to 35 and of SUM_AMT2 to 15. Add the following text above the labels for F_CNAME2 and F_SUM_AMT2, beginning directly above Customer Name:
Top &F_CUTOFF_PCT% of Sales:

Default Layout

4.

5.

Layout Editor

6.

Advanced Reports

6 51

Repeating Frames

7.

Display the property sheet for R_Percent and go to General Layout:Format Trigger.... Select Edit... to display the Program Unit editor. Modify the template provided:
function R_PercentFormatTrigger return boolean is begin if :r_pct <= :cutoff_pct then return (TRUE); else return(FALSE); end if;

This function adds the current records percentage of the total to the previous records percentages. Only if the sum is less than or equal to the userspecified cutoff will it format the frame. Fields 8. Create a field named F_CUTOFF_PCT anywhere in the editor. Give it source of CUTOFF_PCT and a horizontal sizing of Variable. Draw it at least three characters wide and one character high. Check F_CUTOFF_PCTs Hidden check box so the field will not appear except when referenced.

9.

Give F_SUM_AMT2 a format mask of $NNN,NN0.00. Compile, save, and run your report using different values for CUTOFF_PCT.

6 52

Building Reports Manual

Suppressing Labels When No Detail Records Are Retrieved

Distinguishing Features

This is a master/detail report that happens to fetch a master record with no associated detailsDeptno 40 in the figure above. However, unlike a default master/detail report, this report does not display the labels Ename and Job for department 40. Instead, it displays a message stating that no detail records were fetched. A default master/detail report must print a detail label or field, even if there are neither fetched detail records nor values for usercreated columns. The following report demonstrates how to prevent this. This report uses a master/detail data model. Youll also create a formula column in the detail group whose sole function is to return a value; this ensures the detail group contains at least one column that will always return a value each time a detail record is returned (as opposed to, for example, a null value).

Concepts

Data Relationships

Advanced Reports

6 53

Youll create a summary to count the number of times this formula column returns a value; in the layout youll create a format trigger that references the summary to determine if detail labels should be displayed. This provides a reliable method for determining the existence of detail records. Layout This report uses a master/detail layout style with modifications. To see a sample report that suppresses labels when no detail records are retrieved, open the Oracle Reports example report named suppresb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Below is the data model for this report.

Steps to Build this Report

Queries

1.

Create a query named Q_Dept with a SELECT statement of:


SELECT * FROM DEPT ORDER BY DEPTNO

6 54

Building Reports Manual

2.

Next to Q_Dept, create a query named Q_Emp with a SELECT statement of:
SELECT DEPTNO, ENAME, JOB FROM EMP ORDER BY ENAME

Link Q_Emp to its parent group, G_Dept, via DEPTNO and DEPTNO1. Columns 3. Below JOB in group G_Emp create a formula column, DETAIL_VAL. Select Formula:Edit... to display the Program Unit editor and edit the template provided:
function DETAIL_VALFormula return number is begin return(1); end;

All this formula column doesall it needs to dois return a value. Its sole purpose is to serve as an indication of whether or not any detail records have been retrieved for the master. 4. Below LOC in group G_Dept, create a summary column, CNT_DETAIL, with a function of Count, a source of DETAIL_VAL, and a reset level of G_Dept. Select the Master/Detail layout style, and deselect columns DETAIL_VAL, CNT_DETAIL and DEPTNO1. Doubleclick on the M_Emp_HDR frame to display its property sheet. Go to General Layout:Format Trigger... and select Edit... to display the Program Unit editor. Edit the template provided.
function M_Emp_HDRFormatTrigger return boolean is begin if :cnt_detail = 0 then return (FALSE); else return (TRUE); end if; end;

Default Layout Layout Editor

5. 6.

This function states that if no detail records are fetched for the master, then do not print the frame containing the labels for the detail records. Suppressing a frame (or repeating frame) suppresses all objects within the frame. Boilerplate 7. Select the Text tool from the Tool palette, position the cursor above the label Ename, and type NO DETAIL RECORDS RETRIEVED.

Advanced Reports

6 55

Without deselecting the boilerplate, click and drag over the message you just typed, highlighting it in reverse video. Choose a text weight for the boilerplate as you normally do on your platform. Were using Bold. If you wish, you can also change the font size and style. 8. Exit text mode but leave the boilerplate object selected. Make sure the border is transparent, and position the boilerplate as desired over the column labels. Display the boilerplates property sheet and change its print condition to All. Deselect the boilerplate. Use the Frame Select tool to select the M_Emp_GRPFR group frame. This selects not only the group frame, but every object in it. Select Arrange>Move Forward. All the objects, including the M_Emp_GRPFR frame, are now located in front of the boilerplate. Deselect the group of objects, then select the M_Emp_GRPFR frame. Select the Fill Color tool. Choose the solid white fill from the color palette. This will make the frame opaque and hide the text you placed behind it. Check the sizing of the boilerplate relative to your frame. If you can still see some of it projecting beyond the edge of your frame you need to hide it, or it will project beyond the detail labels each time they print. To do so, enlarge the M_Emp_GRPFR to cover it. Your report layout should look like the figure below.

9.

Repeating Frames

10. Change the vertical spacing of R_Dept to 0.25 inches. Compile, save, and run your report.

6 56

Building Reports Manual

Advanced Mailing Label Report

Distinguishing Features

This report resembles the previous mailing label reports, maillblb.rdf and maillb2.rdf (for details, see Introductory Mailing Label Report on page 5 11), in that it displays a list of addresses in a format suitable for use as mailing labels. However, note the one important difference: each zip code is also represented by a barcode, created using an Oracle Graphics display and referenced by the report. This example is a simple mailing label report that references an Oracle Graphics chart, enabling it to pass data to Oracle Graphics and receive a display in return. This report uses one query to fetch all data. This report uses the default mailing label layout style. While in the Layout editor, you will enlarge R_Customer to allow room for the barcode, then create an Oracle Graphics Display object. This special type of layout object refers to an Oracle Graphics display that converts the zip code to a barcode. To see a sample advanced mailing label report, open the Oracle Reports example report named barcode.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Concepts

Data Relationships Layout

Organization

The next figure shows the data model for this report.

Advanced Reports

6 57

Steps to Build this Report

Queries

1.

Create a query named Q_Customer with a SELECT statement of:


SELECT NAME, ADDRESS, CITY || , || STATE || || ZIP CITY_STATE_ZIP, TO_NUMBER(ZIP) ZIPNUM FROM CUSTOMER ORDER BY NAME

Note the function TO_NUMBER. This converts each value of ZIP from a datatype of VARCHAR2 to a datatype of NUMBER so that you can convert it to a barcode. Default Layout 2. Select Mailing Label as the default layout style. Change the repeat setting of G_Customer to Down/Across. Change the widths of NAME, ADDRESS, and CITY_STATE_ZIP to 30. Accept the dialog box. Doubleclick on the R_Customer repeating frame to display its property sheet, and change the vertical sizing to 0.25. Accept the property sheet. Enlarge the R_Customer repeating frame until it is about 1 inch tall.

Repeating Frames

3.

4.

6 58

Building Reports Manual

You can add a barcode using a barcode font (Method 1) or the Oracle Graphics tool (Method 2). Method 1 is not portable or printerindependent, but it runs faster than Method 2.

Method One (barcode font)

To add a barcode using the barcode font: 1. Install a barcode font on your machine (e.g., on Windows, install the barcode font in the Windows Control Panel Font). Barcode fonts are available on many online services and from computer stores. For more information, see your operating system documentation. Select the ZIPNUM field, and change its font to the barcode font (e.g., 3of9)..

2.

Method Two (Oracle Graphics tool)


Oracle Graphics Tool

To add a barcode using the Oracle Graphics tool: 1. Select the Oracle Graphics tool from the Tool palette. Beginning at the left edge of the frame directly below F_CITY_STATE_ZIP, draw a region to fill the area created by enlarging R_Customer. This creates an Oracle Graphics object. Oracle Reports automatically knows that the object will refer to an Oracle Graphics display. Doubleclick on the object to display its property sheet. Rename it D_Barcode. Use the Oracle Graphics Display property sheet to specify all the information Oracle Reports needs to call the Oracle Graphics display and pass it the correct data. Under O.G. Display:Display Name, enter the name of the display you want to include in your report. (Choose List..., change to the reqfiles directory, and select barcode9.ogd.) Select ZIPNUM from the list of report columns (scroll down if necessary). In the field next to it, under the label Display Parameter, enter ZIP. The purpose of the Report Column and Display Parameter fields are to map report columns to Oracle Graphics display parameters. This enables you to use a value in your report as a parameter to govern the information Oracle Graphics displays. 7. Go to the O.G. Query tab, but dont change anything, since in this report the Oracle Graphics display treats the zip code as a parameter, not a database column. Generally, however, this tab is used to tell Oracle Reports the name of the query used by the Oracle Graphics display.

2.

3. 4.

5.

6.

Advanced Reports

6 59

Notice the Source field. The Source field indicates the group that is summarized by the display. Leave this blank (you are not summarizing a group, you are converting each value of ZIPNUM to a corresponding graphical display). 8. Next, take a look at the General Layout tab. Notice that it contains all the usual settings commonly associated with an Oracle Reports layout object (e.g., Vertical and Horizontal Sizing, Format Trigger, etc.) and it can be treated as a typical layout object. Accept the property sheet. The layout should look like the figure below.

Save and run your report. Note: Be aware when creating your Oracle Graphics display that certain Oracle Graphics characteristics can affect the display of data in your report. For example, when you create an Oracle Graphics display, Oracle Graphics actually takes a snapshot of the display. This snapshot is what will appear in your report. If your data changes, the change will not be reflected in your report. You need to include a trigger in either the Timer or the Open Trigger in your display to ensure the query is executed each time. For more information, see your Oracle Graphics documentation. For more information on calling Oracle Graphics displays within your report, refer to Integrating with Other Products in Chapter 16 in the Reports Reference Manual. For more information on the different fields in the Oracle Graphics Display property sheet, see Oracle Graphics Properties in Chapter 8 of the Reports Reference Manual.

6 60

Building Reports Manual

Mailing Reports to Multiple Users

Distinguishing Features

The example report above appears to have no new distinguishing features. It is a portion of a simple, onequery report displaying employee data for one department at Summit Sporting Goods. What distinguishes this report is the way in which it fetches data, and the destination of the report output. The query for this report uses a parameter to restrict the data fetched to that of a single department. Then a second report is run which governs the execution of this report and mails the output to the appropriate departmental manager, a process is repeated for each department. Note: Oracle Reports can mail report output to a variety of mail systems, but Oracle Corp. supports the use of this feature only with Oracle*Mail.

Concepts

With Oracle Reports, you can mail report output to one or more users via several methods. You can use DESTYPE and DESNAME, either on the command line or from within a command file, to direct your report output to one or more mailids. You can also use the equivalent Runtime Parameter Form parameters Destination Type and Destination Name to perform the same task from within the designer. (For more information on DESTYPE and DESNAME, see R25DES in Chapter 1 of the Reports Reference Manual. For more information on Destination Type and Destination Name, see Parameter Properties in Chapter 6 of the Reports Reference Manual.) However, suppose you have a report that produces employee data for all the departments in your company, but you dont want to send each department manager all the information for all departments.

Advanced Reports

6 61

You can create a second report which uses the packaged PL/SQL procedure SRW.RUN_REPORT. This procedure calls R25RUN, the Oracle Reports reportrunning executable, and passes it a command string you specify. Via this command string, you can run the report multiple times and mail each output to the desired mailid. Data Relationships Youll create the following two reports:

empdatab.rdfthe report that selects the employee data mailitb.rdfthe report that mails the data to the department managers

empdatab.rdf

The report youll create to be mailed uses one simple query. Youll also create one parameter. The second report will use this parameter to specify the departmental information to be fetched and mailed. This report is also created using one simple query. This query selects the mailids to which you wish to send the report. The relationship between the two reports is analogous to a master/detail relationship. The report mailitb.rdf is the mastereach time a record is fetched for mailitb.rdf, empdatab.rdf is executed in such a way that only records pertaining to the current record of mailitb.rdf are fetched, output, and mailed.

mailitb.rdf

Layout

In this example, both reports use a default tabular layout. (In practice, when formatting the report you wish to mail, you need only take into consideration the limitations of the mail system you are using.) To see a sample employee data report, open empdatab.rdf. To see a sample reportrunning report, open mailitb.rdf. For details on how to open them, see How to Access Demo Reports on page 4 2. Note: The reports empdatab.rdf and mailitb.rdf select employee identification numbers and mailids from the Emp table, which is included in Oracle Reports demo database. These are not valid mailids. Running this report without first modifying it to select valid mailids for your location will result in an error. Also, the file srw2mail.sh is required to enable Oracle Reports to work with electronic mailing utilities. You may need to have your database administrator modify it to work with your utility.

Organization

The next figure shows the data models for both reports.

6 62

Building Reports Manual

Steps to Build empdatab.rdf

Queries

1.

Create the following query named Q_Empdata:


SELECT * FROM EMP WHERE MGR=:MGRNO

A notification appears, stating that your query has created a bind parameter. The clause in Q_Empdata stating WHERE MGR=:MGRNO causes Oracle Reports to automatically create a parameter for which you can substitute values at runtime. Youll use this parameter to specify the department for which you want to fetch employee data. Accept the notification. Default Layout 2. Keep Tabular as the layout style and deselect columns MGR and DEPTNO. The figure below shows your layout.

3.

Use the Common Properties dialog to give both F_SAL and F_COMM format masks of NNN0.00. Save your report. At this point you can manually run it for each department, specifying mail as the destination, and substituting a different managers mailid and employee number for Destination Name and MGRNO each time.

Advanced Reports

6 63

Or, you can create the following report and let Oracle Reports do it for you.

Steps to Build mailitb.rdf

Queries

1.

Create the following query named Q_Mail:


SELECT ENAME, EMPNO FROM EMP WHERE JOB = MANAGER

Default Layout

2.

Accept the default Tabular layout style. The figure below shows how your layout should appear.

3.

Doubleclick on F_EMPNO to display its property sheet. Go to General Layout:Format Trigger.... and select Edit... to display the Program Unit editor. Modify the template provided.
function sendit return boolean is begin srw.run_report(report=empdatab.rdf destype=mail desname=||:ename || desformat=dflt batch=yes mgrno=||to_char(:empno)); return (TRUE); exception when srw.run_report_failure then srw.message(15, Error running reports.); raise srw.program_abort; return(TRUE); end;

Each time a recordi.e., a managers name and identification numberis fetched, this PL/SQL function calls R25RUN, the Oracle Reports executable that runs reports. It passes R25RUN a command string specifying empdatab.rdf as the report to be run, and Mail as the destination of the output.

6 64

Building Reports Manual

In addition, SENDIT includes the following arguments:


desname=||:ename ||this specifies batch=yesSRW.RUN_REPORT

the mailid of the manager to whom you wish to send the report must be run in batch

mgrno=||to_char(:empno)this substitutes each managers

identification number in turn for the parameter MGRNO in empdatab.rdf. This ensures that only the data for a managers department is fetched, output, and mailed to that manager. Note: SRW.RUN_REPORT passes the commandline arguments as a character string. Any values which are not characters must be converted to characters (e.g., to_char(:empno)converts EMPNO, with a datatype of Number, to characters). Also, the string passed to R25RUN must follow the syntax and casesensitivity rules for your operating system. If your platform does not use a command line, procedures for batch execution may vary. See your Developer/2000 Installation Guide. For more information on R25RUN syntax, see R25RUN in Chapter 1 of the Reports Reference Manual. Notice that SRW.RUN_REPORT is not the only Oracle Reports packaged PL/SQL procedure used by the function SENDIT. The following other procedures are also called:

SRW.RUN_REPORT_FAILUREan exception raised when the procedure SRW.RUN_REPORT fails. It stops program execution and allows you to take action. SRW.MESSAGESa procedure enabling you to create your own error messages SRW.PROGRAM_ABORTan exception ending program execution

For more information on using Oracle Reports packaged procedures in your reports, refer to Packages in Chapter 13 of the Reports Reference Manual. 4. Select File>Run. Accept the Runtime Parameter Form. After a moment, the Previewer appears with the twocolumn output of mailit.rdf. The output of empdata.rdf has already been mailed to its various destinations via Oracle*Mail in the form of an attached Postscript file, and is ready to be received and printed.

Advanced Reports

6 65

Conditional Form Letter Report

Distinguishing Features

This example report is based on the following scenario: Summit Sporting Goods is having a picnic for all employees on June 15. On the evening of that same day, a special dinner is also planned for Summits top sales representatives. The president of Summit Sporting Goods wants you to generate a form letter that does the following:

invites all employees to the picnic invites sales representatives with more than $500 in commissions to the dinner

He wants a conditional form letter, which formats and displays different sections of a form letter report based on whether certain criteria are met.

6 66

Building Reports Manual

Concepts

Conditional printing is useful when you want to display a section of a report only if certain conditions are met at run time. Conversely, you may wish to use conditional printing to suppress certain information for those who dont need it. This report uses one query to select all data. This report uses the form letter layout style. Youll also create the various pieces of boilerplate that will comprise the letter. To govern the printing of these boilerplate objects, youll use vertically collapsing anchors and PL/SQL format triggers to conditionally produce different form letters for employees who meet the specified criteria. To see a sample conditional form letter, open the Oracle Reports example report named condfrmb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Data Relationships Layout

Organization

Below is the data model for this report.

Steps to Build this Report

Queries

1.

Create the following query named Q_Employee:


SELECT ENAME, COMM FROM EMP ORDER BY ENAME

Default Layout

2.

Select the default layout style Form Letter.

Advanced Reports

6 67

Layout Editor

3. 4.

Select and resize the R_Employee repeating frame to a height of about 6 inches. Type the following four boilerplate text objects in the Layout editor. Begin typing the first block of boilerplate in the boilerplate object created for &F_ENAME and &F_COMM. Either delete the two field references or type over them. After you finish each block, start the next at the left margin and about .25 inch down. Press return at the end of each line.

Name: B_EMPLOYEE

Dear Employee &F_ENAME, Mark your calendar! You are invited to attend the Summit Sporting Goods annual picnic on June 15, from 11:00 AM to 6:00 PM. Be prepared for lots of food, lots of entertainment, and lots of fun.

Name: B_1

Because youre one of our top sales representatives, we would like to invite you to a celebration dinner after the picnic. Employees such as yourself brought in over $10 million in increased revenues this year, a 15% increase over last year. The dinner will be held at the City Inn from 7:00 PM to midnight. Dinner will be served at 7:30 PM. Please reply to Human Resources if you plan to attend.

Name: B_2

We would also like to take this opportunity to thank you for all of your efforts over the last year. As a result of your hard work, company revenues increased 15%.

Name: B_3

I look forward to seeing you there! J. King President Summit Sporting Goods

6 68

Building Reports Manual

Boilerplate

5.

Rename the boilerplate objects as follows: Old Name B_EMPLOYEE B_1 B_2 B_3 New Name B_ALL B_SALESREP B_ALL2 B_ALL3

6.

Anchor the top left corner of B_ALL2 to the bottom left corner of B_SALESREP. Then anchor the top left corner of B_ALL3 to the bottom left corner of B_ALL2. In turn, select each anchor and doubleclick on one of its endpoints to display its Anchor dialog box. Activate Collapse Vertically for both anchors. If one of the parent boilerplate objects does not display, its anchored object will move upward, filling the empty space where the parent object would otherwise print. Select all boilerplate objects, then select the Line Color tool and select No Line to remove their borders. Display the property sheet for B_SALESREP, go to General Layout:Format Trigger.... and select Edit... Edit the template.
function B_SalesrepFormatTrigger return boolean is begin if :comm >= 500 then return(TRUE); else return(FALSE); end if; end;

7.

8. 9.

This boilerplate will print only in the letters to employees whose commissions are greater than $500. 10. Display the property sheet for B_ALL2 and display the Program Unit editor. Edit the template provided.
function B_ALL2FormatTrigger return boolean is begin if ((:comm < 500) or (:comm is null)) then return(TRUE); else return(FALSE); end if; end;

This boilerplate will print in the letters to all other employees. The layout is shown in the next figure.

Advanced Reports

6 69

Compile, save, and run your report. Page through the form letters to see that some have the dinner invitation while others have the thank you message. Note: When viewing this report on your screen, you may wish to specify a Destination Type of Preview. Your report output will display as though using Postscript fonts instead of screen display fonts, and you can get a clearer indication of the appearance (e.g., line wrapping) of the printed report. In addition, when you print a conditional form letter report on stationery as illustrated, be sure to take into account the position of the letterhead, etc., when creating the layout so the text of the letter fits into the overall design of the stationery.

6 70

Building Reports Manual

Conditional Highlighting Report

Distinguishing Features

This example report demonstrates two methods for highlighting data in your report. In the first method, for use with monochrome monitors or when printing monochrome reports, the records for all employees whose salaries are greater than $2000 are highlighted with bolding and borders. In the second method, for use with color monitors, the records for all employees whose salaries are greater than $2000 are highlighted using color patterned fills, and borders.

Concepts
Data Relationships Layout

Conditional highlighting reports highlight specified portions of the output when certain criteria are met. This report uses one query to fetch all data. This reports uses a tabular layout style. To add conditional highlighting, youll use a packaged Oracle Reports PL/SQL procedure (SRW.SET_ATTR) in field format triggers to determine which names and salaries will be highlighted in the report output. To see a report that performs conditional highlighting for monochrome reports, open the Oracle Reports example report named condhilb.rdf.

Advanced Reports

6 71

To see a report that performs conditional highlighting using color, open the Oracle Reports example report named condcolr.rdf. For details on how to open them, see How to Access Demo Reports on page 4 2.

Organization

Below is the data model for this report.

Steps to Build this Report

Queries

1.

Create a query named Q_Highlight with a SELECT statement of:


SELECT EMPNO, ENAME, SAL FROM EMP ORDER BY EMPNO

Default Layout

2.

Create a default tabular layout as shown by the next figure.

6 72

Building Reports Manual

Next, youll add conditional formatting attributes to the F_ENAME and F_SAL fields. To do this, youll define a maska collection of formatting attributes applied to the current frame, repeating frame, field, or boilerplate objectbut only when certain criteria are met. Display the property sheet for F_ENAME and go to General Layout:Format Trigger.... Select Edit... and modify the template provided.
function F_enameFormatTrigger return boolean is begin if :sal >= 2000 then SRW.ATTR.MASK := SRW.WEIGHT_ATTR + SRW.FACE_ATTR; SRW.ATTR.WEIGHT := SRW.BOLD_WEIGHT; SRW.ATTR.FACE := helvetica; SRW.SET_ATTR (0, SRW.ATTR); end if; return (TRUE); end;

SRW.ATTR.MASK, the mask you are creating, will apply a new value for text weight (SRW.WEIGHT_ATTR), and a new value for the text face, or font (SRW.FACE_ATTR). The values are bold (SRW.BOLD_WEIGHT), and Helvetica, and will apply only if the value in the SAL column is greater than or equal to two thousand. 3. Create the following format trigger for F_SAL (Hint: Copy and paste from the previous trigger):
function F_salFormatTrigger return boolean is begin if :sal >= 2000 then SRW.ATTR.MASK := SRW.WEIGHT_ATTR + SRW.FACE_ATTR + SRW.BORDERWIDTH_ATTR + SRW.FBCOLOR_ATTR + SRW.BORDPATT_ATTR; SRW.ATTR.WEIGHT := SRW.BOLD_WEIGHT; SRW.ATTR.FACE := helvetica; SRW.ATTR.BORDERWIDTH := 0; SRW.ATTR.FBCOLOR := BLACK; SRW.ATTR.BORDPATT := SOLID; SRW.SET_ATTR (0, SRW.ATTR); end if; return (TRUE); end;

Advanced Reports

6 73

The above trigger adds more attributes to the mask. Salary values over 2000 will also be surrounded by a black border. Specifying a width of 0 (zero) for the border causes it to be of the minimum displayable width. You can achieve the same effect by not specifying a border width at all, since Oracle Reports assumes that all objects it creates have borders of at least the minimum displayable width. However, the borders it creates are also transparent, so you must specify a border color and pattern. Note: The font you choose must be on your system. We have chosen Helvetica for convenience; choose an appropriate font for your report. For a complete list of attributes and their possible values, see The Oracle Reports PL/SQL Package: SRW in Chapter 13 in the Reports Reference Manual. 4. Give F_SAL a format mask of NNN0.00. Save and run your report. Depending on the font you chose, the affected report values may be cropped. If so, go back to the Layout editor and enlarge the F_ENAME and F_SAL fields slightly. The format trigger above will work with both monochrome and color monitors. If you have a color monitor or if you are designing a report on a monochrome monitor but intend to print in color printer, modify the format trigger to include specifications for colors (for a complete list of the patterns and colors provided by Oracle Reports, and their mask values, see Pattern and Color Palettes in Appendix F in the Oracle Report Reference Manual). 5. Create the following format trigger for F_ENAME (Hint: Copy and paste from the previous trigger):
function F_enameFormatTrigger return boolean is begin if :sal >= 2000 then SRW.ATTR.MASK := SRW.WEIGHT_ATTR + SRW.GCOLOR_ATTR + SRW.FILLPATT_ATTR + SRW.FFCOLOR_ATTR; SRW.ATTR.WEIGHT := SRW.BOLD_WEIGHT; SRW.ATTR.GCOLOR := MAGENTA; SRW.ATTR.FILLPATT := GRAY10; SRW.ATTR.FFCOLOR := BLUE; SRW.SET_ATTR (0, SRW.ATTR); end if; return (TRUE); end;

6 74

Building Reports Manual

6.

Create the following format trigger for F_SAL (Hint: Copy and paste from the previous trigger):
function F_salFormatTrigger return boolean is begin if :sal >= 2000 then SRW.ATTR.MASK := SRW.WEIGHT_ATTR + SRW.GCOLOR_ATTR + SRW.FILLPATT_ATTR + SRW.FFCOLOR_ATTR + SRW.BORDERWIDTH_ATTR + SRW.FBCOLOR_ATTR + SRW.BORDPATT_ATTR; SRW.ATTR.WEIGHT := SRW.BOLD_WEIGHT; SRW.ATTR.GCOLOR := MAGENTA; SRW.ATTR.FILLPATT := GRAY10; SRW.ATTR.FFCOLOR := BLUE; SRW.ATTR.BORDERWIDTH := 0; SRW.ATTR.FBCOLOR := BLUE; SRW.ATTR.BORDPATT := SOLID; SRW.SET_ATTR (0, SRW.ATTR); end if; return (TRUE); end;

The new values in the format masks refer to the following attributes: SRW.GCOLOR_ATTRtext color SRW.FILLPATT_ATTRthe pattern used for the fields fill SRW.FFCOLOR_ATTRthe foreground color of the fill The background color is left as the default, but you can also specify a new background color for the fill. You can also specify patterns and background colors for borders. For a complete list of attributes and their possible values, see The Oracle Reports PL/SQL Package: SRW in Chapter 13 in the Reports Reference Manual. Note: You can run a color report on a monochrome monitor; colors and patterns will map to shades of gray. Compile, save, and run your report.

Advanced Reports

6 75

Static Graphics Report

Distinguishing Features Concepts

This sales report includes an imported Summit logo and a graphic drawn within Oracle Reports. Oracle Reports provides several ways to display graphics and images in reports. With certain methods you can display objects that are staticthat is, saved with the report definition. One type of static graphic is a drawing or image, stored in a file, that you import into your report layout. When a drawing or image stored in a file is imported into a report, it becomes a piece of boilerplate and is saved in the report definition. The object will always appear in the report output exactly as when first

6 76

Building Reports Manual

imported; any future changes made to the file will not appear. Other static graphics include lines and shapes you can create in the Layout and Parameter Form editors using the tools in the Tool palette. Data Relationships Layout This report selects its data using two queries linked together in a master/detail relationship. This report uses a master/detail layout style, which youll modify slightly. Next, youll add graphics in the margin, then create a boilerplate object and surround it with a border. For this report youll modify two format masks. To see a sample static graphics report, open the Oracle Reports example report named staticb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Optional

Organization

Youll create queries to build this report. The two queries are linked in a master/detail relationship. Youll also create a break group.

Advanced Reports

6 77

Steps to Build this Report

Queries

1.

Create a query named Q_Salesrep with a SELECT statement of:


SELECT EMPNO, REPID, NAME, ADDRESS, CITY || , || STATE || || ZIP LOCATION, AREA || || PHONE, CREDITLIMIT FROM EMP, CUSTOMER WHERE EMPNO=REPID ORDER BY REPID, NAME

2.

To the right of Q_Salesrep, create a second query named Q_Sales with a SELECT statement of:
SELECT REPID, PRODNAME, AMOUNT FROM SALES ORDER BY REPID, PRODNAME

Link Q_Sales to its parent group, G_Salesrep, via REPID and REPID1. Groups 3. 4. Use EMPNO to create a new group above G_Salesrep. Name it G_Employee. Display the margin areas of your report (remember, youll need to open the Layout editor from the Object Navigator or the Tools menu) and resize them so that you have one inch margins on all sides. Redisplay the report body. Select the Master/Detail layout. Deselect columns REPID and REPID1, and change the label of EMPNO to Sales Rep.# and of AREA_PHONE to Phone. Make the following column width changes: Column NAME ADDRESS LOCATION AREA_PHONE AMOUNT Width 30 30 25 40 12

Default Layout

5.

6.

Accept the Default Layout dialog box. 7. Redisplay the margin area and select Edit>Import>Image... to display the Import Image dialog box. Here you specify the type of image you wish to import and where its stored.

6 78

Building Reports Manual

8.

Ensure that File is selected, and select TIFF from the list of format values (Note: Selecting the format yourself is not necessary, but more efficient). Display the list of values for image quality and choose a new one, if desired. Select Browse... to display the Open File dialog box. Go to the reqfiles directory and select summitsg.tif. Accept the Open File dialog, then the Import Image dialog. The Summit Sporting Goods logo is imported into the upper left corner of the Layout editor. The logo should already be selected (if its not, click on it once). Grab the lower right handle of the logo and shrink it to a little more than three inches long and two inches high so that it overlaps the upper left corner of the report body.

9.

10. Next, return to the body of the report layout (the logo disappears), and, first placing the mouse cursor in the M_Employee_GRPRF frame, drag the entire default layout about .25 inch to the right and about 1.25 inches down. Moving the layout objects ensures that the logo will not overwrite any of the data. Deselect all of the objects. 11. Use the choices under the Format menu to select a font as you normally would on your platform (well use Arial). Select the Text tool in the Tool palette. Starting about 3.5 inches across the page and about .25 inch down the page, create a boilerplate text object about one inch high and about three inches long. Type the following text in the boilerplate object:
Remember, the annual Summit Sales Conference is just a few weeks away. Register today! Call 18001234567 for details.

12. While still in text mode, highlight the second and third sentences of boilerplate. Select a different text style and weight for the highlighted text (were using bold italic). One option is to select Format>Alignment and centeralign the text. Another option is to resize the boilerplate object to make the text wrap the way you want. 13. Make sure the boilerplate remains selected and select the Line Color tool. Select a color from the color palette. Next, select Format>Line and choose a border width. Well use a onepointwide line. Note: If your platform supports patterns for borders, you can also use the Pattern Palette to give the border itself a pattern.

Advanced Reports

6 79

Rectangle Tool

14. Select the Rectangle tool in the Tool palette and draw a rectangle that frames your new boilerplate text. Toggle Confine Mode off, then select Arrange>Send to Back to place the new rectangle behind the boilerplate text. Notice that the border of the rectangle is the width you specified. If your platform does not support patterns for borders, you can select a patterned fill for the rectangle, as we did. 15. Set the maximum records per page of R_Employee to 1. 16. Change R_Salesreps vertical spacing to 0.25. Check Page Protect.

Repeating Frames

Fields

17. Change the format masks of F_CREDITLIMIT and F_AMOUNT to


$NN,NN0.00.

Your completed report layout, including the margin area, should appear similar to the figure shown below.

Save and run your report.

6 80

Building Reports Manual

Dynamic Graphics Report

Distinguishing Features

This employee report includes a bar chart that displays monthly revenues for the company. Importing or drawing this chart is not recommended, as the data in it changes monthly. You have two options to ensure that the data it displays remains current: you can link to the bar chart or you can specify the name of the graphic you want to display at runtime as a parameter value

Concepts

In the Static Graphics Report, you learned how to both import and create drawings and images. You then saved the images and drawings in your report definition as static objects. This section discusses how Oracle Reports enables you to link to and display drawings and images that are dynamic.

Advanced Reports

6 81

Since the objects are stored outside of Oracle Reports, any changes made to them will be reflected in your report output at runtime. Data Relationships One way to display dynamic graphics in a report involves creating a database column that stores the names of the names of the graphics files you want to display. Oracle Reports provides a function called Read from File which enables you to pull the latest versions of the graphics into your report. When you activate Read from File for a column listing filenames, Oracle Reports displays the graphic contained within the named file, rather than the filename itself. Layout Another way to include dynamic graphics in your report is to use Link File. Link File enables you to create a boilerplate object used to contain external boilerplate, including graphics and text. To see a sample dynamic graphics report, open the Oracle Reports example report dynamicb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Below is the data model for this report.

6 82

Building Reports Manual

Steps to Build this Report

Before you create this report, copy the following TIFF images from the images directory into either the directory from which youll be running Oracle Reports or any specified working directory: new_york.tif, boston.tif, dallas.tif, chicago.tif. They must be in the current or working directory when you run this report for Oracle Reports to find them. 1. Create a query named Q_Pictures with a SELECT statement of:
SELECT D.DEPTNO, DNAME, PICTURE FROM DEPT D, PICTURES P WHERE D.DEPTNO=P.DEPTNO ORDER BY D.DEPTNO

Queries

2.

To the right of Q_Pictures, create a second query named Q_Employee with a SELECT statement of:
SELECT DEPTNO, ENAME, JOB, HIREDATE FROM EMP ORDER BY DEPTNO, ENAME

Link Q_Employee to G_Pictures via DEPTNO and DEPTNO1. 3. Open the property sheet for the column PICTURE. On the General tab, make sure the Read from File check box is checked. The PICTURE column in the PICTURES table contains filenames as its record values. By checking Read from File for PICTURE, you tell Oracle Reports to read the filename listed in the column and import that file into the field whose source is PICTURE. 4. Display the list of values next to the checkbox and select Image, then accept the property sheet. This specifies the type of data contained in the files. Select a Master/Detail layout, deselect DEPTNO and DEPTNO1, and delete the label for PICTURE. Accept the Default Layout dialog box. Enlarge both the M_Pictures_GRPF frame and the R_Pictures repeating frame until they are about 5.5 inches wide. Move the F_PICTURE field out to the right edge. Make sure Confine mode is toggled on. Drag the entire layout about 3 inches down and about .5 inch to the right. Now you have enough room to add a bar chart at the top of the report. Select the Link File tool in the Tool palette. Create a rectangular boilerplate object about 5 inches wide and about 3 inches high. The bar chart will appear in this boilerplate.

Default Layout

5.

Layout Editor

6.

7.

8.

Advanced Reports

6 83

9.

Open the property sheet for the boilerplate object, and rename it B_REVENUE. Notice the fields for Link File and Format. When you create a piece of boilerplate using the Link File tool, Oracle Reports automatically knows that the object will link to and external object stored in either the database or in a file.

10. Select List... to display the File Open dialog box. Select revenues.odf from the reqfiles directory and accept the dialog box. 11. For format, select Oracle Drawing Format from the list of values. 12. Under General Layout:Print Condition, change B_REVENUEs print condition to All so that it will appear on every page of the report. Then accept the property sheet. 13. Make sure the border of B_REVENUE is transparent. Your report layout should appear similar to the figure shown below.

Repeating Frames

14. For R_Pictures, set the maximum records per page to 1. Save and run your report.

6 84

Building Reports Manual

Related Concepts: Selecting the Graphic at Runtime

Distinguishing Features

The output of the example report above appears to be exactly the same as the output for the first Dynamic Graphics report. Thats because it is. The difference between the two reports lies in how revenues.odf is pulled into the report and displayed. In dynamicb.rdf, you imported the image revenues.odf into your report to ensure that your report displayed the most current version of the image. But what if you not only have an image that may change, but a list of images from which youd like to choose at runtime? You can use a variation of the technique you used in dynamicb.rdf to display the images whose filenames were also column values. However, instead of selecting a column with fixed values, youll create a column whose value is determined by a parameter, then enter the name of the image you want to display in that parameter at runtime.

Concepts

Advanced Reports

6 85

Data Relationships Layout

The data selected in this report are exactly the same as in the report dynamicb.rdf. Youll also create a formula column and a parameter. The layout for this report is similar to the layout for dynamicb.rdf, except you wont need to create a piece of boilerplate. You will need to resize several frames and fields. To see a sample dynamic graphics report, open the Oracle Reports example report dynam1b.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Below is the data model for this report.

Steps to Build this Report

Before you create this report, copy the following TIFF images from the images directory into either the directory from which youll be running Oracle Reports, or any specified working directory: new_york.tif, boston.tif, dallas.tif, chicago.tif. They must be in the current directory or working directory when you run this report for Oracle Reports to find them. You can also copy revenues.odf, but this is not required. 1. This report uses the same queries as dynamicb.rdf. They are
Q_Pictures: SELECT D.DEPTNO, DNAME, PICTURE FROM DEPT D, PICTURES P WHERE D.DEPTNO=P.DEPTNO ORDER BY D.DEPTNO

Queries

6 86

Building Reports Manual

And Q_Employee:
SELECT DEPTNO, ENAME, JOB, HIREDATE FROM EMP ORDER BY DEPTNO, ENAME

Link Q_Employee to its parent group, G_Pictures, via DEPTNO and DEPTNO1. Parameters 2. In the Object Navigator, select the User Parameters node and create a parameter. Name it PICS_PARM and give it a datatype of Character, a width of 50 and an initial value of revenues.odf. Width can vary, but must be sufficient to contain the entire directory path and filename of revenues.odf. Create a formula column in the G_Pictures group. Open the property sheet for the column and rename it FORM_PIC. Assign it a datatype of Char, select Formula:Edit..., and edit the template provided.
function FORM_PICFormula return Char is begin return (:pics_parm); end;

Columns

3.

This assigns the value of the parameter PICS_PARM to the column. 4. Check the Read from File check box for FORM_PIC. Then assign it a width of 50 (or, again, a sufficient width to contain the full directory path and filename of revenues.odf), and a format of Oracle Format (Drawing). Accept the property sheet. The settings specified above ensure that the column FORM_PIC will use as its source the value in the parameter PICS_PARM. In addition, it will read the parameter value as a filename and pull that file into the field whose source is FORM_PIC. 5. Open the property sheet for the column PICTURE and check the Read from File check box. Select a format of Image from the list of values and accept the property sheet. Select a Master/Detail layout, deselect DEPTNO and DEPTNO1, and delete the labels for PICTURE and FORM_PIC. Notice that the default widths for FORM_PIC and PICTURE are now 20 and their heights are 10. This is the default for columns that will be displaying images. Accept the Default Layout dialog box. Resize the M_Pictures_GRPFR frame and the R_Pictures repeating frame until they are 6 inches wide and 7 inches high.

Default Layout

6.

Layout Editor

7.

Advanced Reports

6 87

8.

Move the F_PICTURE field to the right side of the layout and down beside the M_Employee_GRPFR. Move the F_DNAME field and boilerplate down until it is directly above M_Employee_GRPFR. Select the F_FORM_PIC field and enlarge it until it is about 5 inches wide and 3 inches high to ensure it is large enough to display revenues.odf. If necessary, adjust the positions of the other layout objects further. Your layout should look like the next figure.

9.

Repeating Frames

10. For R_Pictures, set the maximum records per page to 1. Save and run your report. If you wish, you can specify another filename in PICS_PARM. However, if you specify a file that is not in Oracle Drawing Format, be sure to change the setting in FORM_PICS to the appropriate format before you try to run the report.

6 88

Building Reports Manual

Nested Matrix Report

Distinguishing Features Concepts

In the example nested matrix report shown above, the cross product is capable of displaying every possible value for three dimensionstwo down (YEAR and DEPTNO) and one across (JOB). A nested matrix report is a matrix report which contains more than the usual two dimensions (across and down) of a simple matrix. You can create nested matrix reports with any number of queries. In Method One, youll create the example nested matrix report using one query. In Method Two, youll use multiple queries. In the Related Concepts, you will use not only group hierarchy to nest one dimension within another, but youll also create a true parent/child relationship between the relevant groups by explicitly creating a new group and placing it within the cross product and above the other group. This will restrict the records displayed to only those for which data exists. Note: The queries used to select data for these sample matrix reports are not intended as definitive examples of matrix queries. If you are concerned with performance issues, for example, there are alternate methods of querying data that can improve the performance of a matrix report. For more information, see Matrices in Chapter 17 of the Reports Reference Manual.

Advanced Reports

6 89

Data Relationships

This report uses a matrix with three dimensions, created by including three columns in the cross product. The order in which the two down dimensions will be displayed is based upon the order in which you position their corresponding groups within the cross product; i.e., of YEAR and DEPTNO, the two groups printing down, youll position YEAR to the left of DEPTNO. This nests DEPTNO inside of YEAR, and causes all records for DEPTNO to appear for each value of YEAR, regardless of whether that department has any data for that year. This report uses a matrix layout style. To see a sample nested matrix report using one query, open the Oracle Reports example report named nested1b.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Layout

Method One (onequery):

Below is the data model for this report.

Steps to Build this Report

Queries

1.

Create a query named Q_Salary with a SELECT statement of:


SELECT TO_CHAR(HIREDATE,YY) YEAR, DEPTNO, JOB, SUM(SAL) FROM EMP GROUP BY TO_CHAR(HIREDATE,YY), DEPTNO, JOB ORDER BY TO_CHAR(HIREDATE,YY), DEPTNO, JOB

6 90

Building Reports Manual

Groups

2.

Drag the G_Salary group down to give yourself more room and create these three groups using three columns:
G_Year, containing the YEAR column G_Dept, containing the DEPTNO column G_Job, containing the JOB column

Cross Product Tool

Select the Cross Product tool in the Tool palette, then draw a box around G_Year, G_Dept, and G_Job. Name this new group G_Cross. G_Cross is the cross product group in the matrix. G_Year, G_Dept, and G_Job are now child groups of the cross product. G_Salary, which is below the cross product, remains a child group in the group hierarchy. 3. Select a Matrix layout. Change G_Jobs repeat setting to Across, and the widths of YEAR to 2 and of SUM_SAL to 10 and accept the dialog. Your report layout should look like the figure below.

Fields

4. 5.

Change the format mask of F_SUM_SAL to $NNN,NN0.00. Set F_JOBs alignment to Right. This aligns the job values with the salaries. Change the report page width to 10 inches.

Report Properties

6.

Save and run your report.

Method Two (multiquery):

Youll use four queries to build this report. The four queries result in four default groups, three of which youll surround with a cross product, making five groups in all for the report. The fourth default group will remain below the cross product.

Advanced Reports

6 91

To see a sample nested matrix report using four queries, open the Oracle Reports example report named nestedmb.rdf.

Steps to Build this Report

Queries

1.

Create a query named Q_Year with a SELECT statement of:


SELECT DISTINCT TO_CHAR(HIREDATE,YY) YEAR FROM EMP

2.

To the right of Q_Year, create a second query named Q_Dept with a SELECT statement of:
SELECT DISTINCT DEPTNO FROM EMP

3.

To the right of Q_Dept, create a third query named Q_Job with a SELECT statement of:
SELECT DISTINCT JOB FROM EMP

6 92

Building Reports Manual

4.

Move about three inches below the existing queries and create a fourth query named Q_Salary with a SELECT statement of:
SELECT TO_CHAR(HIREDATE,YY) YEAR, DEPTNO, JOB, SUM(SAL) FROM EMP GROUP BY TO_CHAR(HIREDATE,YY), DEPTNO, JOB ORDER BY TO_CHAR(HIREDATE,YY), DEPTNO, JOB

Groups

5.

Select the Cross Product tool in the Tool palette, then draw a box around G_Year, G_Dept, and G_Job. Name this new group G_Cross. G_Cross is the cross product group in the matrix. G_Year, G_Dept, and G_Job are now child groups of the cross product. G_Salary, which is below the cross product, remains a child group in the group hierarchy.

Links

6.

Create three links with the following parentchild relationship information: Parent Group SQL Clause Parent Column(s) YEAR DEPTNO JOB Condition = = = Child Column(s) YEAR1 DEPTNO1 JOB1

G_Cross WHERE G_Cross WHERE G_Cross WHERE Default Layout 7.

Select a Matrix layout, change G_Jobs repeat setting to Across, deselect YEAR1, DEPTNO1 and JOB1, and change the widths of YEAR to 2 and of SUM_SAL to 10. Your report layout should look similar to the figure below.

Fields Report Properties

8. 9.

Change the format mask of F_SUM_SAL to $NNN,NN0.00, and change F_JOBs alignment to Right. Change the report page width to 10 inches.

Advanced Reports

6 93

Related Concepts: Multiquery Matrix with Break

Distinguishing Features

This report shows the same data as the Nested Matrix Report but, unlike the Nested Matrix Report, it displays only records for which data exists. No blank records are displayed. Thus, for 1980, only salary information for department 20 is shown. Though similar to a nested matrix report, this report has one important difference: a userdefined parentchild, or master/detail, relationship within the cross product. You explicitly create a new group and place it within the cross product and above the other groups. Neither of the nested matrix reports you just built contained a break. Oracle Reports had to display every possible combination of values in the cross product, regardless of whether there were any actual values in that combination. This resulted in matrices that were full of holes. To prevent this, youll define a break between YEAR and DEPTNO. This report uses matrix layout. To see a sample multiquery matrix with break, open the example report named xprodmdb.rdf. For details on how open it, see How to Access Demo Reports on page 4 2.

Concepts

Data Relationships

Layout

6 94

Building Reports Manual

Organization

The next figure shows the data model for this report.

Steps to Build this Report

Queries

1.

Create a query named Q_Dept with a SELECT statement of:


SELECT TO_CHAR(HIREDATE,YY) YEAR, DEPTNO FROM EMP GROUP BY TO_CHAR(HIREDATE,YY), DEPTNO ORDER BY TO_CHAR(HIREDATE,YY), DEPTNO

2.

To the right of Q_Dept, create a second query named Q_Job with a SELECT statement of:
SELECT DISTINCT JOB FROM EMP

3.

Below Q_Dept and Q_Job and their default groups, create a third query named Q_Salary with a SELECT statement of:
SELECT DEPTNO, JOB, SUM(SAL), TO_CHAR(HIREDATE,YY) YEAR5 FROM EMP

Advanced Reports

6 95

GROUP BY DEPTNO, JOB, TO_CHAR(HIREDATE,YY) ORDER BY DEPTNO, JOB, TO_CHAR(HIREDATE,YY)

Data Model Editor

4. 5.

Drag YEAR above G_Dept to create a group named G_Year. Select the Cross Product tool and draw a box around G_Year, G_Dept, and G_Job. Name this new group G_Cross. G_Cross is the cross product group in the matrix. G_Year, G_Dept, and G_Job are children of the cross product. Below G_Cross, G_Salary is the lowest in the group hierarchy.

6.

Create three links with the following parentchild relationships: Parent Group SQL Clause Parent Column(s) YEAR DEPTNO JOB Condition = = = Child Column(s) YEAR5 DEPTNO1 JOB1

G_Cross WHERE G_Cross WHERE G_Cross WHERE Default Layout 7.

Select a Matrix layout, change G_Jobs repeat setting to Across, deselect YEAR5, DEPTNO1 and JOB1, and change the widths of YEAR to 2 and of SUM_SAL to 10. Your report layout should appear as shown in the next figure.

Fields Report Properties

8. 9.

Change the format mask of F_SUM_SAL to $NNN,NN0.00, and change F_JOBs alignment to Right. Change the reports page width to 10 inches.

Save and run your report.

6 96

Building Reports Manual

Matrix Break Report

Distinguishing Features Concepts

This report shows department, job, and salary information for each employee by the year they were hired using a matrix break format. A matrix break report is a combination of matrix and break report formats. Essentially, a matrix report is printed for each master group value. A matrix break is similar to the multiquery nested matrix with break discussed earlier, except that in a matrix break report, the parent exists above the cross product, while in a multiquery nested matrix with break report the parent/child relationship exists within the across or down dimension of the cross product. Note: The queries used to select data for these sample matrix reports are not intended as definitive examples of matrix queries. If you are concerned with performance issues, for example, there are alternate methods of querying data that can improve the performance of a matrix report. For more information, see Matrices in Chapter 17 of the Reports Reference Manual.

Data Relationships

This example of a matrix break report uses one query and at least five groups. At least one group is placed above the cross product to serve as the break group. This report uses a matrix layout style.

Layout

Advanced Reports

6 97

To see a sample matrix break report, open the Oracle Reports example report named matrxbkb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Below is the data model for this report.

Steps to Build this Report

Queries

1.

Create a query named Q_Salary with a SELECT statement of:


SELECT TO_CHAR(HIREDATE,YY) YEAR, DEPTNO, JOB, SUM(SAL) FROM EMP GROUP BY TO_CHAR(HIREDATE,YY), DEPTNO, JOB ORDER BY TO_CHAR(HIREDATE,YY), DEPTNO, JOB

Groups

2.

Drag the G_Salary group down to give yourself more room and create these three groups using three columns:
G_Year, containing the YEAR column G_Dept, containing the DEPT column G_Job, containing the JOB column

Cross Product Tool

3.

Select the Cross Product tool in the Tool palette, then draw a box only around G_Dept and G_Job. Name this new group G_Cross.

6 98

Building Reports Manual

G_Cross is the cross product group in the matrix. G_Dept and G_Job are now the child groups of G_Cross. G_Year, which is above G_Cross, is the parent group of the cross product in the group hierarchy. G_Salary remains a child group. 4. Select a Matrix layout, change G_Jobs repeat setting to Across, and change the widths of YEAR to 2 and of SUM_SAL to 10. Accept the dialog box. Your report layout should appear as shown in the figure below.

Fields Report Properties

5. 6.

Change the format mask of F_SUM_SAL to $NNN,NN0.00 and change F_JOBs alignment to Right to align job values with salaries. Change the reports page width to 10 inches.

Save and run your report.

Advanced Reports

6 99

Matrix with Summaries Report

Distinguishing Features Concepts

The example report above is a nested matrix report containing several summaries. All but one of the summaries are assigned to the cross product group. The final summary is a reportlevel grand total. When creating a matrix report that includes summaries, youll probably assign one or more of the summaries to the cross product. However, a summary assigned to the cross product will count all of the values that belong within the cross product if not restricted. To enable you to restrict such summaries, Oracle Reports provides the Product Order setting. Note: The queries used to select data for these sample matrix reports are not intended as definitive examples of matrix queries. If you are concerned with performance issues, for example, there are alternate methods of querying data that can improve the performance of a matrix report. For more information, see Matrices in Chapter 17 of the Reports Reference Manual.

6 100

Building Reports Manual

The Product Order for a matrix summary indicates the following:

The frequency of the summary. The frequency specifies the dimension groups for which to compute the summary (e.g., for each value of one of the dimensions). The order in which to compute the summary. The order specifies how to traverse the matrix in calculating the summary (top to bottom or left to right).

Data Relationships Layout

This matrix report uses the same data model as the nested matrix report, with summary columns added. This report uses a matrix layout style. To see a sample matrix with summaries report, open the Oracle Reports report named matrxsmb.rdf. For details on how to it, see How to Access Demo Reports on page 4 2.

Organization

Below is the data model for this report.

Advanced Reports

6 101

Steps to Build this Report

Queries

1.

Create a query named Q_Salary with a SELECT statement of:


SELECT TO_CHAR(HIREDATE,YY) YEAR, DEPTNO, JOB, SUM(SAL) FROM EMP GROUP BY TO_CHAR(HIREDATE,YY), DEPTNO, JOB ORDER BY TO_CHAR(HIREDATE,YY), DEPTNO, JOB

Groups

2.

Drag the G_Salary group down to give yourself more room and create three groups using three columns:
G_Year, containing the YEAR column G_Dept, containing the DEPTNO column G_Job, containing the JOB column

3.

Select the Cross Product tool in the Tool palette, then draw a box around G_Year, G_Dept, and G_Job. Name this new group G_Cross. G_Cross is the cross product group in the matrix. G_Year, G_Dept, and G_Job are now child groups of the cross product. G_Salary, which is below the cross product, remains a child group in the group hierarchy.

Columns

4.

Create the following summary columns, all in the G_Cross group: Name SUMYEAR SUMDEPT SUMJOB JOBTOTAL Function Sum Sum Sum Sum Source SUM_SAL SUM_SAL SUM_SAL SUM_SAL Reset At G_Year G_Dept G_Job G_Job Product Order G_Year G_Year, G_Dept G_Year, G_Job G_Job

In addition, create the following reportlevel summary: Name Function Source SUM_SAL Reset At Report

SUMTOTAL Sum

The value of Product Order in the table above is the level at which a new value is computed within a cross product. The ordering of groups in the Product Order field affects the order in which running summaries are computed, with the group having the lowest frequency appearing first.

6 102

Building Reports Manual

SUMYEAR and JOBTOTAL are restricted in their scope to summing the totals of SUM_SAL per a single group; they are grand totals of SUM_SAL per year and SUM_SAL per job, respectively. Therefore, the product order for SUMYEAR is simply G_YEAR, while the product order for JOBTOTAL is G_JOB. SUMJOB and SUMDEPT are more complicated; SUMJOB calculates the sum of SUM_SAL for each job in each year, and SUMDEPT calculates the sum of SUM_SAL for each department in each year. For both of these summaries, the value of Product Order has a greater relevance. SUMDEPT calculates a sum for each department in each year (involving G_Dept and G_Year). Year contains four records, for each of which Deptno changes three times. G_Year has a lower frequency than G_Dept; it changes less often. As a result, G_Year appears first in the Product Order field. SUMJOB is similar. SUMTOTAL, a reportlevel summary, needs no product order. Default Layout 5. Select the Matrix layout style, change G_Jobs repeat setting to Across, and change the widths of YEAR to 2 and of SUMTOTAL, SUMYEAR, SUMDEPT, SUMJOB, JOBTOTAL, and SUM_SAL to
10.

Your report layout should look similar to the figure below.

Fields

6.

Change the format masks of F_SUM_SAL, F_SUMYEAR, F_SUMDEPT, F_SUMJOB, and F_JOBTOTAL to $NN,NN0.00, and F_SUMTOTAL to $NNN,NN0.00. Change F_JOBs alignment to Right. Change the reports page width to 12 inches.

Report Properties

7.

Save and run your report.

Advanced Reports

6 103

ASCII File Report

Distinguishing Features

This report is essentially a dump of the order data for Summit Sporting Goods. The output, delimited by double quotes and commas, is written to a text file. No form feeds (i.e., page breaks) or other control characters will appear in the output, so the data file contains an unbroken stream of records and can easily be transferred to another operating system or platform, ready to be loaded into another database or similar application. This report uses a new printer definition file derived from dflt.prt, one of the printer definition files shipped with Oracle Reports. The new file is modified to prevent control characters in the report output. This report uses one query. All selected columns will be concatenated into one column using SQL character operators (||), delimited by a separatorsin this case, commasand surrounded with double quotes.

Concepts

Data Relationships

6 104

Building Reports Manual

Layout

This report uses a default tabular layout. Youll eliminate the margins in the layout, and display character cells in the Layout editor. Then youll resize your layout objects to fit within a the boundaries of a characterbased layout. In essence, Oracle Reports enables you to build a charactermode report using a bitmapped display. Once youve finished the report, you can execute it using either the charactermode runtime engine or, on platforms that support running a report in a different mode than the platform itself, with the parameter MODE set to Character. See your Developer/2000 Installation Guide to determine if your platform falls into this category. To see a sample report with no form feeds, open the Oracle Reports example report datafilb.rdf. For details on how to open it, see How to Access Demo Reports on page 4 2.

Organization

Below is the data model for this report.

Steps to Build this Report

Printer Definitions

1. 2.

Invoke a text editor and open the file dflt.prt. (See your Developer/2000 Installation Guide to learn the location of this file.) Move to the following line:
after page control(L)

Remove control(L) so the line appears as shown below:


after page

Advanced Reports

6 105

Removing the control sequence from the printer definition file will keep the output from breaking between pages when the report is formatted. 3. Character Mode Properties 4. 5. Save the modified dflt.prt file as no_ff and exit the text editor. Doubleclick on the icon representing your report to display the Report Properties property sheet. Go to the Character Mode tab. Set the page width as 66 and the height as 132 character units. Select Use Character Units in Designer, then select OK. The Layout editor will now display character cells in the editing region. Display the Layout editor and Select View>View Options>Rulers... to display the Ruler Settings dialog. Make sure Units is set to Character Cells and Grid Spacing is set to 1. The above steps convert your bitmapped editor into a facsimile of a charactermode editor. You can now design your report. Queries 7. Create a query named Q_Item with a SELECT statement of:
SELECT ||ORDID|| ,||ITEMID|| ,||PRODID|| ,||ACTUALPRICE|| ,||QTY|| ,||ITEMTOT|| ITEMS FROM ITEM ORDER BY ORDID

6.

This query inserts double quotes before and after each column, and a comma between each column. However, you could use any characters to delimit your data. Default Layout Layout Editor 8. 9. Keep the Tabular layout style, delete the label for ITEMS, and change its width to 60. Delete M_Item_GRPFR.

10. Make sure Confine mode is on and drag R_Item and its enclosed F_ITEMS field to the very top of the editor. 11. One at a time, select F_ITEMS and R_Item and resize the two objects so they fit within the first line of character cells in the Layout editor. Make sure the objects do not overlap onto the second line of character cells. You can use the Magnify tool to enlarge the editing region and make it easier to resize the layout objects.

6 106

Building Reports Manual

12. Show the margins of your report. Select the upper left corner of the body and resize it to the upper left corner of the editor to remove the top margin. Remove the bottom margin using the same method: select the lower left corner of the body and resize it to the lower left corner of the editor. Your report layout should appear as shown below.

Parameters

13. In the Object Navigator, expand the System Parameters node and enter the following initial values in the property sheets for the parameters listed below: Parameter Name DESTYPE DESNAME DESFORMAT MODE Initial Value File datafilb.lis no_ff character

14. Save your report, then either invoke Oracle Reports charactermode runtime engine and run the report, or run it from your bitmapped environment with MODE set to Character. (Be aware that the ability to run a report in a different mode than the supporting platform is not available on all platforms. See your Developer/2000 Installation Guide for details.) Note: Oracle Reports provides a printer driver called the Oracle Reports ASCII Driver to enable you to create character output. If your GUI supports the creation of character output, specify the Oracle Reports ASCII driver as you normally would specify printer drivers, then send your output to a file. For details on whether your GUI supports character output, and, if so, how to specify it, see your Developer/2000 Installation Guide. When you run the report, the fetched data is written to a commaseparated text file (i.e., an ASCII or EBCDIC file), with the values in each record delimited by double quotes. The records appear in a continuous stream, minus form feeds or unnecessary blank spaces.

Advanced Reports

6 107

6 108

Building Reports Manual

CHAPTER

Reports with New V2.5 Features


he demo reports in this chapter use features new to Oracle Reports 2.5, including multimedia, lists of values for parameters, usercreated buttons that can transform a regular matrix into a drilldown report, and more. The reports feature the following:

drilldown capabilities, parameter list of values, and ASCII output 7 5 multimedia 7 14 OLE2 integration 7 19 tracing and debugging report execution 7 23

Reports with New V2.5 Features

71

How to Use this Chapter

This chapter differs slightly from the two previous chapters, Introductory Reports, and Advanced Reports, in that its purpose is to demonstrate and explain the features new to Oracle Reports 2.5. As a result, this chapter assumes that you are an experienced Oracle Reports 2.0 user. You can use this chapter in the following ways:

Build all the reports in this chapter. This is a good way to familiarize yourself with several of the new features Oracle Reports 2.5 offers.

Find the features youd like to include in your reports and either build the demo reports or use the steps listed to guide you in the creation of your own reports.

We understand that the new features are the aspects of interest in these reports; therefore, when possible we have included base reports for you to modify instead of requiring you to build them. Instructions for tasks previously described in Chapters 5 and 6 are not provided. In addition, only icons representing new tools will be shown. If you decide to build the reports in their entirety, descriptions of their data models and layouts are included for your convenience. Pointers to similar reports in Chapters 5 and 6 are given if you need to refresh your memory.

How to Access the Reports

The reports you will build in this chapter are also shipped with Oracle Reports. Two types of reports are shipped:

the base reports to modify completed versions of the reports to examine

The table below lists each report and its associated base and completed versions. Case DrillDown Report Multimedia Report OLE2 Report Debugging Report Base Version drill.rdf, salesdt.rdf avi.rdf N/A debug.rdf Completed Version drildone.rdf, saledone.rdf avidone.rdf ole2.rdf debug.rdf

Open the base reports as described in How to Access Demo Reports on page 4 2. Open the completed reports as described in the next section.

72

Building Reports Manual

If You Use Windows and Oracle Forms

A form that launches each of the completed versions of the reports in this chapter is shipped with Oracle Reports. Doubleclick on the icon representing the form, Reports Launcher to invoke it. Launch the report you want to view by selecting the appropriate button. Oracle Forms manages your reports using the Oracle Reports Server. When a form first calls Oracle Reports, an icon representing the Server appears on your desktop. Doubleclick on the icon to display the Server as shown in the next figure. The Server provides a display of all the reports queued to run.

You can use the Oracle Reports Server to monitor the status of the reports, move reports up or down in the queue, and remove jobs from the queue. For more information on Server capabilities and usage, see see your Developer/2000 Installation Guide. In All Other Cases If you dont have access to Oracle Forms, or are on a different platform, invoke Oracle Reports and open the conpleted report you want to examine as How to Access Demo Reports on page 4 2. During the course of building the reports, you may be asked to create an object or objects using certain specified dimensions. These dimensions are merely guides. Due to the fact that font sizes, sizing algorithms, etc., differ from platform to platform, your object or objects may not appear exactly as shown in this manual.

Platform Specifics

Reports with New V2.5 Features

73

Feel free to either modify the sizes of the objects or choose a different font, as necessary. However, try to preserve the relative proportions of the objects shown. In addition, you may be asked to select certain fonts, text attributes, etc.for example, you may be instructed to create a report title, using a typeface of Helvetica, a font size of 12, and a weight and style of bold italic. The method used to select fonts is dependent upon your platform, and some or all of the fonts and text attributes may not be available. Choose the font and text attributes youd like. If you have a color monitor, play with the colors. Note: The shipped reports were created with color. If you use a monochrome monitor, Oracle Reports will map the colors to shades of gray. Also, if the fonts used to create this report are not on your machine, Oracle Reports will map them to available fonts, based on the specifications included in the fontmapping file called uifont.ali. You can customize this file to ensure that the fonts selected are the fonts you want. For more information about customizing the uifont.ali file, see Font Mapping File in Appendix A of the Reports Reference Manual. Finally, since Oracle Reports conforms to the native look and feel of the platform on which it is running, slight differences in naming of options or objects may occurfor example, to exit Oracle Reports, you may choose Quit or Exit, depending on your platform. These variations are slight, and you should have no problem determining what is appropriate for your platform.

74

Building Reports Manual

DrillDown Report with Parameter List of Values

New Features

This is a simple matrix report with buttons in all the cells that contain values. When pressed, each button calls another report, effectively enabling you to drill down to a deeper level of detail. The output of the drilldown report is displayed in its own Previewer. These two reports use the following features new to Oracle Reports 2.5:

usercreated buttons capable of executing actions in the Previewer userdefined lists of values for parameters ASCII output generation

Concepts

A drilldown report is actually two or more reports working together. The toplevel report, such as the matrix shown above, is like a master record, in that it can be used to launch a report that provides more details about the data in its current record. To provide more flexibility in the selection of details, you can add a button to the master report that contains a PL/SQL construct that calls the detail report and provides conditions for its execution.

Reports with New V2.5 Features

75

Generally, the detail report displays information related to the master. It can provide details for a single record (as in this example), a group of records, or the report as a whole. The master report links to the detail report by passing parameters that control the execution of the detail. To better control runtime selection of parameter values, you can create your own list of values for the parameters in the detail report.

Prerequisite Reports

This example requires two reports: drill.rdf (the master report), and salesdt.rdf (the detail report). Both reports are provided, but if you want to recreate them, a description of each report is given below. The report drill.rdf is a simple, onequery matrix report to which some graphical enhancements have been added. For steps to create a onequery matrix data model, see OneQuery Matrix on page 5 82.

drill.rdf

Query

Q_Customer:
select sum(itemtot) Total, e.ename Salesrep c.name Custname from customer c, ord o, item i, sales s, emp e where o.ordid = i.ordid and c.custid = s.custid and s.repid = e.empno group by e.ename, c.name

Data Model

The data model for drill.rdf is a typical matrix data model.

76

Building Reports Manual

Layout

The layout was created in the following manner:


a default matrix layout was created (for instructions, see OneQuery Matrix Report on page 5 82) an image was imported into the margin (for instructions, see Static Graphics Report on page 6 76) a piece of text boilerplate was added to the margin, new fonts and colors were assigned to column headings, and colored fills were assigned to several frames (for instructions, see Graphics and Text Report on page 5 75)

salesdt.rdf Query

The report salesdt.rdf is a master/master/detail report, also with minor modifications. Q_Sales_Det
select e.ename Salesrep, c.name Custname, i.qty Quantity, p.stdprice Price, o.orderdate Order_date, o.shipdate Ship_date from customer c, ord o, item i, sales s, emp e, price p where c.custid = o.ordid and o.ordid = i.ordid and c.custid = s.custid and s.repid = e.empno and i.prodid = p.prodid and upper(c.name) like upper(:P_custname) and upper(e.ename) like upper(:P_salesrep)

Notice the references to the two bind variables, P_CUSTNAME and P_SALESREP, in the last two lines of the query. When bind references are included in a query, Oracle Reports automatically creates parameters for them. Such parameters provide the means by which a master report passes data to a detail report. For details on creating parameters for your report, see Ranking Report on page 6 47. Data Model The data model for salesdt.rdf contains two break groups. A formula column (LINE_TOTAL) and a summary column (CUST_TOTAL) have also been added

Reports with New V2.5 Features

77

Layout

The layout was created in the following manner:


a default master/detail layout was created (for instructions, see Master/Detail Report on page 5 35) a piece of text boilerplate was added to the margin (for instructions, see Header and Footer Report on page 5 67) new fonts and colors were assigned to column headings and colored fills were assigned to several frames (for instructions, see Graphics and Text Report on page 5 75) a field was duplicated in the layout (for instructions, see Invoice Report on page 6 35)

Adding New Features

The next sections explain how to add the following new features:

usercreated buttons lists of values for parameters ASCII output

Adding Buttons

1.

Open drill.rdf. In the Layout editor, select F_TOTAL and shorten it so there is enough room for a button.

78

Building Reports Manual

Button Tool

2.

Select the Button tool. Draw a small region next to F_TOTAL. Display the buttons property sheet, shown below

3.

Under Object:Action, select the Execute PL/SQL radio button. The action you select determines what occurs when the button is pressed. Possible actions are: displaying an image, playing a sound, playing a video, or, as in this example, executing a piece of PL/SQL code. Note: Not all multimedia actions are available on all platforms; for details, see your Developer/2000 Installation Guide.

4.

Select Edit... to display the Program Unit editor, which contains a procedure template. Edit the template provided.
procedure U_1ButtonAction is begin srw.run_report(salesdt.rdf paramform=yes P_custname=||:custname || P_salesrep=||:salesrep ||); end;

Accept the Program Unit editor, then the property sheet.

Reports with New V2.5 Features

79

Now, when the report output is displayed in the Previewer, a button will appear in each matrix with a value. Each time a button is pressed, the PL/SQL procedure calls R25RUN, the Oracle Reports runtime executable, and passes it the following arguments:
paramform=yesspecifies that the Runtime Parameter form

display prior to execution of salesdt.rdf.


P_custname=||:custname ||passes

the current customer name into the salesdt.rdf parameter named P_CUSTNAME.

P_salesrep=||:salesrep ||)passes

the current salesreps name into the salesdt.rdf parameter named P_SALESREP. Notice the placement of the double quotes in the procedure. SRW.RUN_REPORT passes commandline arguments as a character string. Values which are not characters must be converted to characters via the TO_CHAR() function. Any character values that may contain spaces, such as P_CUSTNAME and P_SALESREP, must be passed as literals.

For more information on R25RUN syntax, see R25RUN in Chapter 1 of the Reports Reference Manual. Note: Certain restrictions apply to buttons:

Only one button can be activated at any one time. If you try to select another button you will receive an error message. Buttons and their actions can only be viewed in the Previewer. They will not display in output written to a file, sent to the printer, or mailed to other users.

For more information on buttons and their properties, see Button Properties in Chapter 8 of the Reports Reference Manual. Save drill.rdf. Adding Userdefined Lists of Values for Parameters 1. Open salesdt.rdf. In the Object Navigator, expand the Data Model node, then the User Parameter node, to display the nodes for P_SALESREP and P_CUSTNAME. Display the P_CUSTNAME property sheet. Go to the Data/Selection tab and select the SELECT Statement radio button to indicate that you want to generate your parameters list of values using a SELECT statement.

2.

7 10

Building Reports Manual

You can also create a static list by selecting the Static Values radio button and entering each value in the Value field, selecting Add for each new entry. Such a list must be manually specified and revised, item by item. You can also restrict the values in the list to only those you have provided (i.e., provide a true list of values instead of a combo box). 3. In the text field below, enter the following SELECT statement:
select name from customer

This SELECT statement creates a list of customer names that correspond to the values for the CUSTNAME column in drill.rdf Select OK to accept the parameter property sheet. 4. Display P_SALESREPs property sheet. Select the SELECT Statement radio button and enter the following SELECT statement:
select ename, job from emp where job = SALESMAN

This SELECT statement creates a list of salesreps names that correspond to the values for the SALESREP column in drill.rdf. Save salesdt.rdf and run drill.rdf. The output should resemble that shown in the next figure.

Reports with New V2.5 Features

7 11

Select a button in one of the cells. The Runtime Parameter form for salesdt.rdf is displayed. The values for P_CUSTNAME and P_SALESREP match the values for F_CUSTNAME and F_SALESREP for the matrix cell. Select Run Report. A second Previewer appears, displaying output for salesdt.rdf related to the matrix cell.

Your drilldown report is complete, but at this point the output can only be generated in a bitmapped format (e.g., Postscript). Generating ASCII Output Perhaps youd like the detail reports to output straight text so you can mail the output to other users, easily import it into other applications, print it using line printers, etc. Whether your report generates bitmapped or characterbased output depends on the mode in which its run. This is governed by a Oracle Reports parameter called MODE. To generate character output, set MODE to Character. To enable users to select the mode of the report at runtime, you need to customize your Runtime Parameter form to include MODE. 1. Select Tools>Default Parameter Form... to display the Default Parameter Form dialog box, used to create a customized Runtime Parameter Form. DESTYPE and DESNAME are already selected. Select MODE, P_CUSTNAME, and P_SALESREP.

2.

7 12

Building Reports Manual

3.

Enter any title, hint, or status line values in the appropriate fields. Accept the dialog box. The layout of the Runtime Parameter form appears in the Parameter Form editor. Customize the Runtime Parameter form as desired. As long as you include fields for the necessary parameters, you can change the appearance of the layout objects as you would in the Layout editor. The next figure shows the Parameter Form editor for salesdt.rdf as an example.

Run drill.rdf and select a button in the matrix. In the Runtime Parameter form for salesdt.rdf, specify a mode of Character and select Run Report. The charactermode Previewer is displayed, containing ASCII output for the report.

Reports with New V2.5 Features

7 13

Multimedia Report

New Features

This report consists of graphics and boilerplate created in the Layout editor as a frame for three buttons. These buttons, when pressed in the Previewer, display either an image or a short video clip. This reports uses the following feature new to Oracle Reports 2.5:

usercreated buttons capable of displaying multimedia objects in the Previewer

Concepts

The button you created for the drilldown report executed a PL/SQL procedure. Buttons can also execute other actions; most notably, display multimedia files when pressed in the Previewer. Depending on your platform and the capabilities of your individual machine, these files can be images, sound files, or video clips. A major advantage of buttons is their portability. Reports containing buttons can be moved from platform to platform with no loss of functionality, if the multimedia files are relocated as well.

7 14

Building Reports Manual

Note: Certain restrictions apply to buttons:


Only one button can be activated at any one time. If you try to select another button you will receive an error message. Buttons and/or the media they invoke can only be viewed in the Previewer. They will not display in any fashion in report output written to a file, sent to the printer, or mailed to other users.

For more information on buttons and their properties, see Button Properties in Chapter 8 of the Reports Reference Manual. This report is interesting for another reason. It uses no data model. The layout serves as a front end for an interactive display, and all buttons link to files stored in the file system. You could also select files stored in the database, or columns pointing to the names of files stored in the file system. These last two choices would require the definition of a data model.

Prerequisite Reports

This example requires avi.rdf, and the following multimedia files:


balloons.avi spacewlk.avi oracle.bmp

The report is provided, but if you want to recreate it, a description of each report is given below. avi.rdf Query Data Model Layout The report avi.rdf is extremely simple. It consists of a layout comprised of boilerplate graphics and text, and usercreated buttons. None. None. The layout was created in the following manner:

Several boilerplate graphics objects were created and assigned colored fills and borders. Boilerplate text, instructing the user on what action to take, was added. Colors, fonts, and font sizes were customized as desired. All objects in the layout were selected and grouped to prevent accidental shifting of objects while the buttons are added.

Adding New Features

The next sections explain how to add the following new feature:

adding buttons that activate multimedia displays in the Previewer.

Reports with New V2.5 Features

7 15

Adding Buttons

1.

Open avi.rdf. In the Layout editor, select the Button tool. Draw a small region for the first button below the instructions and display the buttons property sheet, shown in the next figure, and rename the button U_BALLOONS.

2.

Under Object:Action, select the Multimedia File radio button, then select List.... The File Open dialog is displayed. Use this to select balloons.avi from /demo/reqfiles. Display the list of types available and select Video. This indicates that when the button is pressed in the Previewer, Oracle Reports will display the video clip called balloons.avi.

3.

4.

Under Object:Button Face, keep Text as the value of the Label field, and type Balloons in the Text String field. Your button will be labeled Balloons. Buttons can also be labeled with icons. If you want to use an icon instead of a text string, display the list for Label and select Icon. The next field, Text String, changes to Icon File, and you can enter the name and path of the icon file you want to use in the field provided. Note: Not all multimedia actions are available on all platforms; if your platform does not support video, select a graphics file (e.g., .tif) instead. For details on what multimedia actions are allowed on your platform, see your Developer/2000 Installation Guide.

7 16

Building Reports Manual

Accept the the property sheet. Now, when the report output is displayed, a button labeled Balloons will appear in the Previewer. 5. Repeat steps 1 through 4, drawing the region for the button below U_BALLOONS. Rename the new button U_SPACEWALK, select the Multimedia File radio button, then list available files and select spacewlk.avi. Give the file a type of Video and a label of Spacewalk. Accept the the property sheet. Now, when the report output is displayed, a button labeled Spacewalk will appear in the Previewer. 6. Use the Button tool to create one last button below U_SPACEWALK. Rename the button U_LOGO. Select Multimedia File as the action, oracle.bmp as the file, and Image as the filetype. Give it a label of Oracle and accept the property sheet.

Run the report. The output should resemble the figure below.

Click once on Balloons. The Video Player is displayed in a separate window with the first frame of the video visible, as shown below. Select Play to play the video. You can play it straight through, or use the slider bar to advance and rewind.

Reports with New V2.5 Features

7 17

For more information about the Video Player, see Accessing Video in Chapter 11 of the Reports Reference Manual. Close the Video Player and click once on Oracle. The Image Viewer is displayed in a separate window with the image oracle.bmp, as shown in the next figure. With the Image Viewer, you can magnify portions of the image or view different portions of large images in the display area.

For more information about the Image Viewer, see Accessing Images in Chapter 11 of the Reports Reference Manual. Remember, only one button can be activated at any one time. If you want to display spacewlk.avi, be sure to close the Image Viewer first. Also, be sure not to doubleclick on the buttonsOracle Reports views a doubleclick as two separate requests to activate the button.

7 18

Building Reports Manual

OLE2 Report

New Features

The images in the report output above are furnished by OLE2 objects stored in a database table. This report uses the following feature new to Oracle Reports 2.5:

OLE2 objects

Concepts

Oracle Reports V2.5 is an OLE2 container; i.e., it enables you to include OLE2 objects in a report in one of two ways:

in the data model in a boilerplate object

OLE2 Objects in the Data Model: OLE2 objects stored in files can be accessed via a column of filenames for which Read From File has been checked. When you default your layout, the appropriate layout object will be created for it (e.g., a field for an image, a button for video). OLE2 Objects in Boilerplate: When you create a piece of OLE2 boilerplate with the OLE2 tool, you can either invoke any OLE2 servers to which you have access and create the object on the spot, or you can use an existing file. Once a file is embedded, you can activate it if you have access to the application used to create it.

Reports with New V2.5 Features

7 19

OLE2 layout objects have the same properties as all other layout objects; e.g., print condition types, format triggers, vertical and horizontal sizing, etc.

Prerequisite Reports New Features

None. You will build this example in its entirety. The next sections explain how to add the following new feature:

OLE2 objects

Steps to Build this Report

Queries

1.

Create a query and open its property sheet. Rename it Q_Comp_Sum and enter the following SELECT Statement:
select * from company_summary

Accept the query property sheet. Your data model should resemble the next figure.

2. 3.

Notice the last column listed: COMPANY_OLE. This column contains OLE2 objects stored in the database. Doubleclick on COMPANY_OLE to display the columns property sheet.

7 20

Building Reports Manual

Notice the value of General: Datatype: Long Raw. This is how OLE2 objects are stored. Now, change the value of Text in the Format field to OLE2. Close the property sheet. 4. Open the Default Layout dialog box and select Style:Form. In the Data/Selection tab, deselect COMPANY_LOGO and make the following width changes: Column COMPANY_ID COMPANY_NAME COMPANY_CEO COMPANY_LOCATION REVENUES_TO_DATE COMPANY_OLE Width 12 20 24 16 12 15

Accept the Default Layout dialog. 5. Modify all boilerplate as desired, adding any borders or fills that you like, and changing the font for the boilerplate text and text fields, etc. (you can use the report output for ideas). Your layout might resemble the layout shown below.

6.

Run your report. Page through it to see the OLE2 objects that are the values for the COMPANY_OLE column.

Reports with New V2.5 Features

7 21

If you have access to the same application with which the OLE2 object was created, you can doubleclick on the object in the Previewer to invoke the appropriate OLE2 server. You can modify the object, but if it is a column value, you cannot save the changes.
OLE2 Tool

To be able to modify an OLE2 object and save your modifications, the object cannot be obtained from a database column. You need to create it in the Layout editor using the OLE2 tool. You can experiment with ole2.rdf now by creating a piece of OLE2 boilerplate. To do so, select the OLE tool in the tool palette and draw a region on the Layout editor. The Insert Object dialog appears, displaying a list of the currently registered OLE servers with which you can create the OLE2 object. You also have the option of creating the object from a preexisiting file. After choosing the server, create the object as you normally would in that application and update your boilerplate object. For more information about creating OLE2 boilerplate, see OLE2 in Chapter 16) of the Reports Reference Manual.

7 22

Building Reports Manual

Tracing and Debugging Report Execution

New Features

The report whose output is shown above contains no new features. Whats new about this report is in the way youll look at it, using Oracle Reports new debugging features:

Object Navigator settings PL/SQL editor PL/SQL Interpreter Trace mode

Concepts

Oracle Reports now has several tools for designtime debugging. For example, the Object Navigator can show data and layout objects either is a straight alphabetical list by type or in a hierarchical fashione.g., list columns under the groups to which they belong, or fields under the frames to which they belong. The Object Navigator can also show whether an object has attached PL/SQL, and to what it is anchored. Integration with a PL/SQL development environment via Oracle Procedure Builder gives you access to both the Program Unit editor, in which you can write and debug your functions and procedures, and the PL/SQL Interpreter, with which you can set breakpoints, step through the execution of your report, test your functions at design time, and more.

Reports with New V2.5 Features

7 23

Oracle Reports also has extensive tracing capabilities. You can capture and write to a trace file such aspects of report execution as errors and warnings, break points triggered, PL/SQL and SQL execution, and stepbystep execution of report objects.

Prerequisite Reports
debug.rdf

This example requires the report debug.rdf. The report is provided, but if you want to recreate it a description is given below. The report debug.rdf is a simple, twoquery master/detail report with the addition of three summary columns and one formula column. For instructions on how to create a master/detail report, see Master/Detail Report on page 5 35)

Query

Q_Customer
select custid, name from customer

Query

Q_Order
select custid, sum(actualprice) actualprice, sum(qty) qty, sum(itemtot) from item, ord where item.ordid = ord.ordid group by custid

Data Model

The data model for debug.rdf is a typical master/detail data model. The detail group also contains a usercreated formula column, and the report as a whole contains three usercreated summaries.

7 24

Building Reports Manual

For more information about how to create formula columns, see Formula Report on page 5 56. For more information about how to create summary columns, see Summary Report on page 5 40. Layout The layout was created in the following manner:

a default tabular layout was created (for instructions, see Tabular Report on page 5 3) a boilerplate title was added to the top margin (for instructions, see Header and Footer Report on page 5 67) new fonts and colors were assigned to column headings and a colored fills was assigned to a repeating frame (for instructions, see Graphics and Text Report on page 5 75) a reportlevel PL/SQL function was added and referenced from the formula column (for instructions, see PL/SQL Report on page 6 41)

Using New Features

The next sections explain how to use the following new features:

Object Navigator settings the Program Unit editor the PL/SQL Interpreter the Trace Settings dialog box

Object Navigator Settings Data Model Information 1. Open debug.rdf. In the Object Navigator, expand the Data Model node and selected subheading nodes, such as Queries, Groups, and Database Columns. Notice the structure. Under each subheading is a list of all objects of only that type. In addition, the organization of the Groups node shows G_Order indented under G_Customer. G_Order is the child of G_Customer. 2. Select Navigator>Navigator Options.... In the Object Navigator Options dialog box, select the Group tab, then deselect View by Structure and select Show Columns In Groups. Accept the dialog box. Examine the Object Navigator. Because you deselected View by Structure, G_Customer and G_Order are now on the same level. Because you selected Show Columns In Groups, the columns belonging to each group are listed below that groups heading.

Reports with New V2.5 Features

7 25

View by Structure and Show Columns In Groups can act as a schematic of the data relationships in your report and help you pinpoint problems with data hierarchy. Layout Information 3. Select the Layout node, then select the Expand All tool. Once again, examine the structure. As with the Data Node, View by Structure is the default, but when applied to the Layout node, it also shows object ownershipe.g., fields are shown under the repeating frames that own them, etc. Objects are not grouped with like objects. 4. Select Navigator>Navigator Options.... In the Object Navigator Options dialog box, select the Layout tab, then deselect View by Structure. Accept the dialog box. Examine the Object Navigator. The different parts of a report (Header, Trailer, Body, Margin) are no longer accorded their own heading nodes. Now, under each subheading is a list of all objects of only that type. View by Structure can provide a guide to the organization of the layout objects in your report and help you pinpoint problems with the construction of the layout. For example, if a field has been inadvertently moved out of its repeating frame and into the group frame, the Object Navigator will show this. In addition, when viewing the layout by structure you can specify that anchoring information be displayed. This will show all explicit anchors and any implicit anchors that are not a simple case of a child object being anchored to its containing parent. Program Unit Editor The Program Unit editor is the PL/SQL editor in which you create triggers, formulas, reportlevel functions and procedures, and even external libraries and packages. Its appearance and method of access have been upgraded from Oracle Reports V.2.0, but its function remains the same. 5. In the Object Navigator, expand the Program Units node and doubleclick on the program unit icon for DISCOUNT_RATE. The Program Unit editor, containing the source for DISCOUNT_RATE, is displayed. Make a minor, incorrect change to the function (delete a semicolon, for example), then select Compile. A new pane containing error messages appears in the window, as shown in the next figure.

Editing Program Units

6.

7 26

Building Reports Manual

If you are debugging a large construct, you can scroll through the messages and doubleclick on a message to place the text cursor at the point of the error in the source. 7. Select Revert. The function reverts to its previous, correct form. Close the editor. You can also apply changes without compiling (Apply), delete constructs (Delete), and create new constructs (New...). PL/SQL Interpreter The PL/SQL Interpreter is the central debugging workspace of Oracle Procedure Builder. It is a paned window that enables you to define, display, and debug your PL/SQL program units. 8. 9. Select Tools>Interpreter. The PL/SQL Interpreter is displayed. Click on DISCOUNT_RATE in the Object Navigator. The source for the function is imported into the top pane of the Interpreter, as shown in the next figure.

Setting Breakpoints

Reports with New V2.5 Features

7 27

The PL/SQL Interpreter accessed from the Tools menu is a twopaned, modeless dialog that enables you to display the source of a construct and define debugging actions in the top, or Source pane, and enter PL/SQL and Oracle Procedure Builder commands in the bottom, or Interpreter pane. Since it is modeless, you can leave it up as you work on Reports objects, testing and modifying during the design phase. 10. Doubleclick on a line of executable code in the Source pane. This sets a breakpoint, as indicated in the lines prefix by B(01). The Interpreter pane also informs you that a breakpoint has been installed. Doubleclick on the line again. The breakpoint is removed. 11. Set the breakpoint again, and a few others if desired, then close the Interpreter and save your report. Notice the Debug Actions node in the Object Navigator. It now indicates it contains subnodes. Expand the node to see your breakpoints listed. 12. Run debug.rdf When the report reaches a breakpoint, execution is suspended and the PL/SQL Interpreter is again displayed. Contrast this PL/SQL Interpreter with the designtime PL/SQL Interpreter. The PL/SQL Interpreter invoked during the execution

7 28

Building Reports Manual

of a report is a modal dialog that contains the same two panes as the Interpreter accessed from the Tools menu In addition, it contains a third pane that resembles a miniature Object Navigator devoted to PL/SQL, database objects, and debugging. The Debug Actions node appear here. Notice, too, that the Stack node now indicates it contains subheadings. Expand the Stack node in the Interpreters Navigator pane and examine the variable values found there.
Step Into Tool

13. Use the Step Into tool (or one of the other Step tools) to step through the execution of debug.rdf. You can continue stepping through your report, or, if that gets tedious, you can disable breakpoints during report execution.

Go Tool

14. Disable both breakpoints by doubleclicking on the appropriate lines in the Source pane. Allow report execution to complete by either selecting the Step tool or the Go tool. The Previewer appears with your report output. Many other debugging actions are possible with the PL/SQL Interpreter, such as setting conditional breakpoints via triggers, test functions at designtime by entering sample values for them in the Interpreter pane, and use the debugging functions and procedures furnished by the Oracle Procedure Builder DEBUG package to help you debug your PL/SQL constructs. For complete information about using the PL/SQL Interpreter to debug your PL/SQL program units, see the Oracle Procedure Builder Developers Guide.

Trace

Trace enables you to copy statistics for report execution to a file for later review. You can specify any or all Trace options via the Trace Settings dialog, including capture error messages and warnings, performance statistics, the order in which report objects are processed, and the execution of PL/SQL and SQL. For more information about trace file options, see R25DES in Chapter 1 of the Reports Reference Manual. Setting Trace Options 15. Select Tools>Trace.... The Trace Options dialog box, shown below, is displayed.

Reports with New V2.5 Features

7 29

16. Enter a name for your file in the Trace File field. The next field, Trace Mode, indicates whether you want the trace file to be appended to the file for the last run, or to replace it. 17. Under Trace Options, select the desired combination of options (or select All). Accept the dialog box and run the report. 18. After determining that the report has executed correctly, close the Previewer and use a text editor to examine the trace file. It should contain all the options you selected. Below is an example of a trace file, including report name, username, database, time stamps, SQL statements executed, and the values of bind variables.

7 30

Building Reports Manual

PART

IV

Tasks and Procedures

CHAPTER

How To...
his chapter provides procedures for using Oracle Reports to create objects and design your reports. The procedures are grouped into the following categories:

invoking online help 8 2 accessing the online documentation 8 2 setting preferences 8 2 performing common tasks 8 4 working with the Object Navigator 8 14 working with reports 8 17 working with external queries 8 29 working the external PL/SQL libraries 8 30 working with data model objects 8 33 working with layout objects 8 47 working with parameter form objects 8 75 working with the Previewer 8 77 working with PL/SQL 8 79 working with report triggers 8 83 debugging reports 8 84

How To...

81

Invoking Online Help


Oracle Reports provides an extensive, contextsensitive help system. Use it to quickly access information about using Oracle Reports. Oracle Reports help is systemspecific. You access help as you would for any other application on your system (e.g., selecting from a help menu).

Accessing the Online Documentation


All of the Oracle Reports hardcopy documentation is also available online using Oracle Book. You open Oracle Reports documentation as you would any other Oracle Book document. For the names and location of the Oracle Book documents for Oracle Reports, consult your Developer/2000 Installation Guide. For information about using Oracle Book, refer to your Oracle Book documentation.

Setting Preferences
With Oracle Reports, you can modify your design and run preferences to suit your particular needs. You can:

set preferences for designing reports 8 2 set preferences for running reports 8 3 set preferences for the Object Navigator 8 3 set font aliases 8 3 set colors 8 3

Set Preferences for Designing Reports

To set preferences for working in the designer: 1. 2. 3. 4. Select Tools>Tools Options.... In the dialog box, change the settings on the Preferences tab as required. To save the specified preferences for future sessions, select Save Preferences.... Accept the property sheet.

82

Building Reports Manual

Set Preferences for Running Reports

To set preferences for running reports: 1. 2. 3. Select Tools>Tools Options.... In the dialog box, change the settings on the Runtime Parameters and Runtime Settings tabs as required. Accept the dialog box.

Set Preferences for the Object Navigator

To set preferences for how the Object Navigator displays objects: 1. 2. 3. Select Navigator>Navigator Options.... In the dialog box, change the settings as desired. Accept the dialog box.

Set Font Aliases

To alter the default font mappings used by Oracle Reports, edit the file uifont.ali. The location of this file is specified via the environment variable TK2_FONTALIAS and varies according to your operating system. For the exact location, see your Developer/2000 Installation Guide. To alter the default colors on the color palette for layout objects: 1. 2. 3. 4. 5. 6. 7. 8. 9. Select Tools>Tools Options.... In the dialog box, choose a Preferences:Color Palette Mode setting of Editable, and select Save Preferences.... Restart Oracle Reports. In the Layout Editor, select Format>Color Palette.... Select a color to edit. Select Edit.... In the dialog box, edit the color by following the procedure for your system. Accept the dialog box. To rename the color, type a different name in the Current Color field and select Rename. Accept the dialog box.

Set Colors

How To...

83

Performing Common Tasks


The following tasks are common to all Oracle Reports modules (reports, external queries, and external PL/SQL libraries) and objects:

connect to a database 8 4 copy modules 8 5 open modules 8 5 save modules 8 5 rename modules 8 5 grant access to modules 8 6 delete modules - 8 6 archive modules - 8 7 select and deselect objects 8 10 resize objects 8 12 hide and show components 8 13

Connect to a Database

Oracle Reports accesses data in the database you reference in your queries. You can connect to a local database, a remote database (through SQL*Net), or other databases (through SQL*Net with SQL*Connect). In addition to getting data from the database, Oracle Reports can store reports in the database, if specified. You can also connect to other databases using ODBC. For more information about ODBC, see the Developer/2000 Installation Guide for your operating system. To connect to a database: 1. 2. 3. Select File>Connect.... In the dialog box, type your user ID in the User Name field. In the Password field, type your password. If you are connecting to a remote database, position the cursor in the Database field and enter a SQL*Net communications protocol and database node and name. For example, you might enter the following:
t:boston:payroll

where boston is the database node and payroll is the database name. 4. Select Connect to connect to the database.

84

Building Reports Manual

Copy Modules

To a report, external query, or external PL/SQL library stored in the database:


Select the module. Select File>Save As... to copy the existing module under a new name.

Open Modules

To open a report, external query, or external PL/SQL library: 1. 2. Select File>Open... (or the Open tool). In the dialog box, select whether the module you want to open is stored in the database or in a file, and the type of module. Accept the dialog box. In the Open dialog box, select the name of the module you want to open, or type the name in the entry field. Accept the dialog box to open the module.

3. 4.

Save Modules

To save an untitled report, external query, or external PL/SQL library for the first time: 1. 2. Select File>Save or File>Save As... (or the Save tool). In the dialog box, select whether you want to save the module in the database or in a file, and the type of module. Accept the dialog box. In the Save dialog box, type a name for the module and accept the dialog box. For objects stored in the database, Oracle Reports will automatically prefix your userid to the name. (If you want to save the module under the name of a module that already exists, select from the list of values or type in the name of an existing module, and accept the dialog box.) Save Changes To save changes to an open module that has been saved previously, select File>Save (or the Save tool) to save the module under its current name.

3.

Rename Modules

You can use Oracle Reports to rename modules only if you own them and they are stored in the database. To rename modules stored in files, access your operating system and rename the files containing the modules. To rename a report, external query, or external PL/SQL library stored in the database: 1. Select File>Administration>Rename....

How To...

85

2. 3.

In the dialog box, select the type of module you want to rename. Accept the dialog box. In the Rename dialog box, select the old name or type it in the Old Name field. Then type the new name for the module in the New Name field. Accept the dialog box to rename the module.

4.

Grant Access to Modules

You can use Oracle Reports to grant users access to modules only if you have access to the modules and they are stored in the database. The method used to grant users access to modules stored in files is operating system dependent. See your Developer/2000 Installation Guide for more information. To grant users access to the current module: 1. 2. 3. Open the module to which you want to grant other users access. Select File>Administration>Module Access.... In the dialog box, type the name of the user to whom you want to grant access in the User field, then select Add. Repeat this step for each user to be granted access. Accept the dialog box to grant the named users access to the module.

4.

Delete Modules

You can use Oracle Reports to delete modules while in the designer only if you have access to them and they are stored in the database. To delete modules stored in files, you need to access your operating system and delete them. Delete Modules from the Database To delete a report, external query, or external PL/SQL library from the database: 1. 2. 3. 4. Select File>Administration>Delete.... In the dialog box, select the type of module you want to delete. Accept the dialog box. In the dialog box, select or type the names of the modules you want to delete. Accept the dialog box. In the alert window, select Yes. To cancel the delete operation, select Cancel.

Note: Using a SQL script, you can delete multiple reports at once. For more information, see Using SQL Scripts in Chapter 19 of the Reports Reference Manual.

86

Building Reports Manual

Delete Modules in the Object Navigator To delete a report, external query, or external PL/SQL library from the Object Navigator, select the module you want to delete, then select Navigator>Delete (or the Delete tool).

Archive Modules

Oracle Reports Version 2.5 provides version control via PVCS. PVCS is a thirdparty package manufactured by Intersolv. For information about installing and using PVCS, refer to your Intersolv documentation and to your Developer/2000 Installation Guide. Using PVCS, you can:

create an archive directory 8 7 check in a file 8 7 check out a file 8 8 create archive reports 8 9

When you check out a file, Oracle Reports automatically converts the file to the appropriate format and, if necessary, returns the file extension to what it was before check in. Create an archive directory To archive reports, external queries, and PL/SQL library modules, you must first establish an archive directory: 1. 2. 3. Select File>Administration>Source Control Options. In the Source Control: Options dialog, in the Archive field, specify the name and location of your archive directory. Select Add Directory, then Close to add your directory as a valid archive directory.

Note: You cannot add archive directories unless you have already defined the TVCCFG parameter in the ORACLE.INI file. On Microsoft Windows, define the TVCCFG parameter as follows:
TVCCFG=C:\\PVCS\\PROJECT1\\PROJECT1.CFG

Check In a File

After saving your changes in the Designer, you can check in a archive your changes. When you check in a file (.REP, .REX, .RDF, .PLL, .PLD, .SQL), Oracle Reports performs a binarytotext conversion automatically and archives the file in the specified location as a text file. Note that in the case of .RDF, .REP, and .PLL files the file extension will be changed to .RDV, .RPV, or .PLV, respectively. All other files retain their file extensions when checked in.

How To...

87

Note: PVCS uses the text file to generate archive reports. Each time you modify a file and check it into an archive, it becomes a new revision. To check in a file: 1. 2. 3. Select File>Administration>CheckIn. In the Source Control: CheckIn dialog, in the File Name field, specify the name of the file to archive. In the Archive field, specify the location of your archive. Note: If you have already archived a version of the current module, Oracle Reports automatically enters the appropriate information in the Archive field. 4. (Optional) Provide a Version Label and Description. Note: A version label identifies a revision as one of a group of revisions that typically make up a complete version of your application. Version labels enable you to operate on all of the files associated with a particular version at the same time by referencing a single name. 5. (Optional) Click the Keep File Locked check box if you want a writable copy of the archive file to remain locally even after the file is checked in. Having a writable copy of the file allows you to modify and check in subsequent changes to the file without having to first check the file out. Note: When you archive a .RDF file, PVCS creates a file with an RDV extension. For example, ORDER.RDV. When you archive a .REP file, PVCS creates a file with an RPV extension. And when you archive a library (PLL), PVCS creates a file with a PLV extension. Check Out a File Checking a file out of an archive gives you access to it for browsing, editing, or printing. By default, only one user at a time can check out a particular revision with a lock. When you check out a file, Oracle Reports automatically converts the text file to the appropriate format. The file you check out of an archive is called a workfile. Each time you check in a new variation of a workfile, it becomes a revision. To check out a file: 1. Select File>Administration>CheckOut.

88

Building Reports Manual

2. 3. 4.

In the Source Control: CheckOut dialog, in the File Name field, specify the name of the file that you want to check out. In the Revisions field, select the desired file revision. Click on the Lock this File check box. Note: If you intend to modify an archive file, you must enable the Lock this Field check box in order to check in your changes. Otherwise, checks out readonly version of the file.

5. Create Archive Reports

(Optional) Specify the desired destination by entering a path in the Destination field.

PVCS enables you to generate reports that summarize the following archive activities:

when an archive was created archive attributes details about successive revisions version label names number of lines changed in the last revision a description of the workfile

To create an archive report: 1. 2. 3. Select File>Administration>Source Control Options. In the Source Control: Options dialog, click the Reporting Options button. In the Source Control: Reporting dialog, in the Source File Field, specify the name of the desired archive file. PVCS will generate a report based on the comparison between this file and the target file. In the Target File field, specify the name of a target file. Note: If you are comparing two revisions within the same archive, enter the name of the archive file that you entered in step 3. If you are comparing different archive files, specify a different archive file in the Target File field. 5. 6. 7. In the Source and Target fields, select the desired file revisions. In the File Name field, specify the name and location of your report, then click the Create Report button. To view your report, use an editor to open your report file.

4.

How To...

89

Select Objects

To manipulate objects or define their properties, you must first select them. You can:

select single objects 8 10 select multiple objects 8 10 select objects owned by a frame 8 11 select grouped objects 8 11 select all objects in a report region 8 11 select overlapped objects 8 11

Select Single Objects

You can select single objects using the Object Navigator or the editors. In the Object Navigator To select a single object, click on the object. If the object is an editor object, it is also selected in the corresponding editor window. In the Data Model, Layout, and Parameter Form Editors To select a single object, select the Select tool, then click on some part of the object, or click and drag a region around just the object.

Select Multiple Objects

You can select multiple objects using the Object Navigator or the editors. In the Object Navigator To select multiple objects, select the first object, then either:

Shiftclick on a node to select all objects between the first and current object. Or, controlclick on a node to add it individually to the selection group.

If a selected object is an editor object, it is also selected in the corresponding editor window. In the Data Model, Layout, and Parameter Form Editors To select multiple objects, select the Select tool, then either:

Shiftclick on each object. Or, click and drag a region that includes all of the objects you want to select. (In the Data Model editor, note that if the first object you select is a column within a group, everything else you select must be a column within the same group; you cannot select columns within groups at the same time as you select queries, groups, reportlevel columns, or parameters.)

8 10

Building Reports Manual

Select Objects Owned By a Frame or Repeating Frame

To select a set of objects owned by a frame or repeating frame: 1. In the Layout editor:

Select View>View Options>Layout... and check Layout:Confine (or set the mode using the Confine tool). Or, if you want to explicitly select all objects to set common properties, select the Frame Select tool.

2.

Select the frame or repeating fame. All objects within the frame or repeating frame are selected, depending upon their explicit anchors.

Select Grouped Objects Select All Objects in a Report Region

To select grouped objects (grouped using Arrange>Group), select the Select tool and click on one of the grouped objects. To select all objects within the region (Body, Margin, Header, or Trailer) you are currently editing, select Edit>Select All. (In the Data Model editor, note that this does not select any columns within groups.)

Select Overlapped Objects To select any object that is partially or completely overlapped by another object: 1. 2. Select the object that obscures the object you want to select. Select Arrange>Move Backward. The object you want moves on top of the object that obscured it. 3. Select the object.

Deselect Objects

If one or more objects are selected, you can:


deselect single objects 8 11 deselect multiple objects 8 11

Deselect Single Objects

You can deselect single objects using the Object Navigator or the editors: In the Object Navigator To deselect a single object, controlclick on the object. In the Data Model, Layout, and Parameter Form Editors To deselect a single object, shiftclick on the object.

Deselect Multiple Objects

To deselect all selected objects, move to a blank area and click.

How To...

8 11

Resize Objects

You can resize queries, groups, repeating frames, frames, fields, matrix objects, and boilerplate. Note: You cannot resize anchors. However, an anchor is automatically resized if you move one of the objects it anchors together. Caution: When you resize boilerplate text, be very careful that all of the text fits within the object. If font descends (the space left for the lower parts of letters like g and q) do not fit, the line of text will appear in the editor, but, when the report is run, the line will not appear in the output. When you select a handle and drag it, the two edges that join at the corner will be resized; that is, the object will grow or reduce in both the x and y directions. You can:

resize single objects 8 12 resize multiple objects 8 12 make multiple objects the same size 8 13 repeat the previous sizing 8 13

Resize Single Objects

To resize a single object: 1. 2. Select the object. Set the size:


For a fixed size, click and drag one of the objects handles to the desired size. Or, doubleclick on the object to display the property sheet, then specify a value for General Layout:Vertical and General Layout:Horizontal of Contract, Expand, Fixed, or Variable. For more information, see Vertical Sizing and Horizontal Sizing in Chapter 8 of the Reports Reference Manual.

Resize Multiple Objects

To resize multiple objects: 1. 2. Select all of the objects you want to resize. Set the size:

For a fixed size, click and drag the handle of one of the selected objects. All of the objects will change size relative to the object on which you click and drag. Or, select Tools>Common Properties... to display the common property sheet, then specify a value for Generic:Vertical and Generic:Horizontal of Contract, Expand, Fixed, or Variable.

8 12

Building Reports Manual

For more information, see Vertical Sizing and Horizontal Sizing in Chapter 8 of the Reports Reference Manual. Make Multiple Objects the To make multiple objects the same size: Same Size 1. Select the objects, then select Arrange>Size Objects.... 2. Repeat the Previous Sizing In the dialog box, enter the desired settings and accept the dialog box.

To repeat the previous Arrange>Size Objects... setting, select the objects you want to resize, then select Arrange>Repeat Sizing. When working in with , it is sometimes useful to hide selected components. For example, by hiding the Tool palette, you increase how much of the painting region is visible. In the Object Navigator To hide or show the toolbar in the Object Navigator, select Navigator>Toolbar. In the Data Model or Layout Editors To hide or show any component in the Data Model or Layout editors, select the View menu then click on the name of the component you want to hide or show.

Hide and Show Components

How To...

8 13

Working with the Object Navigator


The Object Navigator provides a hierarchical view of the current sessions modules, report objects, and other useful design elements such as database stored procedures. Using the Object Navigator, you can perform the following tasks:

work with reports, external queries, external PL/SQL libraries, data model objects (including parameters), layout objects, and parameter form objects display editors - 8 14 expand and collapse nodes - 8 14 navigate to specific nodes - 8 15 view node hierarchy 8 15 display properties - 8 15 customize the Object Navigator - 8 16 drag and drop PL/SQL program units 8 80

Display Editors

To display the Data Model editor, Layout editor, Parameter Form editor, External Query editor, Program Unit editor, or Stored Program Unit editor:

Doubleclick on the object or code you want to edit. Or, select the node, then click the right mouse button and select Editor... or Program Unit Editor... from the popup menu. Or, select the node, then select the Tools menu and click on the editor you want to display.

Expand and Collapse Nodes

To expand a node to its most recently expanded state:


Click the + (plus) to the left of the node. Or, select the node, then select Navigator>Expand (or the Expand tool).

To collapse a node:

Click the (minus) to the left of the node. Or, select the node, then select Navigator>Collapse (or the Collapse tool).

8 14

Building Reports Manual

To expand or collapse a node and all levels of nodes underneath it:


Shiftclick the + (plus) or (minus). Or, select the node, then select Navigator>Expand All (or the Expand All tool) or Navigator>Collapse All (or the Collapse All tool).

Navigate to Specific Nodes

You can navigate to a specific node by searching for the node, or by selecting to go to a previously marked node. Search for Nodes To search for a specific node: 1. Begin typing the name of the node you want to locate in the Find field. If you want to search for multiple nodes with a common component to their names, type in all characters in common. If a match is found, the cursor moves to the first match subsequent to its beginning position. 2. To search for the next match, click on the arrows next to the Find field.

Mark and Go to Nodes To mark a node, select the node, then select Navigator>Set Mark. To go to a previously marked node, select Navigator>Go to Mark.

View Node Hierarchy

To display an ancestor view that shows the position of the selected object in the object hierarchy:

In the Object Navigator, expand the poplist to the left of the Find field.

Display Properties

To view or change the properties for an object: 1. In the Object Navigator:


Doubleclick on the property icon of the object. Or, select the node, then click the right mouse button and select Properties... from the popup menu. Or, select the object, then select Tools>Properties....

In the Data Model and Layout Editors:


Doubleclick on the object. Or, select the object, then select Tools>Properties....

2.

Select the tab for the category you want to view or change. Inspect all tabs before accepting the property sheet.

How To...

8 15

Display Common Properties To view or change the common properties for multiple objects: 1. In the Object Navigator, Data Model editor, or Layout editor, select the objects (all objects must be part of the same region of the report (Body, Margin, Header, or Trailer)). Select Tools>Common Properties.... Select the tab for the category you want to view or change. Inspect all tabs before accepting the property sheet.

2. 3.

If a checkbox on the property sheet is left unchanged, objects retain their current properties. To specify the same setting for all selected objects, check or uncheck a propertys checkbox. For more information about property sheets, see Report Properties in Chapter 4, Data Model Properties in Chapter 6, Layout Properties in Chapter 8, and Parameter From Properties in Chapter 10 of the Reports Reference Manual.

Customize the Display To customize the way in which the Object Navigator displays objects:
1. 2. 3. Select Navigator>Navigator Options.... In the dialog box, change the settings as desired. Accept the dialog box.

8 16

Building Reports Manual

Working with Reports


A report is an Oracle Reports module that consists of:

references to external queries and PL/SQL libraries, if any reportlevel objects that collectively define the report

Reportlevel objects include data model objects (queries, groups, columns, parameters, links), layout objects (repeating frames, frames, fields, boilerplate, anchors), and parameter form objects (fields, boilerplate). You can:

create reports 8 17 copy reports 8 5 open reports 8 5 save reports 8 5 rename reports 8 5 grant access to reports 8 6 delete reports - 8 6 archive reports - 8 7 run and print reports 8 20 convert reports 8 24 migrate reports 8 25 generate runtime reports 8 26 produce reports on reports 8 26 reference external modules 8 27

Create Reports

Using the bitmapped designer, you can:


create bitmapped reports 8 18 create charactermode reports 8 18

How To...

8 17

Create Bitmapped Reports

To create a bitmapped report: 1. In the Object Navigator:


Select the Reports node, then select Navigator>Create (or the Create tool). Or, select File>New>Report.

Under the new node are nodes for the different parts of the report (data model, layout, parameter form, report triggers, program units, attached libraries). 2. Doubleclick on the data model node icon to display the Data Model editor. Define the data model for your report. For more information, see Working with Data Model Objects on page 8 33. 3. When your data model is complete, select Tools>Default Layout... (or the Default Layout tool). Fill out the dialog box and accept it, then modify the layout in the Layout editor if desired. For more information, see Working with Layout Objects on page 8 47. 4. If desired, select Tools>Default Parameter Form.... Fill out the dialog box and accept it. Note that if you do not define a parameter form, Oracle Reports will create a default for you at runtime. For more information, see Working with Parameters on page 8 40. 5. Save the report.

Note: A report is not created until you save it. Create Charactermode Reports To create a report in the bitmapped environment so that it can be run in a charactermode environment: 1. 2. Doubleclick on the reports node in the Object Navigator to display the report property sheet. To ensure that the page size in the GUI designer will approximate that of the charactermode report, set the page size as follows:

For landscape charactermode reports with dimensions of 132 x 66, set Report:Page Width x Height to 11 x 8.5 inches. For landscape charactermode reports with dimensions of 180 x 66, set Report:Page Width x Height to 15 x 8.5 inches.

8 18

Building Reports Manual

For portrait charactermode reports with dimensions of 102 x 85, set Report:Page Width x Height to 8.5 x 11 inches. For portrait charactermode reports with dimensions of 102 x 116, set Report:Page Width x Height to 8.5 x 15 inches.

3.

On the Character Mode tab, enter the appropriate charactermode dimensions for your report (e.g., 132 or 180 x 66 for landscape or 102 x 85 or 116 for portrait). These settings will be used when the report is run in character mode. If you want the Layout editor to display in terms of character units, select Character Mode:Use Character Units in Designer. For more information about other settings, see Character Mode Tab of Report Property Sheet in Chapter 4 of the Reports Reference Manual. Note: If you are planning to sometimes run the report on a GUI platform and sometimes on a charactermode platform, you could also use format triggers to suppress bitmapped objects when running in character mode. A parameter could be used to determine whether the report is being run from a GUI or charactermode platform.

4.

5.

Under the Data Model node, doubleclick on the MODE system parameter icon. In the General:Initial Value field, type character. Accept the dialog box. In the Layout editor, select View>View Options>Rulers.... In the dialog box, set Units to Character Cells. Set Number of Snap Points Per Grid Spacing to 1. Accept the dialog box and then select View>Grid Snap. This ensures that when you create, move, or resize objects that you will do so on character cell boundaries. Select Tools>Tools Options.... Set Preferences:Horizontal Interfield and Preferences:Vertical Interfield as desired. Note that Preferences:Horizontal Gap and Preferences:Vertical Gap are ignored because you are in charactermode emulation. Objects will appear right on top of one another in the Layout editor, just as they would in true character mode. Using the Format menu, select the font, size, and weight that most closely approximates the charactermode font (e.g., clean, 12 point, medium weight). If you plan to do many reports for character mode, you should save a copy of the report with the previous steps implemented and use it as a template for future reports.

6.

7.

8.

9.

10. Design the data model for the report.

How To...

8 19

11. Create a default layout. Note: If you do not modify the default layout, your report should run with little or no problem in character mode. 12. To quickly create a parameter form that will look good in character mode, you can select Tools>Default Parameter Form... and create a default parameter form. Then clear all of the objects from the Parameter Form editor. When you run the report in character mode, Oracle Reports will use the selections you made in the Default Parameter Form dialog box and automatically create the parameter form in charactermode format. 13. Transfer the report to the charactermode system on which you plan to run it. 14. To run and print the report, see Run and Print Charactermode Reports on page 8 22 or invoke the R25RUN executable to run the report. For more information, see R25RUN in Chapter 1 of the Reports Reference Manual. Caution: Whenever you move a report to a new environment, you must recompile the PL/SQL in the report before running it. For more information about differences between bitmapped and charactermode environments, see Environment and GUI Differences in Appendix A of the Reports Reference Manual.

Run and Print Reports

A report can be run and printed in the designer, from a runfile, or from other Developer/2000 tools. You can also interrupt the running of a report. You can:

specify a printer 8 21 run and print bitmapped reports 8 21 run and print charactermode reports 8 22 run a report in the runtime environment 8 23 print a report from the Previewer 8 23 run a report from Oracle Forms and Oracle Graphics 8 23 interrupt report processing 8 24

8 20

Building Reports Manual

Specify a Printer

To specify the printer for printing your reports: 1. 2. 3. Select File>Choose Printer.... In the dialog box, enter information as required. Accept the dialog.

Run and Print Bitmapped Reports

To run a bitmapped report in a bitmapped environment: 1. 2. 3. Select or open the report. Select File>Run... (or the Run tool). In the Runtime Parameter Form, specify settings as follows:
Screen Preview File Printer Mail (UNIX only) User ID

Destination Type Destination Name

not reqd

printer driver name (for PostScript fonts) not reqd

filename

printer driver name

Destination Format (if it appears)

not reqd

printer driver name

not reqd

printer driver name

Note: Destination Format does not appear in the Runtime Parameter Form by default. For information about defining parameters to appear in the Runtime Parameter Form, see Working with Parameters on page 8 40. 4. 5. Select Run Report. If a dialog box appears, enter information as required by your operating system.

Notes: Although Preview formats the text in boilerplate objects according to PostScript specifications, the report output is shown in the Previewer using your normal screen display fonts. Therefore, some of the text in boilerplate objects may appear to have been formatted incorrectly. To send a report using Oracle*Mail (Destination Type is Mail), you can specify multiple users by enclosing their usernames in parentheses and separating them with commas (e.g., (<name>, <name>,...<name>)). For more information, see Integrating

How To...

8 21

with Other Products in Chapter 16 of the Reports Reference Manual.

To run and print a bitmapped report in a charactermode environment, use R25RUN on the command line. Specify BATCH=YES and print to a file or a bitmapped device such as a PostScript printer. Note: You cannot display a bitmapped report on a charactermode screen. For more information, see R25RUN in Chapter 1 of the Reports Reference Manual.

Run and Print Charactermode Reports

You can preview ASCII output in a bitmapped environment. This means that you can view and print charactermode reports directly in the Oracle Reports bitmapped designer. To run a charactermode report in a bitmapped environment: 1. 2. 3. Select or open the report. Select File>Run... (or the Run tool). In the Runtime Parameter Form, specify settings as follows:
Screen Preview File Printer Mail (UNIX only) User ID

Destination Type Destination Name

not reqd

not reqd

filename

UNIX: printer name Windows: not reqd

(on Windows, the Oracle Reports ASCII Driver formats your report unless you specify a different ASCII driver)

Destination F Format t

not reqd

not reqd

.prt p file

.prt p file

.prt p file

(or .prt file to Print from the Previewer)

4. 5.

Select Run Report. If a dialog box appears, enter information as required by your operating system. Refer to your Developer/2000 Installation Guide.

8 22

Building Reports Manual

Note:

To send a report using Oracle*Mail (Destination Type is Mail), you can specify multiple users by enclosing their usernames in parentheses and separating them with commas (e.g., (<name>, <name>,...<name>)). For more information, see Integrating with Other Products in Chapter 16 of the Reports Reference Manual. To run and print a charactermode report in a charactermode environment, use R25RUN on the command line. For more information, see R25RUN in Chapter 1 of the Reports Reference Manual. If ORIENTATION=LANDSCAPE for a charactermode report, you must ensure that your printer definition file contains a landscape clause.

Run a Report in the Runtime Environment

You can run a .rep file (a runfile) or an .rdf file (a report definition file) using the R25RUN executable. You can invoke R25RUN from either a command line or from a GUI such as Windows. For more information, see R25RUN in Chapter 1 of the Reports Reference Manual.

Print a Report from the Previewer

To print a report from the Previewer: 1. 2. In the Previewer, select Print. In the dialog box, enter the number of pages and copies you want to print. Note: If you run a bitmapped report with a Destination Type of
Screen, a warning appears that you should run the report with a Destination Type of Preview before printing. Preview uses printer

fonts to format the report, which is typically more desirable for printing. 3. Run a Report from Oracle Forms and Oracle Graphics Accept the dialog box to send the output in the Previewer to the printer specified by File>Choose Printer).

You can run a report from Oracle Forms and Oracle Graphics, passing data and parameters to the report as necessary. For more information, refer to your Oracle Forms and Oracle Graphics documentation. In the Windows environment, the Oracle Reports Server manages Oracle Reports requests from Oracle Forms and Oracle Graphics, providing a batch reporting capability. This allows reports to be run in the background, freeing system resources for other tasks.

How To...

8 23

The Reports Server loads the Oracle Reports executable into memory and connects to the specified database at the first request. It remains active until the session ends, avoiding the load and connect overhead for each request. The Reports Server window shows the status of queued reports, and allows you to reschedule (by dragging and dropping) and cancel reports waiting in the queue. Interrupt Report Processing In the Windows environment, a dialog box displays while a report is running to allow you to cancel or pause report processing. To halt execution of a running report:

Select Cancel report to immediately cancel processing. You cannot continue formatting the report if you cancel processing, but you can still browse previously formatted pages. Select Break at next page to format to the end of the current page before interrupting processing. This button appears in the dialog box only if you select Last (to format to the last page) or type a page number (2 or more pages after the current page) in the Previewer. You can browse previously formatted pages, then continue processing the report.

Note: Icons in the dialog box representing the client and the server indicate where processing is active.

Convert Reports

You can convert a report to create a copy of it in a different format. For example, you might convert a report definition stored in the database to a runfile that can be run via the designer (R25DES) or R25RUN. You can also convert a report definition to a portable format to transfer it between different platforms. You can convert reports between the following formats: Convert From Database Description report stored in the database Convert To Database, .rdf, .rex, or .rep Database, .rdf, .rex, or .rep Database, .rdf, .rex, or .rep No conversion allowed

RDF File (.rep) report definition (binary file with source/Pcode) REX File (.rex) one or more report definitions (text file) REP File (.rep) report definition (binary file with only Pcode)

For more information about file formats, see File Storage in Chapter 18 of the Reports Reference Manual.

8 24

Building Reports Manual

To convert report from one format to another: 1. 2. 3. Select File>Administration>Convert.... In the dialog box, select a Document Type of Report, and select the options for the conversion you want to perform. Accept the dialog box to convert the report.

Note: You can also perform format conversions using R25CONV. For more information, see R25CONV in Chapter 1 of the Reports Reference Manual.

Migrate Reports

To migrate your reports and printer definitions between different versions of Oracle Reports, you use R25MREP. You can:

migrate from SQL*ReportWriter Version 1.1 to Oracle Reports Version 2.0 8 25 migrate from Oracle Reports Version 2.0 to Oracle Reports Version 2.5 8 25 migrate from Oracle Reports Version 2.5 to Oracle Reports Version 2.0 8 25

Migrate from Version 1.1 to 2.5 Migrate from Version 2.0 to 2.5

For information about migrating an Oracle Reports Version 1.1 report to Version 2.5, refer to the Reports Migration Manual. To migrate an Oracle Reports Version 2.0 report to Version 2.5, simply install Version 2.5 and open the Version 2.0 report using Version 2.5. When you save the report, it will be saved as a Version 2.5 report. Printer definition files do not require any modification. To migrate an Oracle Reports Version 2.5 report to Version 2.0, first make sure that you are not using any of the Version 2.5 new features. For a description of the Version 2.5 new features, see the Reports Enhancements Manual. Printer definition files do not require any modification. To migrate a Version 2.5 report to Version 2.0: 1. If the report is saved in a file: 1.1 Use R25CONV (or File>Administration>Convert in the designer) to convert the report to a Version 2.5 .rex file (ASCII format). 1.2 Use R20CONV (or File>Convert in the designer) to convert the .rex file to a Version 2.0 .rdf file.

Migrate from Version 2.5 to 2.0

How To...

8 25

Note: If the report is saved in a database, you do not need to convert it. 2. If the report references external PL/SQL libraries: 2.1 Use R25CONV to convert each library to a Version 2.5 .pld file (ASCII format). 2.2 Use R20CONV to convert each .pld file to a Version 2.0 .pll file. 2.3 Using the Version 2.5 designer, detach the reports external PL/SQL library references. 2.4 Save the report to the database, or convert it as described in Step 1. 2.5 Using the Version 2.0 designer, reattach the external PL/SQL library references. 3. If the report contains link file or image objects, display the property sheets in Version 2.0 and redefine the format for these objects.

Note: Imported images are not supported when you move a report from Version 2.5 to Version 2.0.

Generate Runtime Reports

To generate a report for the runtime environment: 1. 2. 3. 4. Open the report for which you want to generate a runfile. Select File>Administration>Generate.... In the dialog box, leave the default name, type a name in the entry field, or select a name from the list of files. Accept the dialog box to generate the runfile.

Note: You can also generate multiple runfiles at one time. For more information, see R25CONV in Chapter 1 of the Reports Reference Manual.

Produce Reports on Reports

You can produce a report that documents information about all or some of the properties of a specified report stored in the database. To produce a report about a report stored in the database: 1. In the Object Navigator, select File>Administration>Report Doc. From the submenu, select how you want the output displayed (Portrait or Landscape). In the Runtime Parameter Form, change the parameter values as desired. Select Run Report.

2. 3.

8 26

Building Reports Manual

Reference External Modules

You may need to reference another module in your report. You can:

reference external queries 8 27 reference external PL/SQL libraries 8 28

Note: Use the REPORTS25_PATH environment variable to specify the default directories where you want Oracle Reports to search for external files you use in your reports. This avoids hardcoding directory paths in your report. For more information about setting this variable, see Oracle Reports Environment Variables in Chapter 18 of the Reports Reference Manual. Reference External Queries To reference an external query in a report: 1. Create a query in the Data Model editor and display its property sheet. For information about creating a query, see Create Queries on page 8 33. 2. 3. In the property sheet, select General:List.... In the dialog box, select whether the external query you want to reference is stored in the database or in a file. Accept the dialog box. In the Open dialog box, select or type the name of the external query you want to reference. If you type the name, make sure you prepend DB: for queries stored in the database and, if necessary, a path for queries stored in files. If the filename is not prefixed by a path, Oracle Reports uses its file path search order to find the file. For more information about file path search order, see FileSearching Method in Chapter 18 of the Reports Reference Manual. 5. Accept the dialog box to reference the external query, then accept the property sheet.

4.

How To...

8 27

Reference External PL/SQL Libraries In a Report

To reference an external PL/SQL library in a report: 1. 2. In the Object Navigator, select the Attached Libraries node for the report, then select Navigator>Create (or the Create tool). In the dialog box, type the name of the external PL/SQL library in the Library field, or select Find.... If you type the name, make sure you prepend DB: for libraries stored in the database and, if necessary, a path for libraries stored in files. If the filename is not prefixed by a path, Oracle Reports uses its file path search order to find the file. For more information about file path search order, see FileSearching Method in Chapter 18 of the Reports Reference Manual. If you select Find..., select the external PL/SQL library you want to reference, then accept the dialog box. 3. Select Attach to accept the dialog box. Note that the Attached Libraries list is saved with the report. The next time you open the report, the Attached Libraries list will be the same as it was when you saved the report. 4. Open the property sheet of the object in which you want to reference the external PL/SQL library. For example, if you want to reference a function in an external PL/SQL library from a report trigger, open the Report Trigger property sheet. 5. Reference the package, function, or procedure in the external PL/SQL library by name in the text of the object, then accept the property sheet.

8 28

Building Reports Manual

Working with External Queries


An external query is an Oracle Reports module that is an ANSIstandard SQL SELECT statement that can be used in more than one report or Oracle product. You can:

create external queries 8 29 copy external queries 8 5 open external queries 8 5 save external queries 8 5 rename external queries 8 5 grant access to external queries 8 6 delete external queries - 8 6 archive external queries - 8 7

Create External Queries

To create a new external query: 1. In the Object Navigator:


Select the External Queries node, then select Navigator>Create (or the Create tool). Or, select File>New>External Query.

2. 3. 4.

Doubleclick on the icon in the new node (by default, UNTITLED) to display the External Query Definition dialog. Define the external query. Insert comments into the object text using Oracles standard comment delimiters (/* and */). Save the external query.

Note: An external query is not stored until you save it. For more information, see Reference External Queries on page 8 27.

How To...

8 29

Working with External PL/SQL Libraries


An external PL/SQL library is an Oracle Reports module that consists of PL/SQL source code that can be used in more than one report or Oracle product. External PL/SQL libraries are simply sets of named functions or procedures. Unlike PL/SQL packages, the functions and procedures included in a library do not need to be logically related. However, packages can be considered libraries. You can:

create external PL/SQL libraries 8 30 copy external PL/SQL libraries 8 5 open external PL/SQL libraries 8 5 save external PL/SQL libraries 8 5 rename external PL/SQL libraries 8 5 grant access to external PL/SQL libraries 8 6 delete external PL/SQL libraries - 8 6 archive external PL/SQL libraries - 8 7 convert external PL/SQL libraries to another format 8 31 reference external PL/SQL libraries from another library 8 31

Create External PL/SQL To create a new external PL/SQL library: Libraries 1. In the Object Navigator:

Select the Libraries node, then select Navigator>Create (or the Create tool). Or, select File>New>External PL/SQL Library.

2. 3. 4. 5.

Expand the new node. Select the Program Units node, then select Navigator>Create (or the Create tool). In the dialog box, enter the name of your PL/SQL procedure, function, or package. Accept the dialog box. In the Program Unit editor, type your PL/SQL procedure, function, or package. For more information, see Call Interface in Chapter 15 of the Reports Reference Manual.

6.

Compile your code and close the Program Unit editor.

8 30

Building Reports Manual

7.

Save the external PL/SQL library.

Note: An external PL/SQL library is not created until you save it. For more information about attaching external PL/SQL libraries, see Reference External PL/SQL Libraries In a Report on page 8 28.

Convert External PL/SQL Libraries

You can convert an external PL/SQL library to between the following formats: Convert From Database PLL File (.pll) Description library stored in the database PL/SQL library (binary file with source/Pcode) Convert To Database, .pll, or .pld Database, .pll, or .pld Database, .pll, or .pld

PLD File (.pld) PL/SQL library (text file)

To convert an external PL/SQL library from one format to another: 1. 2. 3. Select File>Administration>Convert.... Select a Document Type of PL/SQL Library, and select the options for the conversion you want to perform. Accept the dialog box.

Note: You can also perform format conversions using R25CONV. For more information, see R25CONV in Chapter 1 of the Reports Reference Manual. To reference an external PL/SQL library from another library in a Reference External PL/SQL Libraries from report: Another Library 1. In the Object Navigator, under the Libraries node, expand the node for the referencing library. Select the Attached Libraries node, then select Navigator>Create (or the Create tool). 2. In the dialog box, enter the name of the external PL/SQL library in the Library field, or select Find.... If you enter the name in the Library field yourself, make sure you prepend DB: for libraries stored in the database and, if necessary, a path for libraries stored in files. If you select Find..., select the external PL/SQL library you want to reference, then accept the dialog box. 3. Select Attach to accept the dialog box.

How To...

8 31

Note: The Attached Libraries list is not saved with the external library. You need to reattach the needed libraries each time you reopen the referencing external library. 4. 5. Open the function, procedure, or package from which you want to reference the external PL/SQL library. Reference the package, function, or procedure in the external PL/SQL library by name in the text of the function, procedure, or package.

8 32

Building Reports Manual

Working with Data Model Objects


A data model defines what data should be fetched or calculated for a report. The data may appear in the report output, be used to calculate computations, or cause Oracle Reports to perform actions (e.g., execute PL/SQL or user exits). Data model objects include queries, links, groups, columns, and parameters. You can:

create data model objects 8 33 work with parameters 8 40 display data model object properties 8 42 rename data model objects 8 43 delete data model objects 8 43 select and deselect data model objects 8 10 move data model objects 8 45 resize data model objects 8 12 reference columns and parameters 8 46 magnify or reduce the Data Model editor display 8 46

Create Data Model Objects

In the Data Model editor, you can:


create queries 8 33 create links 8 34 create groups 8 35 create columns 8 36

Create Queries

Queries are SQL SELECT statements that defines which rows and columns from specified tables or views are to be fetched from the database. A query is different from an external query in that it cannot be referenced by other modules. The data fetched by your query can be used in calculations, sorts, or set operations such as UNION, and optionally displayed in the report output. To create a query in a report: 1. In the Data Model editor, select the Query tool. Click in the painting region to create a query. (To create many queries at once, doubleclick on the Query tool. The tool remains selected until you click on another tool.)

How To...

8 33

2.

Doubleclick on the query object to display its property sheet. Replace the name in the General:Name field if you dont want to use the default, then specify a SELECT statement or reference and external query and accept the property sheet. For more information, see Query Properties in Chapter 6 of the Reports Reference Manual.

Create Links

A data link establishes the relationship between the data of two queries. When a report with a data link is executed, the data link is converted into a SQL clause (e.g., WHERE DEPTNO = DEPTNO) and appended to the child query. The child query is executed with the values of the primary key used by the parent. To create a link in your data model: 1. In the Data Model editor, select the Data Link tool. (To create many links at once, doubleclick on the Data Link tool. The tool remains selected until you click on another tool.) Create a data link:

2.

Create Query to Query Links If a database constraint is defined between tables, Oracle Reports can automatically detect and link the primary and foreign key columns when you link queries that select from the tables. To create a data link for each database constraint defined between the tables for two queries, click on the parent query, then drag to the child query to create a link for each database constraint defined between the tables for the two queries. Create Group to Group Links To create a link between one querys group and another querys group, which is useful when you want the child query to know about the parents data, click on the parent group (avoiding the columns in the group) and drag a link to the group belonging to the child query. Create Column to Column Links To create a link between columns, click on a column of the parent group and drag a link to a column of the child query.

Note: A link is always drawn from the parent group to the child query. 3. Doubleclick on the link object to display its property sheet. Modify the link definition if necessary, then accept the property sheet. For more information, see Link Properties in Chapter 6 of the Reports Reference Manual.

8 34

Building Reports Manual

Create Groups

Groups have two functions: to filter a querys data, and to separate a querys data into sets. By default, Oracle Reports generates one group for each query and assigns all of the querys columns to it. You create additional groups to:

produce breaks (an identical value in sequential records is printed only once for the records) summarize data at a more granular level (e.g., for each department, instead of for the entire company) produce matrix reports

You can:

create break groups 8 35 create crossproduct groups 8 35

Create Break Groups A break group divides a querys columns into sets. Use a break group to create a report in which an identical value in sequential rows is printed only once for its related records. To create a break group: 1. In the Data Model editor, drag the group that contains the column at which you want to break your report down from the query object about 2 inches. Select the column that you want to use to divide your report (e.g., if you want to group a list of employee data by department number, select the department number column) and drag it out of and above the group to create a new group. Note: If the column is in a group inside of a crossproduct group, you should delete the crossproduct group, create the new group, and then recreate the crossproduct group. 3. Doubleclick on the title bar of the new group object to display its property sheet. Replace the name in the General:Name field if you do not want to use the default. Fill in the rest of the property sheet as necessary and accept it. For more information, see Group Properties in Chapter 6 of the Reports Reference Manual. Create CrossProduct Groups A crossproduct group is generally used to create matrix reports. To create a matrix report, you need at least four groups: one group must be a crossproduct group, two of the groups must be within the crossproduct group to furnish the labels of the matrix report, and at least one group must provide the information to fill the cells of the matrix report.

2.

How To...

8 35

The groups can belong to a single query or to multiple queries. To create a crossproduct group: 1. 2. In the Data Model editor, select the Cross Product tool. Click and drag a rectangle around the groups you want to include in the crossproduct group. Ensure that the box you drag completely surrounds the groups you want in the crossproduct. You cannot drag groups into the crossproduct after you create it. If the crossproduct does not contain all the groups you want it to, then you should delete it and redraw it. Groups within the crossproduct group should have a thicker border than other groups. 3. If the cell group is a separate query from the crossproduct groups, create the appropriate links between the columns in the crossproduct groups and the cell group. Default the layout and select Style:Matrix. On the Data/Selection tab, set the repeat direction for the matrix groups to Matrix, one crossproduct group to Across and the other to Down, and the cell group to Down. Deselect all but the crossproduct and cell columns, and delete all column labels (these are provided by the crossproduct column values). Accept the Default Layout dialog box.

4.

Note: Crossproduct groups are most often used in matrix reports. For more information about matrix reports, see Matrix Reports in Chapter 2 of the Reports Reference Manual. Create Columns Columns are data containers. To create a column in a report, you must select the column in a query. The columns you select from the database can contain data of standard datatypes, OLE2 objects, images, sound, video, and references to file names or the contents of files. In addition to columns of data extracted from the database in a SELECT statement, you can also create columns that contain summaries, formulas, or act as placeholders. You can:

create columns with OLE2 objects 8 37 create columns with images 8 37 create columns with sound and video 8 37 create columns with large image and sound objects 8 38 create columns that reference files 8 38 create summary, formula, or placeholder columns 8 39

8 36

Building Reports Manual

Create Columns with OLE2 Objects When you default a report layout, Oracle Reports automatically generates a field or button (e.g., for video) to contain an OLE2 object. To include OLE2 objects in your report: 1. Create a query that selects a column containing OLE2 objects or the filenames of OLE2 objects. For information about creating a query, see Create Queries on page 8 33. 2. 3. Doubleclick on the column in the Data Model editor to display its property sheet. In the General:Format field, select OLE2. If the column contains the filenames of OLE2 objects, also check Read from File. For more information, see General Tab of Column Property Sheets in Chapter 6 of the Reports Reference Manual. 4. 5. Accept the property sheet. Default the layout.

For more information about OLE2 objects, see OLE2 in Chapter 16 of the Reports Reference Manual. Create Columns with Images To include images in your report: 1. 2. Create a query that selects a column containing images. Doubleclick on the column to display its property sheet. On the General tab, select the file format. For more information, see General Tab of Column Property Sheets in Chapter 6 of the Reports Reference Manual. 3. Accept the property sheet.

Note: Images will appear as fields instead of buttons when you default the layout so that they display in the printed report, not only in the Previewer. If you prefer, you can create buttons for images, as described in Create Buttons on page 8 55. Create Columns with Sound and Video When you default a report layout, Oracle Reports automatically creates buttons for:

sound objects the names of files that contain video objects

How To...

8 37

To include sound and video in your report: 1. In the Data Model editor, create a query that selects a column containing sound objects or the filenames that contain video objects. Doubleclick on the multimedia column to display its property sheet, and do one of the following:

2.

For columns that contain sound objects, verify the General:Datatype setting is Long Raw, and select a General:Format of Sound. For columns that contain filenames of video objects, verify the General:Datatype setting is Char, select General:Read from File and a General:Format of Text.

3.

Default the layout.

Note: The database cannot store video objects, but can store the names of files that contain video objects. Create Columns with Large Image and Sound Objects You can include an unlimited number of image and sound objects without running out of local disk space by using noncaching references. A noncaching reference causes objects to be read from the database only when needed while the report is processing, thereby conserving the temporary space required when all report objects are cached locally. You must be connected to an ORACLE V7.1 database to use this feature. To specify that an image or sound column be a noncaching reference: 1. Use the following syntax in the SELECT statement for your query:
SELECT CDE_MM.GET_REF(table_name, column_name, table_name.rowid) alias_name FROM table_name

2.

In the column property sheet, select a General:Format setting of Image or Sound. Verify that General:Datatype is set to REF.

Create Columns that Reference Files If you have a large number of files containing text or graphics that you want to include in your report, you can include a column that contains their filenames. To include a column that contains the names of files in your report: 1. 2. Select the column in a query. Doubleclick on the column to display its property sheet. On the General tab, check Read from File and select the file format. For more information, see General Tab of Column Property Sheets in Chapter 6 of the Reports Reference Manual.

8 38

Building Reports Manual

Note: If you do not check Read from File, the filenames, rather than the files contents, will be displayed as the columns values. 3. Accept the property sheet.

Create Summary, Formula, or Placeholder Columns In addition to columns of data extracted from the database in a SELECT statement, you can also create three types of columns:

Summary Columns A summary is a computation that is performed on all records of a single column; for example, the sum of all salaries. Oracle Reports is shipped with the summaries for Average, Count, First, Last, and Maximum. Each summary, except First and Last, has a running variation (e.g., running sum, running percent) that you create by specifying, via the Reset At field, how frequently the summary resets to zero. Formula Columns A formula is a computation performed on a single record spanning one or more columns. For example, :ITEMTOT *.07 is a formula that performs an arithmetic function on a single column to compute sales tax, while :SAL + :COMM uses values from two columns to compute total compensation. Oracle Reports is not shipped with formulas; you create your own using PL/SQL or supported 3GLs. Thus, you can create any number or type of customized computations you need. If you use PL/SQL, Oracle Reports provides a PL/SQL editor in which to write the computation. If you use a 3GL, you need to link your program to Oracle Reports. For details on how to write user exits and link them to Oracle Reports, see User Exit Interface in Chapter 14 of the Reports Reference Manual. Placeholder Columns A placeholder is a dummy column for which you can conditionally set the datatype and value via PL/SQL or a user exit. Placeholder columns are useful when you want to selectively populate a column with a value (e.g., each time the nth record is fetched, or each time a record is fetched containing a specific value, etc.).

To create one of these columns: 1. In the Data Model editor, select the Summary Column, Formula Column, or Placeholder Column tool.

To create a column within a group, click in the desired group. The place you click determines where the column will be placed in the hierarchy.

How To...

8 39

To create a reportlevel column, click in an open area of the painting region.

2.

Doubleclick on the column object to display its property sheet. Replace the name in the General:Name field if you dont want to use the default. Then fill in the settings for the type of object you are creating and accept the property sheet. For more information, see Summary Column Properties, Formula Column Properties, and Placeholder Column Properties in Chapter 6 of the Reports Reference Manual.

Work with Parameters

Parameters are variables to which you can assign values at runtime. Parameters are especially useful in modifying SELECT statements at runtime and in PL/SQL. You can:

use predefined system parameters 8 40 create your own parameters 8 41 create a parameter list of values (LOV) 8 41 validate a parameter value at runtime 8 42 delete parameters 8 42

Use System Parameters

To define a system parameter for use during runtime: 1. 2. 3. In the Object Navigator, expand the System Parameters node (under the Data Model node) for your report. Doubleclick on the property sheet icon for the parameter you want to modify. In the property sheet, type a value in General:Initial Value, if required. For more information, see Parameter Properties in Chapter 6 of the Reports Reference Manual. 4. To validate a parameters value at runtime, add a PL/SQL validation trigger:

In the Parameter property sheet, select General:Edit.... In the Program Unit editor, enter the PL/SQL code to be triggered at runtime. Compile the code and close the Program Unit editor.

5.

Accept the parameter property sheet.

8 40

Building Reports Manual

Create Parameters

To create a parameter: 1. In the Object Navigator, select the User Parameters node (under the Data Model node) for your report, then select Navigator>Create (or the Create tool). Note: A parameter will be automatically created for you if you have a bind parameter reference in a querys SQL SELECT statement (e.g., ... WHERE column_name = :user_parm); if you want to use a lexical parameter reference in a query, you need to create the parameter yourself. 2. Doubleclick on the property sheet icon for the new parameter and fill in the name, settings, initial value, and list of values as desired. Accept the property sheet. For more information, see Parameter Properties in Chapter 6 of the Reports Reference Manual. 3. To validate a parameters value at runtime, add a PL/SQL validation trigger:

In the Parameter property sheet, select General:Edit.... Or, in the Object Navigator, select the PL/SQL icon for the parameter.

4. Create a Parameter List of Values

In the Program Unit editor, enter the PL/SQL code to be triggered at runtime. Compile the code and close the Program Unit editor.

On the Runtime Parameter Form, a parameter can display a list of values (LOV), which can be restricted to only the specified values, or unrestricted to allow users to edit or specify parameter values at runtime. You can create the list using a SELECT statement, or by specifying static values. To create a list of values for a parameter: 1. In the Parameter property sheet, select the type of list that you want to create:

For Data/Selection:Static Values, enter a value in the Value field and select Add. Repeat for each value you want to add. (Select Remove to delete items from the list.) For Data/Selection:SELECT Statement, enter a query to populate the list of values. You can select more than one column to display in the LOV, where the first column contains the value to be assigned to the parameter. The LOV displays columns in the order specified in the query.

How To...

8 41

2.

Check Data/Selection:Restricted if you want the parameter value to be restricted to only those in the LOV. Uncheck Data/Selection:Restricted to allow users to edit values or type a different value in the Runtime Parameter Form. Check Data/Selection:Hide First Column if you do not want the first column (which contains the parameter value) of your query displayed in the LOV. Uncheck Data/Selection:Hide First Column if there is no need to preserve the confidentiality of the first column.

3.

Validate a Parameter Value at Runtime

To validate a parameters value at runtime, add a PL/SQL validation trigger: 1. Display the Program Unit editor:

In the Parameter property sheet, select General:Edit.... Or, in the Object Navigator, select the PL/SQL icon for the parameter.

2. 3. Delete Parameters

In the Program Unit editor, enter the PL/SQL code to be triggered at runtime. Compile the code and close the Program Unit editor. Accept the property sheet.

If you delete a parameter, the parameter is deleted, but references to the parameter by other objects are not modified. You must delete references to the parameter or enter a valid parameter name for those references before you run the report. To delete a user parameter: 1. In the Object Navigator, select the User Parameters node (under the Data Model node) for your report, then select the parameters you want to delete. Select Navigator>Delete (or the Delete tool).

2.

Note: You cannot delete system parameters.

Display Data Model Object Properties

To display the property sheet for a data model object:


Doubleclick on the object. Or, select the object, then select Tools>Properties....

To display a common property sheet for multiple objects: 1. 2. Select the objects (all objects must be part of the same region of the report (Body, Margin, Header, or Trailer)). Select Tools>Common Properties....

8 42

Building Reports Manual

For more information about data model object property sheets, see Data Model Properties in Chapter 6 of the Reports Reference Manual.

Rename Data Model Objects

You can rename a column, group, parameter, or query. Rename via the Object Navigator To rename a data model object using the Object Navigator: 1. 2. Select the object. Click on the name in the node to change the cursor to an Ibeam. Change the name as desired. Note that you cannot change the names of system parameters. Click outside the name to quit edit mode and update the name in other Reports objects that reference it.

3.

Rename via a Property Sheet To rename a data model object using a property sheet: 1. 2. Display the objects property sheet. Replace the existing object name in the General:Name field with the new name. Note that you cannot change the names of system parameters. Accept the property sheet. The name change cascades to other data model objects referencing the renamed object.

3.

Note: If you have already created a layout, the name change does not cascade to the layout objects. You must either update references in the layout objects to the object manually or generate a default layout. For example, if you rename a column, and there is a field that references that column, the Source setting will change to *Undefined*.

Delete Data Model Objects

You can delete objects in the Data Model editor by clearing them. When you clear an object, you delete it. Oracle Reports does not store the object in the paste buffer. Note: When you delete a data model object, the query, group, or column and any data model objects directly owned by the object are deleted. All references (e.g., a summary columns Source setting) to the deleted objects will be labelled *Undefined*. You cannot run the report until you enter a valid object name for these references. You can:

delete queries 8 44 delete links 8 44 delete groups 8 44

How To...

8 43

delete columns 8 45 delete a database column 8 45

Delete Queries

If you delete a query, the following objects are deleted:


the query any groups directly owned by the query any columns contained in groups directly owned by the query any links that reference the groups and columns directly owned by the query

To delete a query:

In the Object Navigator Select the query, then select Navigator>Delete (or the Delete tool). In the Data Model Editor Select the query, then select Edit>Clear.

Delete Links

To delete a link:

In the Object Navigator Select the link, then select Navigator>Delete (or the Delete tool). In the Data Model Editor Select the link, then select Edit>Clear.

Delete Groups

If you delete a group, the following objects are deleted:


the group any summary or formula columns in the group

You cannot delete the default group for a query unless you delete the query. Note: Any database columns in the group are moved to the next lower group in the group hierarchy, if there is one. If there is not, the columns are moved to the next higher group in the data model hierarchy. Any references to the deleted group in links are changed to the parent columns new group.

8 44

Building Reports Manual

To delete a group:

In the Object Navigator Select the group, then select Navigator>Delete (or the Delete tool). In the Data Model Editor Select the group, then select Edit>Clear.

Delete Columns

If you delete a manually created column, only the column is deleted. To delete a column:

In the Object Navigator Select the group, then select Navigator>Delete (or the Delete tool). In the Data Model Editor Select the column, then select Edit>Clear.

Delete a Database Column

To delete a database column: 1. 2. 3. Open the Query property sheet for the query that selects the column. Edit the SELECT statement for the query and remove the column from the SELECT list. Accept the property sheet.

Move Data Model Objects

To move a column, group, parameter, or query to a different position: 1. 2. In the Data Model editor, select the object you want to move. Drag the object to its new position. When moving a column, drag it until it is actually covering the column above which you want it to appear.

You can also: move objects by pixel 8 46 reorder columns 8 46 move a summary or formula between groups 8 46

Notes:

Links cannot be movedthey must be deleted and recreated. Groups are ordered in the Default Layout dialog box according to their order in the Data Model editor. If a query is owned by a group, its groups appear after the group that owns the query. If queries are unrelated, their groups are ordered in the Default Layout dialog box as they appear in the Data Model editor (reading from left to right, top to bottom).

How To...

8 45

Columns are ordered in the Default Layout dialog box in the same order as they appear in their groups.

Move Objects By Pixel

To move objects one pixel at a time: 1. 2. 3. In the Data Model editor, deselect Grid Snap (select View>Grid Snap and ensure that it is not checked). Select all objects you want to move. Press the arrow key on your keyboard corresponding to the direction in which you want the selected objects to move. Each time you press an arrow key, the selected objects will move one pixel in that direction. Note: If Grid Snap is checked, each time you press an arrow key all selected objects will move one unit in that direction, based upon the currently specified unit of measurement.

Reorder Columns Move a Summary or Formula Between Groups

To change the order of a column in a query, select the column and drag it to a new position in the group. To move a summary or formula column between groups in the same query, select the column and drag it to the target group. Note: You cannot move a summary or formula column between queries, or between the report level and a query.

Reference Columns and Parameters

You reference columns and parameters in PL/SQL just as you do any variables in PL/SQL. For more information, refer to your PL/SQL documentation.

Magnify or Reduce the You can magnify the Data Model editor display or reduce the size of the objects to see the entire layout on one screen. Data Model Editor Display To magnify the Data Model editor display, select View>Zoom
In (or click on the Magnify tool, then click in the painting region).

To reduce the Data Model editor display, select View>Zoom Out (or click on the Magnify tool, then shiftclick in the painting region).

8 46

Building Reports Manual

Working with Layout Objects


Layout objects define a reports appearance. Layout objects include repeating frames, frames, anchors, boilerplate graphics and text, buttons, OLE2 and Oracle Graphics objects, matrix objects, frames, and fields. Use the Layout editor to position your report information exactly as you want it. You can:

activate layout modes 8 47 create a default layout 8 48 create layout objects 8 50 display layout object properties 8 58 rename layout objects 8 58 delete layout objects 8 59 select and deselect layout objects 8 10 group layout objects 8 59 move layout objects 8 60 resize layout objects 8 12 copy and paste layout objects 8 63 modify layout objects 8 64 magnify or reduce the Layout editor display 8 64 undo editor actions 8 72 import layout objects 8 72 export layout objects 8 73

Activate Layout Modes As you manipulate objects in the Layout editor, you can activate two
modes: Confine Mode This mode confines a child object within its enclosing parent object. For example, if Confine mode is on, you will not be able to move a field outside the borders of its repeating frame. This mode prevents errors resulting from child objects overlapping or moving outside the borders of parent objects. To set or override Confine mode:

Select View>View Options>Layout... and check or uncheck Layout:Confine (or toggle the mode using the Confine tool).

How To...

8 47

Flex Mode Flex mode intelligently resizes all parent objects when a child object bumps into a parent border. This mode simplifies modifying an existing layout; you no longer have to resize a group frame, then a repeating frame, and so on to move or resize fields down or to the right. To set or override Flex mode:

Select View>View Options>Layout... and check or uncheck Layout:Flex (or toggle the mode using the Flex tool).

Note: On an empty Layout editor canvas, press the right mouse button to display a menu to select layout modes, edit actions, and the property sheet for the layout.

Create a Default Layout

Oracle Reports has six default layouts that you can use for your reports. When you create a default layout, Oracle Reports creates the layout objects necessary to produce the desired output. You can:

create a default layout for the entire report 8 48 create a default layout for a selected part of the report 8 49 create a default layout with more white space 8 50

Create a Default Layout for a Report

To create a default layout for your entire report: 1. Create a data model for your report. Note that your data model must meet the requirements of the layout style you intend to choose. For more information about data model requirements for each layout, see Layout Defaulting in Chapter 2 of the Reports Reference Manual. 2. 3. 4. 5. 6. 7. Select Tools>Default Layout... (or the Default Layout tool). In the dialog box, on the Style tab, select one of the default layout styles. On the Data/Selection tab, choose the groups that you want included in the default layout. In Repeat, select a print direction for each group from the list of values. Choose the columns that you want to include in the default layout. Modify the label and width for the columns, if necessary.

8 48

Building Reports Manual

8. 9.

If you want to use the most recent Layout editor settings in creating the default layout, check Use Current Layout Settings. Accept the dialog box.

Caution: If you default your layout after having previously created a layout, all the existing objects in the report body are removed and replaced with the new layout objects. However, objects in the header page, trailer page, and margins are untouched. To avoid replacing your entire layout, you should use the Default Layout tool to create a layout for just a selected area in the editor, as described below. Create a Default Layout for Part of a Report To create a default layout for a selected part of your report: 1. Create a data model for your report. Note that your data model must meet the requirements of the layout style you intend to choose. For more information about data model requirements for each layout, see Layout Defaulting in Chapter 2 of the Reports Reference Manual. 2. 3. 4. 5. 6. 7. 8. 9. Go to the Layout editor and select the Additional Default Layout tool. Click and drag a rectangular area where you want to place the default layout. In the dialog box, on the Style tab, select one of the default layout styles. On the Data/Selection tab, choose the groups that you want included in the default layout. In Repeat, select a print direction for each group from the list of values. Choose the columns that you want to include in the default layout. Modify the label and width for the columns, if necessary. If you want to use the most recent Layout editor settings in creating the default layout, check Use Current Layout Settings.

10. Accept the dialog box. The default layout objects are created within the area you defined with the Default Layout tool. 11. Repeat steps 2 through 10 to create multiple default layouts within the same report.

How To...

8 49

Create a Default Layout with More White Space

To create a default layout with more white space between objects: 1. 2. Select Tools>Tools Options.... In the dialog box, enter larger values for Preferences:Horizontal Gap and Preferences:Vertical Gap to increase the space between objects and the objects they enclose. Enter larger values in Preferences:Horizontal Interfield and Preferences:Vertical Interfield to increase the space between fields. Create a default layout as you normally would (follow procedures above).

3.

Create Layout Objects

Layout objects define a reports format; i.e., the positioning and appearance of data, text, and graphics in the report output. You can:

create field objects 8 50 create boilerplate text objects 8 51 create drawing objects 8 52 create image objects 8 52 create link objects to files 8 53 create frame objects 8 53 create anchor objects 8 54 create OLE2 objects 8 54 create Oracle Graphics display objects 8 55 create buttons 8 55 create matrix objects 8 56 create page objects 8 56

Create Field Objects

Fields are placeholders for parameters and columns, including the page number and current date. If a parameter or column does not have an associated field, its values will not appear in the report output. When you create a default layout, Oracle Reports generates one field for each column, and places each field inside of a repeating frame. To create a field object: 1. 2. Select the Field tool. Click and drag to create the object. (To create many fields at once, doubleclick on the Field tool. The tool remains selected until you click on another tool.)

8 50

Building Reports Manual

3.

Doubleclick on the field to display its property sheet. Modify any of the defaults, then accept the property sheet. For more information, see Field Properties in Chapter 8 of the Reports Reference Manual.

Create Boilerplate Text Objects

You can use boilerplate text to customize your report by changing the default labelling, creating report heading pages, adding graphics, etc. You can:

create a boilerplate object, then type text 8 51 type the text directly in the editor 8 51 reference fields in boilerplate text 8 52

Create a Boilerplate Object To create a boilerplate object for typing text: 1. 2. 3. Select the Text tool. Click and drag to create an empty boilerplate object in the painting region. Type the desired text. The text you type is composed of paragraphs which are separated by new lines. Text within a paragraph is wordwrapped inside the boilerplate objects horizontal size. 4. When you are done typing, click outside of the boilerplate text object.

Type Directly To type text directly in the Layout editor: 1. 2. Select the Text tool. Click in the painting region where you want the text to begin and begin typing. The text you type is composed of paragraphs that are separated by new lines. Text within a paragraph is wordwrapped inside of the boilerplate objects horizontal size. Since the horizontal size of the boilerplate text grows as you type in this case, the text does not wordwrap. You must press Return to move to the next line. 3. When you are done typing, click outside of the boilerplate text object.

How To...

8 51

With both methods for creating boilerplate text, the vertical size of the text grows as you type more text. However, after the boilerplate text object is created and you leave text mode, the horizontal size of the object is fixed and the next time you edit the text, it wordwraps within the horizontal boundaries. Reference Fields in Boilerplate Text To include the value of a field within boilerplate text: 1. 2. 3. Select the Text tool. Create a new boilerplate text object or click on an existing one. Move the text cursor to the location where you want the reference to a field to appear. Type an ampersand (&) followed by the name of the field. If you want to place the field reference next to other text with no spaces in between, enclose the field name in angle brackets (e.g., &<fieldname>Kg). Otherwise, Oracle Reports will assume that all of the text between the ampersand and the next space is part of the field name. Note, however, that you can put references right next to each other with no spaces in between and without angle brackets (e.g., &field1&field2&field3). Create Drawing Objects To create a drawing object: 1. Select the appropriate tool (e.g., Rectangle tool for a rectangle). (To create many of the same type of object at once, doubleclick on the appropriate tool. The tool remains selected until you click on another tool.) To create a line, rounded rectangle, rectangle, ellipse, arc, or freehand object, click in the painting region and drag to create the object. To create a polygon or polyline, click in the painting region where you want each point of the object, then doubleclick to create the object. Doubleclick on the object to display its property sheet. Modify any of the objects defaults, then accept the property sheet.

2.

3.

To draw constrained objectsi.e., perfect circles and squares, etc.you can hold down the constrain key when drawing the graphic. For more information, see Constrained Mode in Chapter 7 of the Reports Reference Manual. Create Image Objects To create an image object: 1. 2. Select the Link File tool. Click and drag to create an image boilerplate object.

8 52

Building Reports Manual

3.

Doubleclick on the object to display its property sheet. Enter the name of the file to which you want the boilerplate linked in the Object:Link File field, and the format of the file in the Object:Format field. For more information, see Boilerplate Properties in Chapter 8 of the Reports Reference Manual.

4. Create Link Objects to Files

Accept the property sheet.

If you have a text or graphic file that you would like to display as boilerplate in your report, you can link to the file. To import the contents of a file into your report, see Import Layout Objects on page 8 72. To create a boilerplate object that gets its contents from a file: 1. 2. 3. Select the Link File tool. Click and drag to create a link file boilerplate object. Doubleclick on the object to display its property sheet. Enter the name of the file to which you want the boilerplate linked in the Object:Link File field, and the format of the file in the Object:Format field. For more information, see Boilerplate Properties in Chapter 8 of the Reports Reference Manual. 4. Accept the property sheet.

Create Frame Objects

To create a frame or repeating frame object: 1. 2. Select the Frame tool. Click and drag to create the object. (To create many frames at once, doubleclick on the Frame tool. The tool remains selected until you click on another tool.) Doubleclick on the frame to display its property sheet. Modify any of the defaults, as required. For more information, see Frame Properties and Repeating Frame Properties in Chapter 8 of the Reports Reference Manual. 4. Accept the property sheet.

3.

How To...

8 53

Create Anchor Objects

Anchors determine the relative positioning of all objects in the report output. They attach one layout object, called the child object, to a second, called the parent object. They also define the vertical and horizontal positioning of the child relative to its parent. The child object may be either outside of or contained within the parent. To create an anchor between two objects: 1. 2. Select the Anchor tool. Click on an edge of the child object and doubleclick on an edge of the parent object. A line is drawn from the child to the parent. A small box appears at the end of the line that is attached to the parent object. Note: An object may be anchored to only one other object, even if it has two anchors.

Create OLE2 Objects

To create an OLE2 boilerplate object in the Layout editor: 1. 2. Select the OLE2 Object tool and drag a rectangle. In the dialog, select the appropriate radio button:

Create New Select the type of object you want to create. Create from File Specify the name of a file or select Browse... to choose a file. Also select Link if you want the object linked to the file (rather than copied into the report).

3. 4.

Select Display As Icon if you want the OLE2 object displayed in your report as an icon. Accept the property sheet.

Notes: The appearance of a usercreated OLE2 boilerplate object in the Layout editor is dependent upon the type of object it is (i.e., whether its a document, spreadsheet, graphic, video, etc.). To activate an OLE2 object in your report layout, move your cursor over the object, and click and hold the right mouse button. From the popup menu, select the Object item to display a submenu of actions that can be performed by the objects server.

For more information about OLE2 objects, see OLE2 in Chapter 16 of the Reports Reference Manual.

8 54

Building Reports Manual

Create Oracle Graphics Display Objects

To create an Oracle Graphics object that gets its contents from an Oracle Graphics display: 1. 2. 3. Select the Oracle Graphics tool. Click and drag to create an Oracle Graphics object. Doubleclick on the object to display its property sheet. Type the name and source of the Oracle Graphics Display object in O.G. Display:Display Name and O.G. Query:Source. Fill out the rest of the property sheet as necessary. For more information, see Oracle Graphics Properties in Chapter 8 of the Reports Reference Manual. 4. Accept the property sheet.

For more information about passing data and parameters from a report to an Oracle Graphics display, see Oracle Graphics in Chapter 16 of the Reports Reference Manual. Create Buttons You can use the Layout editor to create your own buttons when you want to:

access multimedia (image, sound, or video) objects stored in files (unless the filenames are stored in a database column; in this case, you can default the layout to create default buttons for sound and video objects) access images stored in the database (when you default the layout, Oracle Reports creates fieldsnot buttonsto display images stored in the database; if you want to display the images by clicking on buttons instead, you must create the button in the Layout editor) execute PL/SQL

To create buttons: 1. 2. 3. In the Layout editor, select the Button tool and drag a rectangle. Doubleclick on the button object to display the property sheet. On the Object tab, select the appropriate radio button:

Multimedia File Specify the filename that contains the multimedia object and select an Object:Type of Image, Sound, or Video. Multimedia Column (This is only valid if you have selected a database column that contains an image or sound object, and defined the format in the column property sheet.) Select the column name from the poplist.

How To...

8 55

Execute PL/SQL Select the Edit... button to specify a PL/SQL program unit to be executed when the button is selected.

4. 5.

Choose an Object:Label of Text or Icon. If you choose Text, type the text you want to appear on the button. If you choose Icon, specify the name of the file that contains the icon that you want to appear for the button. For more information, see Button Properties in Chapter 8 of the Reports Reference Manual.

6.

Accept the property sheet.

Note: Buttons are only available when you run the report with a Destination Type of Screen or Preview. If you run the report to any other destination, the button will not appear in the output. Create Matrix Objects If you create a matrix report using the default layout, a matrix object is created for you. To create your own matrix object: 1. Select two or more repeating frames that intersect. Ensure that:

At least one of the repeating frames has a Print Direction of Across and another a Print Direction of Down. If more than two repeating frames are selected, they are completely enclosed by the others.

2.

Select Tools>Create Matrix. One matrix object will be created at the intersection of every two intersecting repeating frames.

Create Page Objects

On the pages of your report, you can:


number pages 8 56 include time and date stamps 8 57 create margin objects 8 57 create header and trailer objects 8 58

Number Pages To number the pages of a report: 1. 2. 3. Select the Field tool to create a field object. Doubleclick on the field object to display its property sheet. In the Object:From field, select &Physical Page Number. For more information about the other page number selections, see Field Properties in Chapter 8 of the Reports Reference Manual.

8 56

Building Reports Manual

4. 5.

Select Object:Page Numbering..., and fill out the dialog box. Accept the dialog box. If you want to add text to the page number (e.g., Page n), select Object:Hidden. Accept the dialog box, then in the Layout editor, create a boilerplate text field for referencing the page number field (e.g., Page &F_PAGE).

For more information about specifying page numbers, see Page Numbering in Chapter 8 of the Reports Reference Manual. Include Time and Date Stamps To include the time or date in a report: 1. 2. 3. 4. Select the Field tool to create a field object. Doubleclick on the field object to display its property sheet. In the Object:From field, select &Current Date. In the Object:Format Mask field, enter the mask that defines how you want the time or date to appear (e.g., MM/DD/YY fmHH:MI AM). For more information about format masks, see Format Mask in Chapter 8 of the Reports Reference Manual. Create Margin Objects To create objects in the margin of a report: 1. 2. 3. 4. 5. Select View>View Options>Layout.... In the dialog box, select a Layout:Display Layout Using setting of Margin (or select the Margin tool). Accept the dialog box or select Apply, which places the cursor in the margin. To adjust the margin, click on the margin border, then select a handle and drag the margin to the desired position. Create required objects in the margin area. These objects will appear on all pages of the report. Note: If you create objects in the body portion of a report while displaying the margin area, you will not be able to edit those objects when the margin is not displayed.

How To...

8 57

Create Header and Trailer Objects To create objects on the header (beginning) and trailer (ending) pages of a report: 1. Select View>View Options>Layout..., then select a Layout:Display Layout Using setting of Header or Trailer (or select the Header or Trailer tool). Create required objects in the Layout editor. These objects will appear on the header or trailer pages of your report.

2.

Display Layout Object Properties

To display the property sheet for a layout object:


Doubleclick on the object. Or, select the object, then select Tools>Properties....

To display the common property sheet for multiple objects: 1. 2. ,Select the objects (all objects must be part of the same region of the report (Body, Margin, Header, or Trailer)). Select Tools>Common Properties....

For more information about layout object property sheets, see Layout Properties in Chapter 8 of the Reports Reference Manual.

Rename Layout Objects

You can rename repeating frames, frames, fields, boilerplate, and matrix objects: Rename via the Object Navigator To rename a layout object using a property sheet: 1. 2. Select the object. Click on the name in the node to change the cursor to an Ibeam. Change the name as desired. Note that you cannot change the names of system parameters. Click outside the name to quit edit mode and update the name in other objects that reference it.

3.

Rename via a Property Sheet To rename a layout object using a property sheet: 1. 2. 3. Display the objects property sheet. Replace the existing object name in the General:Name field with the new name. Accept the property sheet. The name change cascades to other layout objects referencing the renamed object.

Note: Anchors are not named.

8 58

Building Reports Manual

Delete Layout Objects

You can delete repeating frames, frames, fields, boilerplate, and anchors in the Layout editor by cutting or clearing. Cut Objects When you cut an object, you effectively delete it. However, Oracle Reports stores the most recently cut object in a paste buffer so that you can paste it somewhere else, as many times as you want. To cut an object: 1. 2. Select the object. Select Edit>Cut.

Note: To cut an anchor, you must also select the objects it anchors together. If you select the anchor and neither of the objects it anchors together, nothing will be copied to the Clipboard. If you select one of the objects and the anchor, only the object will be copied to the Clipboard. Similarly, for a matrix, you must select the matrix and its two repeating frames. Clear Objects When you clear an object, you delete it. Oracle Reports does not store the object in the paste buffer. To clear an object:

In the Object Navigator, select the object you want to delete, then select Navigator>Delete (or the Delete tool). Or, select the object, then select Edit>Clear.

Delete Matrix Objects To delete a matrix object, you can use the methods described above or you can do the following: 1. 2. Select one or more of the repeating frames whose intersection forms the matrix. Move the repeating frame such that it no longer intersects with the other repeating frames. A dialog box is displayed asking if you want to delete the matrix. Accept the dialog box. The matrix is deleted.

3.

Group Layout Objects

When manipulating layout objects, it is sometimes convenient to group objects together so you can move and resize them simultaneously. To make a set of objects a group: 1. 2. Select all of the objects that you want to group together. Select Arrange>Group.

How To...

8 59

All the selected objects are now in a group. If you select the Select tool and click on one of the objects in the group, all of the objects in the group will be selected. Once the objects in the group have all been selected, you can manipulate (e.g., move, resize, or rotate) them simultaneously. To select only one of the objects in a group, you select the Single Select tool and click on the object. Grouping objects is only a convenience for operating on objects in the editor. It has no effect on the output. To do such things as keep objects together on the same page or protect them from being overwritten in the output, you draw frames around them and/or use their property sheet settings. Caution: When you group objects, the objects are all moved to the same layer. In the case of repeating frames, this can lead to a frequency error. For example, suppose a repeating frame contains a boilerplate object and a field. The boilerplate object is a layer above the field. If you group the repeating frame and the boilerplate object, the repeating frame is moved to the same layer as the boilerplate object. When you run the report, you receive a frequency error because the repeating frame is a layer above its enclosed field. (Repeating frames must be on a layer below the objects that they contain.) To fix this, you need to ungroup the objects and move the repeating frame to a layer below the field.

Move Layout Objects

You can move all of the objects in the Layout editor. If you move or resize an object so that the objects edge will extend past the boundary of the editor, Oracle Reports will not allow you to perform the action. Note: A common problem in moving objects is positioning them exactly where you want them. If you are having trouble positioning objects when you move them, you may want to select View>View Options>Rulers... to alter your ruler and/or grid settings. You can:

align layout objects 8 61 move single objects 8 61 move multiple objects simultaneously 8 61 move objects by pixel 8 61 move frames and the objects they enclose 8 62 move anchors 8 62 move matrices 8 62 move objects in relation to other objects 8 62

8 60

Building Reports Manual

rotate boilerplate objects 8 62 create page breaks 8 63

Align Layout Objects

After you have created or generated layout objects, you may want to move them so that their top, side, or bottom edges align with those of other objects. To align layout objects: 1. 2. 3. 4. Select the objects you want to align. Select Arrange>Align Objects.... In the dialog box, specify the desired alignment. Accept the dialog box to apply the settings to the selected objects.

Note: If you want to apply the current alignment to other objects, select the objects, then select Arrange>Repeat Alignment. Move Single Objects To move a single object: 1. 2. Select the object you want to move. Drag the object to its new location.

Note: If the object has an explicit anchor (one you created), the anchor remains attached to the object and is resized. Move Multiple Objects Simultaneously To move multiple objects: 1. 2. Select all of the objects you want to move. Click on one of the selected objects and drag it to the new location. All of the selected objects will move together and will retain their relative positions to each other. Note that, if any of the objects has an explicit anchor (one you created), the anchor remains attached to the object and, if necessary, is resized.

Move Objects By Pixel

To move objects one pixel at a time: 1. 2. 3. Deselect Grid Snap (select View>Grid Snap and ensure that it is not checked). Select all objects you want to move. Press the arrow key on your keyboard corresponding to the direction in which you want the selected objects to move. Notes:

If Grid Snap is checked, each time you press an arrow key all selected objects will move one unit in that direction, based upon the currently specified unit of measurement.

How To...

8 61

Anchors cannot be moved in this fashion.

Move Frames and the Objects They Enclose

You can move a frame or repeating frame and the objects contained within that frame or repeating frame simultaneously. To move a frame or repeating frame and the objects each encloses: 1. 2. Select the frame or repeating frame. Drag the frame to its new location. All of the enclosed objects move together and will retain their relative positions to each other.

Move Anchors

To move an anchor: 1. 2. Select the anchor. Select the Reshape tool, then click and drag one of the anchor endpoints to its new location on the object edge.

Note: Pressing the constrain key when moving an anchor endpoint moves the endpoint along the object edge in 25% increments. For more information, see Constrained Mode in Chapter 7 of the Reports Reference Manual. Move Matrices To move a matrix: 1. 2. Move Objects in Relation to Other Objects Select the matrix. Click and drag to move the matrix to its new location. Note that the two repeating frames that form the matrix are also moved.

To layer objectsthat is, move objects in front of or behind other objects: 1. 2. Select all of the objects you want to move. Select one of the following items from the Arrange menu: Moves the selected object in front of the object directly on top of it. Moves the selected object behind the object directly underneath it. Moves the selected object in front of all other objects. Moves the selected object behind all other objects.

Move Forward Move Backward Bring to Front Send to Back Rotate Boilerplate Objects

To rotate boilerplate objects: 1. 2. Select objects or groups that you want to rotate. Select the Rotate tool.

8 62

Building Reports Manual

3.

Click on a handle and drag to rotate the object or group.

Note: You can only rotate boilerplate text and graphics. You cannot rotate other layout objects (repeating frames, frames, or fields). Create Page Breaks You can create page breaks before or after any layout object (except anchors). To create a page break: 1. 2. Doubleclick on the object at which you want to insert a page break to display its property sheet. For General Layout:Pagination, select the setting you require. Note: To set a page break after each repeating frame, display the property sheet for the repeating frame and specify an Object:Maximum Records per Page setting of 1. For more information and additional considerations for creating page breaks, see General Layout Tab in Chapter 8 of the Reports Reference Manual.

Copy and Paste Layout You can copy, cut, and paste layout objects. Objects Copy or Cut Layout Objects When you copy a layout object, Oracle
Reports stores a replica of the selected object in a paste buffer so that you can paste it somewhere else, as many times as you want. 1. 2. Select the object you want to copy. Select Edit>Copy (or the Copy tool) or Edit>Cut (or the Cut tool).

Note: To copy an anchor, you must also select the objects it anchors together. If you select the anchor and not the objects it anchors together, nothing is copied to the Clipboard. If you select one of the objects and the anchor, only the object is copied to the Clipboard. Similarly, for a matrix, you must select the matrix and its two repeating frames. Paste Layout Objects When you paste an object, the contents of the Clipboard are placed in the same position as the cut or copied object. 1. 2. Cut or copy the object. Select Edit>Paste (or the Paste tool).

Notes: You can paste objects across editorsfor example, paste boilerplate text from the Layout editor into the Parameter Form editor. If a pasted object overwrites another object, the object that is overwritten will be placed underneath the pasted object.

How To...

8 63

You can magnify the Layout editor display or reduce the size of the objects to see the entire layout on one screen.

Magnify or Reduce the You can magnify the Layout editor display or reduce the size of the Layout Editor Display objects to see the entire layout on one screen.

To magnify the Layout editor display, select View>Zoom In (or click on the Magnify tool, then click in the painting region). To reduce the Layout editor display, select View>Zoom Out (or click on the Magnify tool, then shiftclick in the painting region).

Modify Layout Objects To change your report layout, you can:


edit boilerplate text 8 64 change boilerplate text attributes 8 65 change field text attributes 8 66 change boilerplate graphics attributes 8 67 change display settings 8 67 override implicit anchors 8 68 add borders 8 68 remove borders 8 69 adjust margins 8 69 change colors 8 69 change patterns 8 70 change fonts 8 71 change record spacing 8 71 change the default format mask 8 71

Edit Boilerplate Text

You can insert, replace, cut, copy, and paste text. Insert and Replace Text To insert and replace text in a boilerplate object: 1. 2. 3. Select the Text tool. Click on the text object. Modify the text as desired, then click outside of the text object.

8 64

Building Reports Manual

Note: While editing boilerplate text, the vertical size of the text grows as necessary. The horizontal size of the object remains fixed, and the text you type wordwraps within that size. Cut and Copy Text To cut or copy boilerplate text: 1. 2. 3. Select the Text tool. Click on the boilerplate text object. Click and drag to mark the text you want to cut or copy. (If you need to resize the marked area after you mark it, press Shift and then click and drag.) By doubleclicking on a character, you mark the word that contains it. Then select Edit>Cut or Edit>Copy.

Paste Text To paste boilerplate text: 1. 2. Change Boilerplate Text Attributes Cut or copy the boilerplate text. Select Edit>Paste.

To change the attributes of boilerplate text: 1. 2. 3. Select the Text tool. Click on the boilerplate text object. Click and drag to mark the text you want to change. (If you need to resize the marked area after you mark it, press Shift and then click and drag.) By doubleclicking on a character, you mark the word that contains it. Select the Format menu to change the Font, Size, Weight, Style, Spacing, and Alignment of your text.

4.

PL/SQL You can also set spacing and alignment for boilerplate using PL/SQL. Using PL/SQL gives you the additional advantage of being able to add the attributes conditionally. To add spacing or alignment attributes using PL/SQL: 1. 2. Go to the property sheet of the object to which you want to add the attribute. In Format Trigger, use SRW.SET_ATTR to set the attribute for the object. For example, you could enter something like the following:
begin srw.attr.mask := srw.hjust_attr; srw.attr.hjust := srw.center_hjust; srw.set_attr (0, srw.attr);

How To...

8 65

return (true); end;

This would center each line of boilerplate text within the object. For more information, see SRW.SET_ATTR in Chapter 13 of the Reports Reference Manual. 3. 4. Accept the property sheet. Click and drag to mark the text you want to cut or copy. (If you need to resize the marked area after you mark it, press Shift and then click and drag.) By doubleclicking on a character, you mark the word that contains it. Then select Edit>Cut or Edit>Copy.

Change Field Text Attributes

To change the attributes of text within a field: 1. 2. Select the field. Select the Format menu and change the desired attributes for the text. You can change the Font, Size, Weight, Style, Spacing, and Alignment of the text in the field.

PL/SQL You can also set text attributes for fields using PL/SQL. Using PL/SQL gives you the additional advantage of being able to add the attributes conditionally. To add text attributes using PL/SQL: 1. 2. Go to the property sheet of the object to which you want to add the attribute. In Format Trigger, use SRW.SET_ATTR to set the attribute for the object. For example, you could enter something like the following:
if :sal > 1000 then srw.attr.mask := srw.face_attr + srw.sz_attr; srw.attr.face := times; srw.attr.sz := 18; srw.set_attr (0, srw.attr); end if; return (true);

This would change a fields font to times and point size to 18, if SAL is greater than 1000. For more information, see SRW.SET_ATTR in Chapter 13 of the Reports Reference Manual. 3. Accept the property sheet.

8 66

Building Reports Manual

Change Boilerplate Graphics Attributes

To change the attributes of a boilerplate graphic: 1. 2. Select the Select tool, then click on the boilerplate graphic object. Select the Format menu and change the desired attributes for the graphic. You can change Line, Dash, and Arrow attributes for the graphic.

PL/SQL You can also set graphic attributes using PL/SQL. Using PL/SQL gives you the additional advantage of being able to add the attributes conditionally. To add graphic attributes using PL/SQL: 1. 2. Go to the property sheet of the object to which you want to add the attributes. In Format Trigger, use SRW.SET_ATTR to set the attributes for the object. For example, you could enter something like the following:
if :sal > 1000 then srw.attr.mask := srw.borderwidth_attr + srw.fbcolor_attr + srw.bbcolor_attr + srw.bordpatt_attr + srw.fillpatt_attr; srw.attr.borderwidth := 1; srw.attr.fbcolor := black; srw.attr.bbcolor := black; srw.attr.bordpatt := solid; srw.attr.fillpatt := gray20; srw.set_attr (0, srw.attr); end if; return (true);

This would put a border and a gray tint block on a field, if SAL is greater than 1000. For more information, see SRW.SET_ATTR in Chapter 13 of the Reports Reference Manual. 3. Change Display Settings Accept the property sheet.

You can specify how you want objects to be displayed as well as what report region you want to display. To change your current display settings: 1. 2. Select View>View Options>Layout.... In the dialog box, change the display settings as desired, then accept the dialog box.

How To...

8 67

Override Implicit Anchors

To override implicit anchors created by Oracle Reports according to the implicit anchoring algorithm:

Create an explicit anchor between two objects that have an implicit anchor defined; explicit anchors override implicit anchors. Or, move an implicit anchor.

For more information, see Implicit Anchoring Algorithm in Chapter 2 of the Reports Reference Manual. Add Borders After you have created or generated layout objects, you may want to add borders to some of them. To add borders to layout objects: 1. 2. 3. Select the object to which you want to add borders and select the Line Color tool. On the color palette, select the solid black square. Customize the border:

To choose a line width, select Format>Line. To choose a pattern, select Format>Dash. Even though it appears in the output, the dash pattern is sometimes obscured in the editor by the objects outline. You can select View>View Options>Layout and turn off object outlines on the Options tab. To frame the border, select Format>Bevel.

Note: If you specify Character Mode:Use Character Units in Designer and Character Mode:Convert Borders in the Report Properties property sheet, a line indicating the charactermode border width will appear around any object in the Layout editor that has a line width greater than zero. Add Matrix Borders By adding borders to a matrix object or its dimension repeating frames, you can make your matrix report appear as a grid. PL/SQL You can also add a border using PL/SQL. Using PL/SQL gives you the additional advantage of being able to add the border conditionally. To add a border using PL/SQL: 1. Go to the property sheet of the object to which you want to add a border.

8 68

Building Reports Manual

2.

In Format Trigger, use SRW.SET_ATTR to set the border for the object. For example, you could enter something like the following:
if :sal > 1000 then srw.attr.mask := srw.borderwidth_attr + srw.fbcolor_attr + srw.bbcolor_attr + srw.bordpatt_attr; srw.attr.borderwidth := 1; srw.attr.fbcolor := black; srw.attr.bbcolor := black; srw.attr.bordpatt := solid; srw.set_attr (0, srw.attr); end if; return (true);

This adds a border around a field, if SAL is greater than 1000. For more information, see SRW.SET_ATTR in Chapter 13 of the Reports Reference Manual. 3. Remove Borders Accept the property sheet.

To remove borders to layout objects: 1. 2. Select the object from which you want to remove borders and select the Line Color tool. Select No Line to hide the border.

Adjust Margins

To change the size of your margins: 1. 2. 3. Select View>View Options>Layout..., then select a Display Layout Using setting of Margin (or select the Margin tool). Accept the dialog box or select the Apply button, which places the cursor in the margin. To adjust the margin, select the margin border, the click on a handle and drag the margin to the desired position.

Change Colors

To change the colors of a layout object: 1. 2. 3. Select the object. Select the Fill Color, Line Color, or Text Color tool, depending on which part of the object you want to apply your color selection. On the color palette, select a color.

How To...

8 69

Note: Color selections are applied to the entire object (e.g., you can apply a color to all the text in the object but not to a segment of the text). PL/SQL You can also add colors using PL/SQL. Using PL/SQL gives you the additional advantage of being able to add colors conditionally. To add color using PL/SQL: 1. 2. Go to the property sheet of the object to which you want to add the colors. In Format Trigger, use SRW.SET_ATTR to set the colors for the object. For example, you could enter something like the following:
if :sal > 1000 then srw.attr.mask := srw.fbcolor_attr + srw.bbcolor_attr + srw.ffcolor_attr + srw.bfcolor_attr; srw.attr.fbcolor := black; srw.attr.bbcolor := black; srw.attr.ffcolor := cyan; srw.attr.bfcolor := cyan; srw.set_attr (0, srw.attr); end if; return (true);

This would set a fields foreground border color and background border color to black, and its foreground fill color and background fill color to cyan, if SAL is greater than 1000. For more information, see SRW.SET_ATTR in Chapter 13 of the Reports Reference Manual. 3. Change Patterns Accept the property sheet.

You can change the background pattern of an objects fill or line. To change a pattern for a layout object: 1. 2. 3. Select the object. Select the Fill Color or Line Color tool, depending on which part of the object you want to apply a pattern. On the color palette, select Patterns....

8 70

Building Reports Manual

4.

On the pattern palette, select a pattern. To change the foreground and background colors, select the dropdown color palettes at the bottom of the pattern palette. Doubleclick on the System Menu icon to close the pattern palette.

5. Change Fonts

To change the text font of a layout object: 1. 2. 3. Select the object. Select Format>Font and choose the font you require. To change the size, weight, or style of a font, select Format>Size, Format>Weight, or Format>Style.

Change Record Spacing

To change the spacing between records in a report: 1. 2. 3. Select the repeating frame that encloses the layout definition for the records you want to space. Doubleclick on the repeating frame object to display its property sheet. Change the settings for Object:Spacing as required. For more information, see Repeating Frame Properties in Chapter 8 of the Reports Reference Manual.

Change the Default Format Mask

You can change the default format mask for displaying Date and Number values for the current Oracle Reports session or define format masks for use in future sessions. To temporarily change the default format mask for the current Oracle Reports session: 1. 2. 3. Doubleclick on a field object to display its property sheet. In the Object:From field, select the source for which you want to change the format mask. In the Object:Format Mask field, select or enter a mask that defines how you want the time or date to appear (e.g., MM/DD/YY fmHH:MI AM).

To define a format mask for use in future sessions: 1. 2. 3. Select Tools>Tools Options.... Under Preferences:Format Masks, select Edit. In the dialog box, select a Display of Number or Date, and enter a format mask in the Mask: field.

How To...

8 71

4.

Select Add to add the new format mask to the list that is saved between sessions.

For more information about format masks, see Format Mask in Chapter 8 of the Reports Reference Manual.

Undo Editor Actions

To undo your most recent editor action, select Edit>Undo. You can undo at most one editor action. Thus, immediately after you select Undo, the menu item name changes to Redo. If you select Redo, your most recent editor action will be redone. Note: Undo has no effect on work that you have performed in the object property sheets, and it has no effect on boilerplate text that you have typed. You can, however, indirectly affect boilerplate text by undoing a function that modified it, such as Cut or Paste.

Import Layout Objects

You can import text and graphics into the layout of your report. Import Boilerplate Text To import text into a boilerplate object: 1. 2. 3. Select Edit>Import>Text.... In the dialog box, specify the name of the file and accept the dialog box. The file will be imported into a boilerplate object. The boilerplate object is placed in the upper left corner of the Layout editor. The object is selected so you can move it to the desired position in the Layout editor.

Import Text into Fields To import text into a field in a property sheet: 1. Display the appropriate property sheet. For example, to import the text of a query into the Query property sheet, open the Query property sheet. Move to the field into which you want to import the text. To replace text that already appears in the field, click and drag to select the text to be replaced; otherwise, the imported file is inserted into the field at the current cursor location. Select Edit>Import>Text.... In the dialog box, specify the name of the file and accept the dialog box. The file is imported into the field.

2.

3. 4.

8 72

Building Reports Manual

Import Graphics To import drawings, color palettes, or images: 1. 2. Select Edit>Import and select the type of object you want to import. In the dialog box, enter necessary information. For more information about the supported file types, see Oracle Reports File Storage in Chapter 18 of the Reports Reference Manual. 3. 4. Accept the dialog box. In the Import from File dialog box, specify the name of the file and accept the dialog box.

Export Layout Objects

You can export text and graphics to files from property sheets or from the Layout editor. Export Text from Property Sheets To export text from a property sheet: 1. 2. Open the property sheet containing the text to be exported. To export all of the text in a field, click in the field. To export a selected portion of the text in a field, click and drag across the text to highlight it. Select Edit>Export>Text.... Note: Use the Edit menu in the window in which the text is located (the local menu). 4. In the Export to File dialog box, specify the name of the file and accept the dialog box.

3.

Export Boilerplate Text To export text from a boilerplate objects: 1. To export all of the text in a boilerplate object, click on the boilerplate object. To export a selected portion of the text, select the Text tool, click on the boilerplate object, then click and drag across the text to highlight it. Select Edit>Export>Text.... In the dialog box, specify the name of the file and accept the dialog box.

2. 3.

How To...

8 73

Export Graphics To export drawings, color palettes, or images from the Layout editor: 1. 2. Select Edit>Export and select the type of object you want to import. In the dialog box, enter necessary information. For more information about the supported file types, see Oracle Reports File Storage in Chapter 18 of the Reports Reference Manual. 3. 4. Accept the dialog box. In the Export to File dialog box, specify the name of the file and accept the dialog box.

8 74

Building Reports Manual

Working with Parameter Form Objects


Parameter form objects define the appearance of the Runtime Parameter Form, which displays at runtime to provide a dialog for specifying parameter values. The two kinds of parameter form objects (fields and boilerplate) behave exactly the same as their counterparts in the Layout editor. You work with the parameter form fields and boilerplate in the same way you work with your layout fields and boilerplate. You can:

create a default parameter form 8 75 customize the Runtime Parameter Form 8 75 create parameter form objects 8 50 display parameter form object properties 8 58 rename parameter form objects 8 58 delete parameter form objects 8 59 select and deselect parameter form objects 8 10 move parameter form objects 8 60 resize parameter form objects 8 12 copy and paste parameter form objects 8 63

Create a Default Parameter Form

To create a default parameter form for your report: 1. 2. In the Object Navigator, select Tools>Default Parameter Form.... Accept the dialog box to display the Parameter Form editor with the default parameter form.

Customize the Runtime Parameter Form

If you do not customize the Runtime Parameter Form, it will default to include only the Destination Type and Destination Name system parameters and any userdefined parameters at runtime. To customize the form: 1. 2. In the Object Navigator, select Tools>Default Parameter Form.... In the dialog box, select the parameters you want to include in the Parameter Form, and modify the parameter labels as desired. Note: If you need to add more pages to the Parameter Form, display the report property sheet for the report (doubleclick on the report icon), and change the value for Parameter Form:Number of Pages.

How To...

8 75

3. 4.

Accept the dialog box to display the Parameter Form editor. To further customize the Parameter Form, use your mouse to modify the size and placement of fields, and the tool palette to include additional elements. For more information, see Parameter Form Editor in Chapter 9 of the Reports Reference Manual.

8 76

Building Reports Manual

Working with the Previewer


The Previewer window displays report output when you run a report and send the output to Preview or Screen. Use the Previewer to see exactly how your report will appear on paper before you print it. You can:

navigate in the Previewer 8 77 print from the Previewer 8 77 change the title 8 77 split the viewing region 8 78 magnify or reduce the image 8 78 open multiple Previewers 8 78

Navigate in the Previewer

To navigate in the Previewer:

Select Prev, Next, First, or Last to display the pages of the report. To display a specific page, enter the page number in the Page field and select Page. Use the scroll bars to move the Previewer display.

Print from the Previewer

To print the report displayed in the Previewer: 1. 2. Select Print. In the dialog box, enter the number of pages and copies you want to print. Accept the dialog box. If you ran the report with a Destination Type of Screen, a warning appears that you should run the report with a Destination Type of Preview before printing. Preview creates PostScript output, which is typically more desirable for printing. 3. Accept the dialog box to send the output in the Previewer to the printer (specified by File>Choose Printer).

Change the Title

To change the Previewer title: 1. In the Object Navigator:


Doubleclick on the report icon to display the report property sheet. Or, select the report, then select Tools>Properties....

2.

In the Parameter Form:Previewer Title field, enter a new title. Accept the property sheet.

How To...

8 77

Split the Viewing Region

You can create two views of the report output by splitting the Previewer screen, either horizontally or vertically. This is useful when you are browsing a long report and want to view two different sections of the output at the same time. To split the viewing region: 1. 2. Drag the box above the vertical scroll bar (to split horizontally), or to the left of the horizontal scroll bar (to split vertically). Release the mouse button at the position you want to split the viewing region.

Magnify or Reduce the You can magnify a hardtosee portion of your report or reduce the image of the report output to get a sense of your reports overall layout. Image
1. To magnify the output displayed in the viewing region, select the large magnify icon to the left of the horizontal scroll bar. Select the small Magnify icon the reduce the size of the output. Repeat this step to increase the magnification or reduction.

2.

Open Multiple Previewers

To open a new Previewer window with the same contents as the current one, select New in the Previewer window.

8 78

Building Reports Manual

Working with PL/SQL


PL/SQL constructs can be used in many different places in Oracle Reports. You can use PL/SQL to perform aggregate computations, restrict output, implement conditional control, and dynamically format data. If you create a PL/SQL construct and later decide it would be useful to have it in other places as well, you can copy the construct. On the client side, you can edit, run, and compile PL/SQL V1 program units; on the server side, you can also edit and compile PL/SQL V2 program units. You can:

create reportlevel PL/SQL 8 79 open and edit existing PL/SQL 8 80 rename reportlevel PL/SQL 8 80 drag and drop PL/SQL program units 8 80 copy and paste PL/SQL 8 80 delete reportlevel PL/SQL 8 81 compile PL/SQL 8 81 import and export PL/SQL 8 81

Create Reportlevel PL/SQL

Reportlevel PL/SQL (also called local PL/SQL) consists of functions or procedures that you can reference from groups, columns, frames, repeating frames, fields, boilerplate, parameters and report triggers. To create a new reportlevel PL/SQL program unit: 1. 2. In the Object Navigator, select the Program Units node, then select Navigator>Create (or the Create tool). In the Program Unit editor, click in the Source Text field and type or modify the text of the subprogram. For more information, see Call Interface in Chapter 15 of the Reports Reference Manual.

How To...

8 79

Open and Edit Existing To open an existing PL/SQL program unit: PL/SQL 1. In the Object Navigator:

Doubleclick on the P icon in the subprogram under the Program Units node. Or, if you know what object references the PL/SQL, doubleclick on the PL/SQL icon in the node that represents the object.

2.

In the Program Unit editor, modify the text of the subprogram as desired. For more information, see Call Interface in Chapter 15 of the Reports Reference Manual.

Rename Reportlevel PL/SQL

To rename a reportlevel PL/SQL subprogram: 1. 2. 3. 4. In the Object Navigator, select the PL/SQL subprogram you want to rename. Singleclick on the name portion of the node and modify the name. Click once outside the node to take the name out of edit mode and update it throughout the rest of the report. Doubleclick on the PL/SQL icon in the node. In the Program Unit editor, change the subprogram name in the PL/SQL code itself, then accept the Program Unit editor.

When you change the name of a PL/SQL subprogram, make sure that you change any references to it in the report. Otherwise, you will get errors for unresolved references when you try to run the report.

Drag and Drop PL/SQL To move PL/SQL program units between files on the client and the database server: Program Units
1. 2. Select a program unit node. Drag the program unit from one report to another or between client (Program Units node) and server (a Stored Program Units node under Database Objects).

Copy and Paste PL/SQL

To copy and paste a PL/SQL construct from one place to another: 1. 2. In the Program Unit editor, lick and drag to select the part of the PL/SQL construct that you want to copy. Select Edit>Copy (or the Copy tool).

8 80

Building Reports Manual

3.

Go to the place where you want to paste the PL/SQL construct (e.g., a new or existing package, function, or procedure in an external PL/SQL library). Select Edit>Paste (or the Paste tool).

4.

Note: If you are planning to use the PL/SQL construct in multiple places within the same report, you should copy it into reportlevel PL/SQL. You can reference reportlevel PL/SQL from anywhere in the report. If you are planning to use the PL/SQL construct in multiple places in different reports, you should copy it into an external PL/SQL library (select File>New>External PL/SQL Library or File>Open). You can reference external library contents from any report that has the library attached to it. If you are pasting the PL/SQL into an external PL/SQL library, remember libraries can only contain packages, functions, and procedures. If you paste the PL/SQL into a package body in the external PL/SQL library, remember to add the construct specification to the package spec as well (if you want to be able to reference it from outside the package). If you are pasting the PL/SQL construct into reportlevel PL/SQL, remember that reportlevel PL/SQL must be a function or a procedure.

Delete Reportlevel PL/SQL

To delete a reportlevel PL/SQL subprogram: In the Object Navigator, select the subprogram, then select Navigator>Delete (or the Delete tool). When you delete a PL/SQL subprogram, make sure that you have also deleted all references to it in your report. Otherwise, you will get errors for unresolved references when you try to run the report.

Compile PL/SQL

To compile the PL/SQL in a report or external PL/SQL library: 1. 2. Open the report or library you want to compile. Select File>Compile (or the Compile tool).

Oracle Reports compiles the PL/SQL in the report or library and displays any compilation errors. Note: In the Object Navigator, uncompiled PL/SQL program units are shown with an asterisk appended to the program unit name.

How To...

8 81

Import and Export PL/SQL

You can copy a PL/SQL construct using Import and Export. You export the construct to a file and then import it into the Program Unit editor where you want it. For more information, see Import Boilerplate Text on page 8 72 and Export Boilerplate Text on page 8 73.

8 82

Building Reports Manual

Working with Report Triggers


Report triggers are PL/SQL subprograms that fire at specific times during report execution. One important use of triggers is to govern conditional printingi.e., to change the appearance of one or more objects based upon criteria you determine. For example, you can use a format trigger to cause a value to display in bold if it is less than zero. Oracle Reports is shipped with a PL/SQL package that contains procedures with which you can quickly change the format attributes of an object. These include procedures to:

change the interior pattern and color of an object change the font size, style, weight, spacing, and justification of a field or boilerplate text change the format mask of a field change the charactermode attributes of an object, including highlighting access a fields value

You can:

create report triggers 8 83 delete report triggers 8 83

Create Report Triggers

To create a report trigger: 1. In the Object Navigator, doubleclick on the Report Triggers node to expand it and display a list of report trigger nodes. Doubleclick on the PL/SQL icon in the trigger you want to create. In the Program Unit editor, type your PL/SQL code in the Source Text field.

2.

Note: A report trigger must be either a function or an anonymous block. For more information, see Call Interface in Chapter 15 of the Reports Reference Manual.

Delete Report Triggers

To delete the PL/SQL block for a particular trigger: 1. In the Object Navigator, doubleclick on the Report Triggers node to expand it and display a list of report trigger nodes. Doubleclick on the PL/SQL icon in the trigger you want to delete. In the Program Unit editor, click and drag in the Source Text field to mark the subprogram and select Edit>Clear.

2.

How To...

8 83

Debugging Reports
Oracle Reports includes the following debugging facilities:

Object Navigator settings a Program Unit editor for editing and compiling PL/SQL a PL/SQL Interpreter for interactive debugging report tracing for detailed report execution information

You can:

set the Object Navigator display 8 84 use the Program Unit editor 8 84 use the PL/SQL Interpreter 8 85 trace report execution 8 86

Set the Object Navigator Display

To make debugging easier, select Navigator>Navigator Options... and set the following options for displaying objects in the Object Navigator:

Groups:Show Columns In Groups to show the data models hierarchy Layout:View by Structure to show the layouts hierarchy

Use the Program Unit Editor

The Program Unit editor provides:


PL/SQL editing PL/SQL compiling message browsing

Access the Program Unit Editor To access the Program Unit editor:

Select General Layout:Edit... on an object property sheet. Or, doubleclick on a PL/SQL icon in the Object Navigator. Or, select Tools>Program Unit Editor.

Paste into the Program Unit Editor To paste the name or arguments of a program unit specification or builtin package into the Program Unit editor: 1. 2. In the Object Navigator, select the program unit specification or builtin package Press the right mouse button to paste the name or arguments into the Program Unit editor.

8 84

Building Reports Manual

Create a Program Unit To create a new PL/SQL program unit: 1. 2. 3. In the Program Unit editor, select New.... In the dialog box, specify a name for the program unit. Accept the dialog box. Type the procedure, function, or package in the Program Unit editor.

To navigate to other PL/SQL program units: 1. 2. Select a Type of All or Local. For the Name field, select a program unit.

Use the PL/SQL Interpreter

You can easily control and monitor the execution of your report using the information shown in the PL/SQL Interpreter window:

a source pane that displays PL/SQL program units an interpreter pane for entering PL/SQL constructs or Development Environment commands

When displayed at runtime, the PL/SQL Interpreter also shows:

an Object Navigator pane that shows the debug actions and the call stack (functions, procedures and local variables). You can use this pane to change the values of variables dynamically as you debug your report.

Using the PL/SQL Interpreter, you can:

set breakpoints to interrupt program execution (select a breakpoint and press the right mouse button to enable or disable the breakpoint) create triggers for activation only if certain conditions exist display and browse the call stack step through code one line at a time examine and change the values of variables modify code at runtime

To display the PL/SQL Interpreter:


Select a PL/SQL program unit, then select Tools>Interpreter to display a modeless Interpreter. Or, encounter an error or breakpoint at runtime to display a modal Interpreter.

How To...

8 85

For more information, refer to your Oracle Procedure Builder documentation.

Trace Report Execution Report tracing is provides a detailed profile of the processing of a
report. Specifically, you can trace the following:

performance profile breakpoints encountered report objects processed PL/SQL executed SQL executed

You can specify the trace file, and whether to replace or append to an existing trace file. You can set tracing options in any of the following ways:

In the Designer, select Tools>Trace... and fill out the dialog box as desired. On the command line, specify tracing options with the R25DES or R25RUN command using TRACEFILE, TRACEMODE, and TRACEOPTS. Using a packaged PL/SQL procedure, specify tracing options via the SRW package using SRW.TRACE_START, SRW.TRACE_END, SRW.TRACE_ADD_OPTION, SRW.TRACE_REM_OPTION.

8 86

Building Reports Manual

Glossary
A
alert An interface element that notifies you of a condition that occurred because of your last action. You must respond to an alert. alias A secondary name used in a SQL statement to reference a table, view, or column. alignment (Field Properties) The method used to position data within a field; i.e., to the left, right, center, flush/left, flush/right, or flush/center of the defined width of a field. ancestor group A group that owns another group, either directly or indirectly. anchor A layout object used to fix a spot on one object to a spot on another object, ensuring the position of the first object in relation to the second object. anchored object The object, known as the child object, which is anchored or attached to another object, known as the parent object. anchoring object The object, known as the parent object, to which another object, known as the child object, is anchored or attached. argument 1. An expression within the parentheses of a function, supplying a value for the function to operate on. For example, in the expression f(x), x is the argument. 2. Clauses containing Oracle Reports executable keywords and their specified values. For example, DESTYPE=FILE is an argument. Arrange menu The menu with which you organize the graphical objects in the editor and specify attributes for the editor components. ASCII Acronym for American National Standard Code for Information Interchange. attribute See setting.

B
bind reference A reference to a bind parameter. See bind parameter. bind parameter A parameter used to replace a single literal value (e.g., a character string, number, or date) appearing anywhere in a SELECT statement.

Glossary 1

body A report region that contains the bulk of the report layout (text, graphics, data, and computations). The report body appears between the report header and trailer pages. boilerplate Text and/or graphics that appear in a report every time it is run. In some products this is called constant text or graphics. border A userdefined outline around a layout object, usually used to highlight its contents. Oracle Reports draws borders such that half the width of the border lies outside the edge of the object, and half inside the edge, as shown below. See also edge.

button 1. An interface element used to select an action item, display a dialog box, or acknowledge the current condition. 2. A usercreated layout object that only appears in the Previewer, and, when pressed, executes a userspecified action.

C
call interface An interface that enables you to invoke Oracle Reports executables from other Oracle products, such as Oracle Forms, or a userwritten 3GL program. canvas See editor. CGM An acronym for character graphics metafile. check box An interface element that can be toggled on or off. See also toggle. child query See detail query. Clipboard A memory buffer. An object remains in the Clipboard until you cut or copy another object, or until you quit Oracle Reports. CMDFILE An argument that allows you to specify a file that contains a set of arguments for R25DES or R25RUN. column 1. A data model object created automatically for each column expression in a querys SELECT list, or created manually to perform summaries, formulas, or act as a placeholder. 2. A vertical list of data contained in a database table. A column has a column name and a specific data type. column expression An expression in a SELECT statement that defines which database column(s) are retrieved. It may be a column name or a valid SQL expression referencing a column name.

break column A column assigned to a break group. break group A group used to categorize, or break, the records contained in a report into sets. It does this by establishing a hierarchy for the fetched data. All data in columns belonging to a break group are above the data in columns belonging to other groups. This causes each record fetched for a break group, to only display once, while multiple related records in other groups can be displayed. break order (Column Properties) A setting that indicates the order in which to display a break columns data. Valid options are Ascending and Descending. break report A report containing a break group.

Glossary 2

Building Reports Manual

column heading See label. command line An operatingsystem command line. Oracle Reports can be invoked from a command line using a number of parameters. Not found on all platforms. comment A multiline field in which you can enter explanatory information about an Oracle Reports object. commit To make changes to data (INSERTs, UPDATEs, DELETEs) in the database permanent. Before changes are stored, both the old and new data exist so that changes can be stored or the data can be restored to its prior state. compile To translate a PL/SQL construct into binary, executable format. In Oracle Reports, PL/SQL constructs must be compiled before they are executed. computation (Column Properties) A setting used to perform runtime calculations on data fetched from the database. These calculations are a superset of the kinds of calculations that can be done directly with a SELECT statement. See also formula column, summary column. computed column See computation. condition (Query/Link Properties) An operator that defines the parent querys relationship to the child query in a parentchild relationship. Confine mode Layout editor mode that prevents child objects from being moved or resized on or outside their parent objects. connect To log on to a database. You must connect if you want to create or modify queries or run a report. construct A PL/SQL code structure. There are two types of constructs: nonvalue constructs do not return a value; value constructs return a value.

coordinates (x,y) The location points for objects appearing in an editor. x and y coordinates determine the horizontal (X) and vertical (Y) placement of layout objects. copy To store a replica of a selected object in the Clipboard, so that it may be pasted elsewhere in an editor if desired. cross product Group that owns two or more other groups and performs a mathematical cross product (i.e., correlates values between them). crosstab See matrix cell. cursor 1. A small icon representing the mouse pointer. The shape of the cursor will vary, depending on the tool you have selected in the designer. 2. A work area in which ORACLE stores the current SQL statement, and if the statement is a query, the results column headings and one row of the result. cut To delete one or more Oracle Reports objects and store them in the Clipboard, so that they may be pasted elsewhere in an editor if desired.

D
Datatype (Column and Field Properties) A setting that specifies the type of data contained in a column, parameter, or field. May be Character, Number, Date, Long, Long Raw, or Raw. data model A relational model that defines what data should be fetched from the database, what values should be computed, and how data should be ordered in a report. Oracle Reports objects that define the data model are queries, groups, columns, parameters, and links.

Glossary 3

database A set of dictionary tables and user tables that are treated as a unit. Also called a server. database cursor See cursor. DATE An ORACLE datatype. A date column may contain a date and time between January 1, 4712 BC and December 31, 4712 AD. default A value that Oracle Reports assigns to a setting if you do not specify one. Also, an Oracle Reports object (such as a group, field, frame, etc.) that Oracle Reports creates so that you do not need to create it yourself. DESFORMAT An argument that specifies the characteristics of the reports output device named in DESNAME. designer The interface, invoked by R25DES, through which you define a module. DESNAME An argument that specifies the name of the output device to which the report will be sent. DESTYPE An argument specifying the kind of output device to which the report will be sent (e.g., printer, file, mail). detail query When defining a master/detail report, the detail query retrieves all related records for each record retrieved by the master, or parent, query. dialog box A partial screen or window that prompts you to enter some piece(s) of information necessary to complete an operation. Dialog boxes are accessed extensively via the various menus. disabled An interface element state that means a menu item, button, etc., cannot be used in the current context; i.e., it does not respond to keyboard or cursor/mouse input. display format See format mask.

E
EBCDIC Acronym for Extended BinaryCoded Decimal Interchange Code. edge The boundary of a layout object. Edit menu A menu that lists a set of operations to perform on objects in an editor (e.g., cut, copy, paste, etc.). editing region The area of a editor in which you can create, modify, position, or delete objects while viewing their graphical representations. editor A work area in which you define the data model (Data Model editor), the layout (Layout editor), and the Runtime Parameter Form (Parameter Form editor) for your report. enabled An interface element state that means that a menu item, button, etc., can be used in the current context, that is, it responds to keyboard or cursor/mouse input. enclosing object An object that contains another object. An object is considered to be enclosed by another object only if all of the following are true: both objects belong to the same region (Body, Margin, Header, or Trailer); the outermost of the two objects is a frame or repeating frame; the outermost of the two objects is behind the other object; the innermost of the two objects lies entirely within the borders of the other object. execute See run. export To store a copy of the selected text or image in an editor to a file. expression A PL/SQL value construct combining variables, constants, literals, and operations on their values.

Glossary 4

Building Reports Manual

external PL/SQL library A PL/SQL package, function, or procedure that can be referenced by the same or multiple reports and by other Oracle products, any number of times. These are executed on the module side, not the database or server side. external query ANSIstandard SQL SELECT statement that can be referenced within the same or multiple reports, and by other Oracle products, any number of times. These are executed by the database or server.

F
field 1. An interface element in which you enter, edit, or delete data that either defines an object or makes a processing choice. Fields appear in property sheets, dialog boxes, and lists of values. 2. A layout object that defines the appearance of a columns data. field label See label. file column A column whose value is a filename. Each file column will display either the filename or the actual contents of the file (e.g., ASCII and CGM files) based upon the Link setting in the columns property sheet. If you specify that you want to link to the file, its contents will appear. If you do not want to link to the file, only its filename will appear. File menu A menu that lists a set of operations to perform on the selected module. fill area The area within an object to which a fill (color or pattern) should be applied. Each object has two fill areas: inside the objects border, and inside the objects edge. filter See group filter.

Flex mode Layout editor mode that automatically resizes or shrinks parent objects when child objects are moved or resized, and adjusts the positions of other layout objects that might otherwise be affected by the repositioning or resizing of the objects. foreign key A value or column in one table that refers to a primary key in another table. form layout A default layout style in which labels appear to the left of fields, and each record prints on a separate logical page. form letter layout A default layout style that intermixes boilerplate and fields, wrapping lines at word breaks. format mask (Field Properties) A setting that defines the appearance of the value of a field. For example, a format mask is used to specify the display of currency amounts and dates. Format menu The menu used to specify attributes affecting the appearance of objects in the editor. format trigger A PL/SQL function executed before the object to which it is associated is printed, allowing you to dynamically change the formatting attributes of that object. formula column A usercreated column that gets its data from a PL/SQL function or expression, a user exit, a SQL statement, or any combination of these. frame A layout object used to enclose other layout objects and control the formatting, frequency, and positioning of several objects simultaneously. FROM A required clause of the SQL SELECT statement that identifies the tables or views from which data is selected.

Glossary 5

function 1. (Column Properties) A setting with which you specify which operation (e.g., First, Last, Sum, % of Total, etc.) you want to use to compute the value of a summary column. 2. A PL/SQL value construct that requires a name and the full PL/SQL syntax, including declarations and the BEGIN and END keywords.

H
header An optional report region that can contain introductory material for the report, including text, graphics, data, and computations. The report header appears first, before the body and trailer. heading node A node in the Object Navigator denoting a type of object which can be contained within or associated with a report. Selecting a heading node does not select an object in the report. See also node, Object Navigator. Help menu A menu that lists various ways to access Oracle Reports online help system. hidden (Field Properties) A property that specifies whether Oracle Reports will suppress the indicated field at its location in the layout. If Hidden is specified, the fields value will appear only where referenced in text objects (using &fieldname). horizontal sizing (Layout objects) A setting that determines how the horizontal size of the layout object will change at runtime to accommodate the objects or data within it. Valid options are Contract, Expand, Fixed, and Variable. horizontal spacing (Repeating Frame Properties) The amount of space that should appear horizontally between instances of a repeating frame.

G
generate (File menu) To translate the report definition into a binary, executable file. grant To give a user access to a module. Only a modules creator can grant its access to other users. group A data model object that is created automatically to contain all the columns selected by a query, or created by the user to modify the hierarchy of the data appearing in a report; it is used primarily for creating breaks in a report, as well as for resetting computations. See also break group. GROUP BY An optional clause of a SELECT statement which identifies the level of summarizing to be performed before fetching data from the database. group filter A PL/SQL function that restricts the data fetched by a group. group name (Group Properties) The name of a group. Groups are named so they can be referenced by other objects. groups query The query that selects data for the group. GUI An acronym for graphical user interface.

I
icon A graphic representation of a window or tool. import To add to your report definition text or graphics stored in the database, server, or in files. You can import into the editors both text and graphics, but you may import only text into single and multiline fields.

Glossary 6

Building Reports Manual

index An optional structure associated with a table that is used by ORACLE or another server or database to locate rows of the table quickly, and (optionally) to guarantee that every row is unique. Insert mode A mode in which each character you type is inserted into your text at the cursor, without overtyping adjacent characters. The opposite of Replace mode.

J
join Combining data from two (or more) tables in a single SELECT statement. justification See alignment.

link A data model object used to define a master/detail (parentchild) relationship between a group and a query. list of values A list of valid options for a field in the designer or a parameter in the Runtime Parameter form. logical page One page of your actual report (it may be displayed on one or more physical pages). login account A username and password to access ORACLE or another server or database. This account is usually separate from an operating system account.

M
mailing label layout A default layout that displays records in one or more columns on the page. Fields appear directly beneath each other in a single repeating frame. margin An optional report region that appears at the top and bottom of each logical page in the body region. The margin may include any layout object, but typically contains boilerplate and fields (for page numbers, page totals, grand totals, and current date and time). master/detail layout A default layout in which the detail records appear below the master records. Master records appear in form layout style, while detail records appear in tabular layout style. matrix cell A repeat direction that displays each record of a repeating frame as a cell of a matrix. See also matrix report.

L
label A heading created for each field appearing in a report layout. Labels are boilerplate objects. layout A formatting model that uses layout objects to define the positioning and appearance of the data in your report. Layout objects are frames, repeating frames, fields, boilerplate, anchors, and buttons. lexical reference A reference to a lexical parameter. See also lexical parameter. lexical parameter A parameter used to replace a clause in a SELECT statement (e.g., GROUP BY, ORDER BY, etc.), enabling you to specify a value for the clause at runtime. link file The name of a file to which a boilerplate object is associated. At runtime, Oracle Reports imports the files contents into your report layout.

Glossary 7

matrix layout A default layout, resembling a grid, that formats the four sets of data necessary for a matrix report; one set of data displays as a row of labels, one as a column of labels, one set creates the grid, and one set fills the cells of the grid. See also matrix report. matrix report A crosstabulation of four sets of data: one set of data displays across the page; one set of data displays down the page; one set of data is the crossproduct, determining all possible locations in which the across and down data relate and placing a cell in those locations; and one set of data displays as the filler of the cells. menu A list of available choices from which you can choose what action to take next or what interface element to access next. module An object that can be shared by more than one report, as well as by other Oracle products. Reports, external queries, and external PL/SQL libraries constitute Oracle Reports modules. multiline field A field in the designer that extends for several lines, allowing you to scroll vertically through the information.

node A line in the Object Navigator. A node denotes either one object in a report or one type of object which can be contained within or associated with a report. Nodes can optionally contain such information about an object as whether it has associated PL/SQL, is anchored to another object, etc. See also heading node, Object Navigator. noncaching column A report column that references a database column of datatype NOCACHE. nonvalue construct A PL/SQL code structure that does not return a value. Nonvalue constructs include procedures and packages. NULL value The absence of a value. A null value should mean only that nothing is known about the value.

O
object An item that defines one portion of a module (e.g., a column object defines all information about the column: its datatype, width, name, etc.). Most objects have property sheets, with which you can modify their definitions. Object Navigator The Oracle Reports window containing a list of objects in all currently opened reports. The list appears in outline form, and enables the user to accomplish several tasks related to managing reports; e.g., editing property sheets, renaming objects, and deleting objects. See also node, heading node.

N
nested matrix Matrix report in which either the across and/or down dimension contains one or more master/detail relationships. There is no limit to the amount of nesting allowed. NOCACHE A datatype indicating that the data will be fetched when the page on which it appears is formatted (instead of fetched and cached until formatted).

Glossary 8

Building Reports Manual

OLE2 Object Linking and Embedding V2. For more information, see your Microsoft documentation. ORDER BY An optional clause used in a SQL SELECT statement to specify the order in which the results of a query are to be fetched. Oracle Reports Server A batch report executable found only on Microsoft Windows. The executable is loaded once when a report is launched by another Developer/2000 tool and remains in memory. It enables you to manage the execution of reports; e.g., cancel a report, reposition a report in the queue, etc. output The results of a report at runtime. Output can be displayed on a screen, stored in a file, printed on paper, or sent to other users via Oracle*Office. overflow When an objects contents cannot fit on the current logical page. In the event of overflow, some of the contents are moved to the next logical page.

P
packaged function 1. A PL/SQL function, shipped with Oracle Reports, that can be referenced anywhere in a report or external PL/SQL library. 2. See function. palette An interface element that displays all tools, colors, and patterns available in an editor. page break (Layout objects) A setting that controls whether to move the current object and its children to the next logical page. You can set page breaks to occur before or after the current object appears in the report output.

pagedependent reference A value in the report that relies on the formatting of the report. For example, the Total Number of Logical Pages and a summary with Reset At of Page are page dependent references. page height (Report Properties) The height of the physical page. page width (Report Properties) The width of the physical page. panel The number of physical pages needed to print one logical page. parameter A variable that you can change at runtime. parent group (Query Properties) A group that owns a query or another group. parent/child relationship Way in which to define a primary key to foreign key relationship between two different tables. See also link. paste To place the contents of the Clipboard (cut or copied Oracle Reports objects) at the current cursor location. paste buffer See Clipboard. pattern A graphical property of certain layout objects, such as frames, repeating frames, fields, and boilerplate. physical page The size of a page that is output by your printer. PL/SQL A procedural extension of SQL that provides programming constructs such as blocks, conditionals, and procedures. .pll file A file with an extension of .pll that contains an external PL/SQL library in binary format. preference A setting that affects the behavior of the design or runtime interface.

Glossary 9

Previewer The interface with which you view and scroll through report output online. primary key A column in a database table whose members consist of unique values that can be used to identify a row in a table. print condition (Layout objects) A setting that defines how frequently an Oracle Reports object is printed relative to other Oracle Reports objects. print direction (Repeating Frame Properties) The direction in which each instance of a repeating frame prints relative to the prior instance. The valid options are Across, Across/Down, Down, and Down/Across. printer control code In a printer definition file, an escape sequence to which you assign a printer code that can be referenced in a report. procedure A PL/SQL nonvalue construct that requires a name and the full PL/SQL syntax, including declarations and the BEGIN and END keywords. product order (Column Properties) The order in which groups are evaluated in the cross product when computing summaries. property See setting. property sheet A rectangular area that appears in a window, displaying all of the information for one object (e.g., a query). protocol A string you can enter when connecting to a database or server that allows you to connect to a remote database or server. .prt file A file with an extension of .prt that contains a printer definition in text (e.g., ASCII or EBCDIC) format.

Q
query A SQL SELECT statement that specifies the data you wish to fetch for the report. query name (Query and Group Properties) A setting that identifies a query. quit (File menu) An option that terminates an Oracle Reports session and returns the user to the operating system. On some systems, Quit is Exit.

R
R25CONV An executable command that converts a report definition from one storage format (i.e., database, .rdf file, .rep file, .rex file) to another. R25DES An executable command that invokes Oracle Reports designer, with which you can define and run reports. R20MPRT An executable command that converts Version 1.1 printer definitions to Version 2.0 printer definition files in text format (e.g., ASCII or EBCDIC). R25MREP An executable command that converts Version 1.1 reports to Version 2.5 reports, stored either in database tables or files. R25RUN An executable command that runs a previously defined report(s). radio button A twochoice list (similar to a check box), appearing in sets of two or more, only one of which may be either on or off at any given time. .rdf file A file with an extension of .rdf that contains a single report definition in binary format. .rdf files are used to both run and edit reports. read consistency The ability to query the data at a single point in time. This ensures that all the data in a report is internally consistent.

Glossary 10

Building Reports Manual

record One row fetched by a SQL SELECT statement. region The area in a report that owns the objects being defined. Valid regions are Header, Body/Margin, and Trailer. rename (File menu) A menu option used to change the name of a module. .rep file A file with an extension of .rep that contains a single report definition in binary format. .rep files are used solely to run reports; you cannot edit a .rep file. repeating frame A layout object used to display rows of data that are fetched for a group. Replace mode A mode in which each alphanumeric character you type replaces the current character at the cursor. The opposite of Insert mode. report A module that defines all of the information about itself, including its history, page size, references to other modules, and use of reportlevel objects. reportlevel objects The objects that are used to define a reports data model and layout. Reportlevel objects are assigned to a single report, and cannot be shared by other reports or other Oracle products. Oracle Reports objects include reports, queries, external queries, external PL/SQL libraries, groups, columns, parameters, links, frames, repeating frames, fields, boilerplate, and anchors. reset (Column Properties) A setting that specifies the group at which the value of a column summary is to be reset to 0. revert (File menu) An option enabling you to reset the current module definition to the most recently saved state.

.rex file A file with an extension of .rex that contains a report definition stored in text (e.g., ASCII or EBCDIC) format. .rex files are used to port reports from one platform to another. row 1. One set of fields in a table; for example, the fields representing one employee in the example table EMP. 2. One set of fields in the output of a query. run (File menu) To produce the report output. runfile See .rep file. running summary A column summary which returns cumulative values of the function between reset points. Runtime Parameter Form A screen or window appearing optionally at runtime in which a user can modify print options and parameters prior to report execution. runtime The time during which Oracle Reports is running a report.

S
script A file containing SQL statements that you can run in SQL*Plus to quickly perform database administration. Several SQL scripts are shipped with Oracle Reports. scroll region See multiline field. SELECT statement A SQL statement that specifies which rows and columns to fetch from one or more tables or views. session In R25DES, the period between invoking Oracle Reports and quitting Oracle Reports. In R25RUN, the period between running a report and quitting it.

Glossary 11

setting An attribute of an object that determines the effect or presentation of that object. Examples of properties include Vertical Sizing, Page Width and Datatype. sibling An object that is at the same level as another object in a hierarchy, either directly or indirectly. source (Column and Field Properties) For columns, the name of the column whose values will be summarized. For fields, the column or parameter whose data will be displayed in the field. SQL A standard interface for storing and retrieving information in a relational database or server. SQL is an acronym for Structured Query Language. .sql file A file with an extension of .sql that contains a query stored in text (e.g., ASCII or EBCDIC) format. Any report you create can reference any query you create or to which you have been granted access. SQL statement A SQL instruction to ORACLE. A SELECT statement is one type of SQL statement. subprogram A named PL/SQL construct. Packages, functions, and procedures constitute subprograms. subtotal See summary column. summary column A column, with a type of summary, which computes subtotals, grand totals, running totals, and other summaries of the data in a report, using one of the packaged summary functions provided by Oracle Reports. system variable One of the variables that are provided with Oracle Reports (e.g., &Logical Page, DESTYPE).

table A named collection of related information, stored in a relational database or server, in a twodimensional grid that is made up of rows and columns. tabular A default layout displaying labels at the top of the page and rows of data underneath the labels. TERM An argument that enables you to specify a file that describes the terminal from which you are using R25DES or R25RUN. text See boilerplate. text item See field. TIFF Acronym for Tagged Image Format File. title bar The horizontal area at the top of a window that displays the name of the application or interface element that appears in that window. title page See header. toggle A setting that can be turned either on or off. For example, you can toggle between insert and replace mode when typing data. tool An icon that appears in an Oracle Reports editor. Tools are used to perform actions on objects in a report. toolbar Portion of an Oracle Reports editor containing tools that serve as shortcuts for common menu selections (e.g., File>Save, Edit>Cut, etc.). Tool palette Portion of an Oracle Reports editor containing tools that provide a means of creating, deleting, or modifying report objects via interaction with the graphical user interface (e.g., drawing tools, text tool, query tool, etc.) They do not have menu equivalents.

T
tabbed property sheet See property sheet.

Glossary 12

Building Reports Manual

Tools menu A menu that provides access to several tools for use in building reports; e.g., the Default Layout and Parameter forms, several editors, the PL/SQL Interpreter, debugging tools, etc. trailer A optional report region that can contain closing material for the report, including text, graphics, data, and computations. The report trailer appears last, following the header and body. transaction A sequence of SQL statements that ORACLE treats as a single unit. trigger A PL/SQL construct that is executed, or fired, at a specific time during the formatting of a report.

V
value construct A PL/SQL code structure that returns a value. Value constructs include functions and expressions. vertical sizing (Layout objects) A setting that determines how the vertical size of the layout object will change at runtime to accommodate the objects or data within it. Valid options are Contract, Expand, Fixed, and Variable. vertical spacing (Repeating Frame Properties) The amount of space that should appear vertically between instances of a repeating frame. view A virtual table whose rows do not actually exist in the database. A virtual table is based on a table that is physically stored in the database. View menu A menu that lists choices for customizing the features provided by the the Oracle Reports editors; e.g., whether to display the rulers, the grid, the toolbar, etc.

U
USERID An argument which allows you to specify your ORACLE username and password with an optional SQL*Net address. user exit A way in which to pass control (and possibly arguments) from Oracle Reports to another Oracle product or 3GL, and then return control (and possibly arguments) back to Oracle Reports.

W
width (Column and Parameter Properties, layout objects) The width of a column, parameter, or layout object. Windows menu A menu that lists all of the Oracle Reports windows that are open or iconized.

Glossary 13

Glossary 14

Building Reports Manual

Index
Symbols
&, field reference, 8 52 % of Total function, how to use, 5 44 All (print condition), 3 36 All but first (print condition), 3 36 All but last (print condition), 3 36 Ancestor view, 8 15 Anchors creating, 8 54 deleting, 8 59 moving, 8 62 resizing, 8 12 Anchor tool, how to use, 6 17 Anchors collapsing, 3 33 description of, 1 7, 3 31 explicit, 3 31 how to create, 6 17 implicit, 3 31 properties of, 3 31 relative positioning of, 3 32 types, 3 31 Anchors report brief description of, 4 22 concepts of, 6 14 distinguishing features, 6 14 explanation of, 6 14 organization of, 6 15 steps to build, 6 166 20 Arc, drawing, 8 52 Archiving, modules, 8 7 Arrows, changing boilerplate graphic, 8 67 ASCII, printing, 8 22 ASCII driver, printing charactermode reports, 8 22

A
Accessing demo reports introductory reports, 4 2 reports with new features, 7 2 Across report with control breaks brief description of, 4 13 concepts of, 5 61 distinguishing features, 5 61 explanation of, 5 61 organization of, 5 61 steps to build, 5 625 64 Additional default layout, creating, 8 49 Advanced mailing label report brief description of, 4 31 concepts of, 6 57 distinguishing features, 6 57 explanation of, 6 57 organization of, 6 57 steps to build, 6 586 62 Aggregating data within ranges report brief description of, 4 20 concepts of, 6 6 distinguishing features, 6 6 explanation of, 6 6 organization of, 6 7 steps to build, 6 76 9 Alias, font, 8 3

Index 1

ASCII file report concepts of, 6 104 distinguishing features, 6 104 explanation of, 6 104, 6 1056 108 organization of, 6 105 Attach library dialog box, how to use, 6 43 Attached PL/SQL libraries description of, 3 57 how to create, 6 42 Attributes, changing boilerplate text, 8 65 fields, 8 66 graphics, 8 67

B
BACKGROUND, description of, 3 19 Barcode adding using bar code font, 6 59 adding using Oracle Graphics tool, 6 59 Basic concepts, Oracle Reports, 1 3 Bevel, 8 68 Bind references, uses of, 3 20 Bitmapped report in bitmapped environment, 8 21 in charactermode environment, 8 22 printing, 8 21 running, 8 21 Body/margin pages, 3 6 Boilerplate changing graphic attributes, 8 67 changing text attributes, 8 65 copying text, 8 65 cutting text, 8 65 deleting, 8 59 description of, 1 7, 3 29 description of (in parameter form), 3 41 entering text, 8 51 external, 2 40 how to access external, 8 53 how to add to margin area, 5 69 how to modify in Layout editor, 2 31 inserting text, 8 64

link file, 8 53 pasting text, 8 65 properties of, 3 29 properties of (in parameter form), 3 41 referencing fields in text, 8 52 renaming, 8 58 replacing text, 8 64 resizing, 8 12 tools for creating, 3 30 Boilerplate (Parameter Form editor), description of, 1 8 Boilerplate text definition of, 5 18 how to create, 5 20 Borders adding to layout objects, 8 68 customizing, 8 68 how to add to layout objects, 2 36 how to suppress, 5 69 removing, 8 69 Break compared to link, 3 22 description of, 3 14 vs master/detail, 5 35 Break column, definition of, 5 25 Break groups creating, 8 35 definition of, 5 25 description of, 3 14 how to create, 5 27 multiple columns in, 5 29 multiple groups in a report, 5 32 Break report brief description of, 4 8 concepts of, 5 25 distinguishing features, 5 25 explanation of, 5 25 organization of, 5 26 steps to build, 5 265 29 Buttons creating, 8 55 description of, 3 34 properties of, 3 34 using in the Previewer, 2 51

Index 2

Building Reports Manual

C
Cancelling, running of report, 8 24 Cautions converting reports, must recompile, 8 20 resizing, 8 12 Changing display attributes, 2 34 Character mode, output, 8 22 Charactermode environment, creating reports for, 8 18 Charactermode report creating, 6 105 in bitmapped environment, 8 22 in charactermode environment, 8 23 printing, 8 22 running, 8 22 Check printing report brief description of, 4 24 concepts of, 6 23 distinguishing features, 6 23 explanation of, 6 23 organization of, 6 24 steps to build, 6 246 27 Check printing reportspelling out amounts. See Spelling out cash amounts report Clipboard, 8 63 Collapsible anchors, 3 33 Color, use of in format triggers, 6 74 Color palettes exporting, 8 74 importing, 8 73 Colors assigning to layout objects, 5 79 foreground, 5 79 changing for layout objects, 8 69 editing, 8 3 how to set, 5 78 Column hierarchy, 3 18 Column labels how to modify in Default Layout dialog, 5 23 how to modify in Layout editor, 2 31 Column mode, description of, 3 36 Columns break, 5 25 creating, 8 39

default, 3 16 deleting, 8 45 description of, 1 5, 3 16 formula, 3 18, 8 39 graphics, 3 16 how to create file columns, 6 87 how to create formulas, 2 23 how to create summaries, 2 25 how to omit from output, 5 38 large objects, 8 38 moving, 8 45 placeholder, 3 18, 8 39 renaming, 8 43 selecting, 8 10 summary, 3 17, 8 39 usercreated, 3 16 valid formats for graphics, 3 16 with filenames, 8 38 with images or drawings, 8 37 with OLE2 objects, 8 37 with sound and video, 8 37 Commands R25CONV, description of, 3 64 R25DES, description of, 3 64 R25MREP, description of, 3 64 R25RUN, description of, 3 64 Common properties definition, 5 17 how to set, 2 32 how to use, 5 17 Common property sheet displaying, 8 16, 8 58 for fields in repeating frame, 8 11 Compiling libraries, 8 81 reports, 8 81 Concepts, 3 1 attached PL/SQL libraries, 3 57 break, 3 14 column hierarchy, 3 18 data definition, 3 21 external PL/SQL, 3 56 external PL/SQL libraries, 3 56 external PL/SQL packages, 3 57 formatting trigger, 3 58 group filters, 3 58 group hierarchy, 3 16 layout, 3 35

Index 3

layout definition, 3 40 matrix, 3 42 modules, 3 3 PL/SQL, 3 56 PL/SQL formula, 3 58 PL/SQL libraries, 3 56 placeholder, 3 58 report trigger, 3 59 reportlevel PL/SQL, 3 58 the Oracle Reports package, 3 57 using PL/SQL with your reports, 3 56 validation trigger, 3 58 Conditional form letter report brief description of, 4 33 concepts of, 6 67 distinguishing features, 6 66 explanation of, 6 66 organization of, 6 67 steps to build, 6 676 71 Conditional highlighting report brief description of, 4 34 concepts of, 6 71 distinguishing features, 6 71 explanation of, 6 71 organization of, 6 72 steps to build, 6 726 77 Conditional highlighting with color, how to use, 6 74 Conditional printing, definition of, 3 39 Confine mode, 8 47 definition of, 2 38, 5 24 how to use, 2 38, 5 24 Connect dialog box, how to use, 2 7 Connecting to the database, 8 4 within Oracle Reports, 2 7 Control break group. See Break group Converting, reports, 8 24 Converting , PL/SQL libraries, 8 31 Converting reports, from the command line (R25CONV), 3 64 COPIES, description of, 3 19 Copy boilerplate text, 8 65 layout objects, 8 63 PL/SQL, 8 80

Copying external PL/SQL libraries, 8 5 external queries, 8 5 reports, 8 5 Copying fields, 6 12 Creating a break group, 5 27 a default layout, 2 10 a new report, 2 16 a parameter form, 3 42 anchors, 8 54 boilerplate text, 5 20 break groups, 8 35 buttons, 8 55 columns, 8 39 crossproduct groups, 8 35 default layout, 8 48 default parameter form, 8 75 drawing objects, 8 52 external PL/SQL libraries, 8 30 external queries, 8 29 fields, 8 50 frames, 8 53 groups, 8 35 images, 8 52 data links, 8 34 matrix, 8 56 modules, 3 4 OLE2 columns, 8 37 OLE2 object, 8 54 parameters, 8 40 PL/SQL, 8 79 PL/SQL libraries, 3 56 PL/SQL packages, 3 57 queries, 8 33 repeating frames, 8 53 report triggers, 8 83 reports, 8 17 sound and video columns, 8 37 Creating parameters, 6 45 Creating summaries in a matrix, 5 91 Cross product groups definition of, 3 15 description of, 3 44 Crossproduct groups, creating, 8 35 Cross Product tool, how to use, 5 83

Index 4

Building Reports Manual

CURRENCY, description of, 3 19 Customizing a session changing report properties, 2 46 editing preferences, 2 44 specifying runtime parameters, 2 44 specifying runtime settings, 2 45 Cut, boilerplate text, 8 65

D
Dash, changing boilerplate graphic, 8 67 Data definition concepts, 3 21 Data file report. See ASCII file report Data link tool, 2 56 Data links based on contraints, 8 34 column to column, 8 34 creating, 8 34 deleting, 8 44 description of, 1 5, 3 12 group to group, 8 34 how to create between queries, 2 56 query to query, 8 34 selecting, 8 10 Data model description of, 3 8 how to specify (overview), 1 4 Data Model editor description of, 3 59 displaying, 8 14 Data model objects columns, 3 16 description of, 3 8 groups, 3 13 queries, 3 8 visual representation of, 3 8 Database constraints, for data links, 8 34 Date, including in report, 8 57 Debugging, with the Program Unit editor, 7 26 Debugging via tracing , 7 29 with the Object Navigator, 7 25 with the PL/SQL Interpreter, 7 27

Debugging data relationships, via the Object Navigator, 7 25, 7 27, 7 29 Debugging PL/SQL, via the PL/SQL Interpreter, 7 29 Debugging reports concepts of, 7 23 new features, 7 23 PL/SQL Interpreter, 8 85 Program Unit editor, 8 84 setting the Navigator display, 8 84 Debugging the layout, via the Object Navigator, 7 26 DECIMAL, description of, 3 19 Default (print condition), 3 36 Default buttons, creating, 8 55 Default layout brief description of, 3 40 how to update, 3 41 rules, 3 40 Default Layout dialog box field width setting, 5 13 Label field, 5 23 Repeat setting, 5 13 Default layout, creating, 8 48 Default Parameter Form dialog box, how to use, 7 12 Default parameter form, creating, 8 75 Default parameters. See System parameters Deleting anchors, 8 59 boilerplate, 8 59 columns, 8 45 data model objects, 8 43 external PL/SQL libraries, 8 6, 8 7 external queries, 8 6, 8 7 fields, 8 59 frames, 8 59 layout objects, 8 59 modules, 8 6 parameters, 8 42 PL/SQL, 8 81 repeating frames, 8 59 report triggers, 8 83 reports, 8 6, 8 7

Index 5

Deselecting multiple objects, 8 12 single objects, 8 11 Designing reports, command to get into designer (R25DES), 3 64 DESTINATION FORMAT, description of, 3 19 DESTINATION NAME, description of, 3 19 DESTINATION TYPE, description of, 3 19 DESTYPE (Destination Type), preview, 6 26 Dialog boxes Attach Library, 6 43 Connect, 2 7 Default Parameter Form, 7 12 Display, 2 18 Import, 5 79 Import Image, 2 37 Insert Object, 7 22 layout options, 2 33 New program unit, 6 43 New Program Unit , 6 44 Object Navigator Options, 5 93 object navigator options, 2 61 Open, 2 18 Page Numbering, 6 12 Print Job, 2 53 Save , 2 13 Save Library, 6 43 Save to File, 2 13 Table and Column Names, 2 9 tools options, 2 44 Trace Options, 7 29 dialog boxes, report progress, 5 6 Dimension groups (in a matrix), description of, 3 44 Dimensions of a report, 3 5 description of, 3 5 Display attributes, how to change, 2 34 Displaying, editors, 8 14 Documenting reports, 8 26 Drawings creating objects, 8 52 exporting, 8 74 importing, 8 73 in columns, 8 37 Drilldown report, brief description of, 4 41

Drilldown report with parameter list of values concepts of, 7 5 explanation of, 7 5 new features, 7 5 DUMPREP, R25CONV, 3 64 Duplicating fields, 6 12 Dynamic graphics report brief description of, 4 36 concepts of, 6 81 distinguishing features, 6 81 explanation of, 6 81 organization of, 6 82 steps to build, 6 836 86

E
Editing, boilerplate text, 8 64 Editing program units, 7 26 Editors brief description of, 1 9 Data model editor, 3 59 description of, 3 59 Layout editor, 3 60 Parameter form editor, 3 61 undoing actions, 8 72 Ellipse, drawing, 8 52 Ellipse tool, how to use, 5 77 Empty values, how to substitute values for, 5 89 Ending a session, 2 16 Executable, 3 63 R25CONV, description of, 3 64 R25DES, description of, 3 64 R25MREP, description of, 3 64 R25RUN, description of, 3 64 Executing reports, using the runtime engine (R25RUN), 3 64 Exiting Oracle Reports, 2 16 Explicit anchors, description of, 3 31 Export, layout objects, 8 73 External boilerplate, 2 40 External PL/SQL libraries converting, 8 31

Index 6

Building Reports Manual

creating, 8 30 deleting, 8 6, 8 7 description of, 3 3, 3 56 how to create, 3 56, 6 42 opening, 8 5 referencing, 8 27, 8 28 copying, 8 5 renaming, 8 5 saving, 8 5 External PL/SQL packages description of, 3 57 how to create, 3 57 External queries copying, 8 5 creating, 8 29 deleting, 8 6, 8 7 description of, 3 3 opening, 8 5 referencing, 5 10, 8 27 renaming, 8 5 saving, 8 5 External Query editor displaying, 8 14 how to access, 5 8 how to use, 5 8 External query report brief description of, 4 4 concepts of, 5 7 distinguishing features, 5 7 explanation of, 5 7 organization of, 5 7 steps to build, 5 85 11

F
Field display attributes alignment, 3 28 display, 3 28 format mask, 3 28 list of, 3 28 Field justification, how to use, 5 84, 5 86 Field properties, how to modify, 2 32 Field width, how to modify, 5 44 Fields changing text attributes, 8 66 creating, 8 50

deleting, 8 59 description of, 1 6, 3 28 description of (in parameter form), 3 41 duplicating, 6 12 hidden, 5 73 how to modify, 5 47 properties of, 3 28 properties of (in parameter form), 3 41 referencing in boilerplate text, 8 52 renaming, 8 58 resizing, 8 12 Fields (Parameter Form editor), description of, 18 File columns, 3 16 File dialog box, 2 18 Files, referenced in columns, 8 38 Fill/Line/Text display, description of, 2 27 Filler groups (in a matrix), description of, 3 44 Fills, how to add to layout objects, 2 36 Filters, group description of, 3 15 packaged, 3 15 usercreated, 3 15 finding report objects, 2 48 First (group filter), description of, 3 15 First (print condition), 3 36 Flex mode, 8 48 definition of, 2 49 how to use, 2 49 rules for use, 5 69 Font aliases, 8 3 changing boilerplate text, 8 65 changing field text, 8 66 changing for layout objects, 8 71 Footers, adding to a report, 5 67 Form letter layout, characteristics of, 5 18 Form letter report brief description of, 4 6 concepts of, 5 18 distinguishing features, 5 18 explanation of, 5 18 organization of, 5 19 steps to build, 5 195 22

Index 7

Format masks changing, 8 71 how to specify, 2 32, 5 10 Format triggers definition of, 5 15 description of, 3 39 how to create, 5 17 how to use, 6 55 properties of, 3 39 Formula columns creating, 8 39 description of, 3 18 how to build, 5 58 Formula report brief description of, 4 12 concepts of, 5 56 distinguishing features, 5 56 explanation of, 5 56 organization of, 5 57 steps to build, 5 585 61 Formula tool, 2 23 Frames creating, 8 53 deleting, 8 59 description of, 1 6, 3 24 how to add borders, 2 36 moving with enclosed objects, 8 62 properties of, 3 24 renaming, 8 58 resizing, 8 12 Freehand object, drawing, 8 52

rotating, 8 62 Graphics and text report, brief description of, 4 17 Graphics columns description of, 3 16 valid formats, 3 16 Graphics, text, and color report concepts of, 5 75 distinguishing features, 5 75 explanation of, 5 75 organization of, 5 76 steps to build, 5 765 81 Grids in a matrix, how to add, 5 93 Group hierarchy, 3 16 Grouping objects, 5 79 Groups break, 3 14, 5 25, 8 35 creating, 8 35 cross product, 3 15, 3 44 crossproduct, 8 35 default, 3 14 deleting, 8 44 description of, 1 5, 3 13 moving, 8 45 renaming, 8 43 resizing, 8 12 selecting, 8 10 structure in matrix reports, 3 44 usercreated, 3 14

H G
Generate, reports, 8 26 GENREP, R25CONV, 3 64 Grand total of a matrix, 5 92 Grant, access to module, 8 6 Graphics changing attributes, 8 67 drawing, 8 52 exporting, 8 74 how to add frame borders, 2 36 how to draw lines, 5 78 importing, 8 73 in boilerplate, 8 53 Header and footer report brief description of, 4 15 concepts of, 5 67 distinguishing features, 5 67 explanation of, 5 67 organization of, 5 68 steps to build, 5 685 70 Header page, creating objects on, 8 58 Headers, adding to a report, 5 67 Hidden fields definition of, 5 19 how to use, 5 73, 6 49, 6 52 Hiding components, 8 13

Index 8

Building Reports Manual

Horizontal gap. See Preferences Horizontal interfield. See Preferences

concepts of, 6 35 distinguishing features, 6 35 explanation of, 6 35 organization of, 6 36 steps to build, 6 366 41

I
Image viewer, using in Previewer, 2 51 Images creating, 8 52 exporting, 8 74 importing, 8 73 in columns, 8 37 Implicit anchors, description of, 3 31 Import layout objects, 8 72 text into fields, 8 72 Import dialog box, 5 79 Import Image dialog box, 2 37 Insert Object dialog box, 7 22 Inserting, boilerplate text, 8 64 Integration, with Oracle Graphics, 6 58 Interface elements description of, 1 8 editors, 1 9 Object Navigator, 1 9 property sheets, 1 8 tool palettes, 1 9 toolbars, 1 9 tools, 1 9 Intermixing fields and repeating frames brief description of, 4 23 concepts of, 6 20 distinguishing features, 6 20 explanation of, 6 20 organization of, 6 21 steps to build, 6 216 24 Introductory mailing label report brief description of, 4 5 concepts of, 5 11 distinguishing features, 5 11 explanation of, 5 11 organization of, 5 12 steps to build, 5 125 14 Invoice report brief description of, 4 27

J
Justification changing boilerplate text, 8 65 changing field text, 8 66

K
Keep with anchoring object, 3 37

L
Last (group filter), description of, 3 15 Last (print condition), 3 36 Layout, how to specify (overview), 1 5 Layout concepts, 3 35 Layout definition concepts, 3 40 Layout editor changing settings, 8 67 description of, 3 60 displaying, 8 14 grouping objects in, 5 79 how to move objects in, 5 46 modes, 8 47 viewing layouts in, 2 12 Layout objects adding borders, 8 68 aligning, 8 61 anchors, 3 31 boilerplate, 3 29 buttons, 3 34 changing colors, 8 69 changing fonts, 8 71 changing patterns, 8 70 clearing, 8 59 copying, 8 63 cutting, 8 59 description of, 3 23 deselecting, 8 11

Index 9

exporting, 8 73 fields, 3 28 frames, 3 24 grouping, 8 59 how to add borders, 2 36 how to add fills, 2 36 how to modify in the Layout editor, 2 47 how to move in the Layout painter, 5 46 importing, 8 72 in a matrix report, 3 48 matrix, 3 48 moving, 8 60 pasting, 8 63 properties, 2 32 removing borders, 8 69 repeating frames, 3 26 setting common properties of, 2 32 Layout options dialog box, 2 33 Layout styles, 2 10 Lexical references, uses of, 3 21 Limiting records per page, 6 13 Line changing boilerplate graphic, 8 67 drawing, 8 52 Line tool, how to use, 2 27, 5 78 Lines and borders, Graphics, 2 42 Lines in the layout, how to draw, 5 78 Link file, how to use, 6 83 Link file for boilerplate, creating, 8 53 Link File tool, how to use, 2 39 Linking queries, 2 56 without specifying groups, 6 29 Linking to a file, 2 39 Links See also Data links compared to breaks, 3 22 List of values (LOV), 8 41 Loading demo reports introductory reports, 4 2 reports with new features, 7 2 LOADREP, R25CONV, 3 64 Local PL/SQL. See Reportlevel PL/SQL Logon procedure. See Connect dialog box

M
Magnify Data Model editor, 8 46 Layout editor, 8 64 Previewer, 2 53, 8 78 Magnify tool, how to use, 6 17 Mailing label layout characteristics of, 5 11 how to create, 5 13 Mailing reports to multiple users brief description of, 4 32 concepts of, 6 61 distinguishing features, 6 61 explanation of, 6 61 organization of, 6 62 steps to build, 6 636 65 Mappings, font, 8 3 Margin area adding layout objects, 5 74 description of, 2 33 how to resize, 6 37 Margins adjusting, 8 57 creating objects in, 8 57 how to add boilerplate, 2 34 how to resize, 2 34 resizing, 8 69 Master/detail joins vs. multiple queries, 5 35, 5 38 vs break, 5 35 Master/detail layout, how to build, 2 58 Master/detail relationship, how to create, 2 56 Master/Detail report brief description of, 4 9 concepts of, 5 35 distinguishing features, 5 35 explanation of, 5 35 organization of, 5 36 steps to build, 5 375 40 Master/detail/detail, description of, 3 23 Master/Detail/Summary report brief description of, 4 11 concepts of, 5 51

Index 10 Building Reports Manual

distinguishing features, 5 51 explanation of, 5 51 organization of, 5 52 steps to build, 5 535 56 Master/Master report brief description of, 4 7 concepts of, 5 22 distinguishing features, 5 22 explanation of, 5 22 organization of, 5 22 steps to build, 5 235 26 Matrix break report brief description of, 4 38 concepts of, 6 97 data model, 3 55 description of, 3 54 distinguishing features, 6 97 explanation of, 6 97 layout, 3 55 organization of, 6 98 steps to build, 6 986 100 Matrix concepts, 3 42 cross product groups, 3 44 data model concepts, 3 42 data model for simple matrix, 3 49 dimension groups, 3 44 filler groups, 3 44 group structure, 3 44 layout concepts, 3 47 layout for simple matrix, 3 49 matrix object, 3 48 multiquery matrix, 3 43 multiquery matrix with break, 3 52 nested matrix, 3 50 number of queries, 3 43 onequery matrix, 3 43 product order, 3 45 requirements for matrix reports, 5 81 summary columns, 3 45 Matrix layout characteristics of, 5 81 description of, 3 47 how to build, 5 84 Matrix objects creating, 8 56 description of, 3 48, 5 94 moving, 8 62

renaming, 8 58 resizing, 8 12 Matrix report adding a grid, 5 93 brief description of, 4 18 concepts of, 5 81 creating, 8 35 distinguishing features, 5 81 explanation of, 5 81 Matrix report (onequery) organization of, 5 82 steps to build, 5 835 85 Matrix report (threequery) organization of, 5 85 steps to build, 5 855 87 Matrix report with grid concepts, 5 93 distinguishing features, 5 93 organization of, 5 93 steps to build, 5 935 95 Matrix with summaries report (complex) brief description of, 4 39 concepts of, 6 100 distinguishing features, 6 100 explanation of, 6 100 organization of, 6 101 steps to build, 6 1026 105 Matrix with summaries report (simple) concepts of, 5 90 distinguishing features, 5 90 explanation of, 5 90 organization of, 5 90 steps to build, 5 915 93 Matrix with text replacing empty values concepts of, 5 88 distinguishing features, 5 88 explanation of, 5 88 organization of, 5 88 steps to build, 5 895 90 Maximum records per page, how to use, 6 13 Migrating, reports, 8 25 MODE, description of, 3 19 Modes Confine, 8 47 Flex, 8 48

Index 11

Layout editor, 8 47 Modifying column labels, in the default layout dialog, 5 23 Modules archiving, 8 7 compiling PL/SQL, 8 81 deleting, 8 6 description of, 3 3 external PL/SQL library, 3 3 external query, 3 3 granting access, 8 6 how to create, 3 4 how to grant access to, 3 4 list of types, 3 3 opening, 8 5 renaming, 8 5 report, 3 3 saving, 8 5 storage and security, 3 4 Moving anchors, 8 62 columns, 8 45 frames and their enclosed objects, 8 62 groups, 8 45 matrices, 8 62 multiple objects, 8 61 one pixel at a time, 8 46, 8 61 parameters, 8 45 queries, 8 45 repeating frames and their enclosed objects, 8 62 single objects, 8 61 Moving objects in an editor, 2 18 Multiquery matrix, description of, 3 43 Multiquery matrix with break concepts of, 6 94 distinguishing features, 6 94 explanation of, 6 94 organization of, 6 95 steps to build, 6 956 97 Multiquery matrix with break report data model, 3 53 layout, 3 53 Multimedia objects, accessing from the Previewer, 2 51

Multimedia report brief description of, 4 42 concepts of, 7 14 explanation of, 7 14 new features, 7 14 Multiple break groups concepts of, 5 32 distinguishing features, 5 32 explanation of, 5 32 organization of, 5 32 steps to build, 5 335 35 Multiple columns in a break group concepts of, 5 29 distinguishing features, 5 29 explanation of , 5 29 organization of , 5 29 steps to build, 5 305 32 Multiple query reports, 3 10 with related queries, 3 11 with unrelated queries, 3 11

N
navigating to objects, via Object Navigator, 2 48 Nested matrix report brief description of, 4 37 concepts of, 6 89 data model, 3 50 description of, 3 50 distinguishing features, 6 89 explanation of, 6 89 layout, 3 51 Nested matrix report (multiquery) organization, 6 91 steps to build, 6 926 94 Nested matrix report (onequery) organization of, 6 90 steps to build, 6 906 92 New program unit dialog box, 6 44 how to use, 6 43 Nodes expanding and collapsing, 8 14 going to, 8 15

Index 12 Building Reports Manual

hierarchy, 8 15 marking, 8 15 searching, 8 15 Null values, how to substitute values for, 5 89

O
Object Navigator brief description of, 1 9 customizing display, 8 16 description of, 2 6, 3 2 navigating via, 2 48 Object Navigator Options dialog box, 2 61, 5 93 Object Navigator Settings, how to use, 7 25 ODBC, 8 4 OLE2 objects creating, 8 54 creating columns for, 8 37 selecting from the database, 7 20 OLE2 report brief description of, 4 43 concepts of, 4 43, 7 19 explanation of, 7 19 new features, 4 43, 7 19 Omitting columns from the report, 5 38 Onequery matrix, description of, 3 43 Open external PL/SQL libraries, 8 5 external queries, 8 5 modules, 8 5 reports, 8 5 Oracle Reports Server, 8 23 Oracle Reports basic concepts, 1 3 concepts, 3 1 ORIENTATION, description of, 3 20

P
Packaged PL/SQL procedures, how to use, 6 64 Packaged PL/SQL procedures, using, how to use, 6 73

Packaged PL/SQL procedures, using (feature), how to use, 6 65 Page breaks creating, 8 63 how to specify, 2 59 Page numbering See also Renumbering pages by repeating frame including in report, 8 56 Page Numbering dialog box, how to use, 6 12 Page protect description of, 3 38 how to use, 5 66 Page width, how to set, 5 63 Pagedependent references, definition of, 6 9 Paging through the Previewer, 2 52 Parameter form editor description of, 3 61 displaying, 8 14 Parameter form objects boilerplate, 3 41 description of, 3 41 fields, 3 41 Parameter form, default, how to build, 3 42 Parameter list of values creating, 8 41 steps to create, 7 107 12 using select statement, 7 10 Parameters created in SQL statement, 3 19 creating, 8 40 deleting, 8 42 description of, 1 5 how to create, 6 45, 6 48 list of values, 8 41 moving, 8 45 renaming, 8 43 selecting, 8 10 system, 3 19, 8 40 user, 8 41 usercreated, 3 20 validating, 8 42 Parent/child relationships. See Master/detail relationship Paste boilerplate text, 8 65

Index 13

clipboard, 8 63 layout object, 8 63 PL/SQL name or arguments, 8 84 Patterns, changing for layout objects, 8 70 PL/SQL copying and pasting, 8 80 creating, 8 79 deleting, 8 81 drag and drop, 8 80 renaming, 8 80 support, 8 79 uncompiled, 8 81 PL/SQL concepts external PL/SQL, 3 56 external PL/SQL package, 3 57 formatting trigger, 3 58 formula, 3 58 group filters, 3 58 placeholder, 3 58 report trigger, 3 59 validation trigger, 3 58 PL/SQL Interpreter for debugging, 8 85 how to use, 7 27 PL/SQL library, referencing, 8 28, 8 31 PL/SQL report brief description of, 4 28 concepts of, 6 41 distinguishing features, 6 41 explanation of, 6 41 organization of, 6 42 steps to build, 6 426 46 Placeholder columns creating, 8 39 description of, 3 18 Placing database values in page headings brief description of, 4 16 concepts of, 5 71 distinguishing features, 5 71 explanation of, 5 71 organization of, 5 72 steps to build, 5 725 75 Platform differences, 4 2, 7 3 how they affect reports, 2 4 Polygon, drawing, 8 52 Polyline, drawing, 8 52

Preferences adjusting spacing with, 6 5 designing reports, 8 2 editing, 2 44 horizontal gap, 6 5 horizontal interfield, 6 5 Object Navigator display, 8 3 runtime, 8 3 saving, 2 44, 8 2 setting, 8 2 vertical gap, 6 5 vertical Interfield, 6 5 prefs.ora, Preferences, 2 42 Previewer accessing multimedia from, 2 52 description of, 3 62 how to split, 2 52 magnifying the contents, 8 78 navigating in, 8 77 opening new window, 8 78 printing from, 2 53, 8 77 scrolling and paging, 8 77 scrolling in, 2 52 splitting the viewing region, 8 78 using buttons in, 2 52 using multiple previewers, 2 53 using Page Up and Page Down, 2 52 using Split Vertical and Split Horizontal, 2 52 Primary key, data links. See Linking Print condition all, 3 36 all but first, 3 36 all but last, 3 36 default, 3 36 description of, 3 35 first, 3 36 how to use, 6 24 last, 3 36 Print direction how to use, 5 14 modifying in Default Layout dialog box, 5 62 Print Job dialog box, 2 53 Printer, specifying, 8 21 Printer definition, modifying 6 105

Index 14 Building Reports Manual

Printing bitmapped reports, 8 21 ASCII output, 8 22 charactermode reports, 8 22 landscape, 8 23 previewer, 8 23, 8 77 reports, 8 20 Printing reports on preprinted forms brief description of, 4 26 concepts of, 6 30 distinguishing features, 6 30 explanation of, 6 30 organization of, 6 31 steps to build, 6 316 36 PRINTJOB, description of, 3 20 Procedural information, 8 1 Product order definition of, 3 45 in matrix reports, 3 45 Program unit, drag and drop, 8 80 Program Unit editor description of, 2 23 displaying, 8 14 for debugging, 8 84 how to use, 7 26 pasting name or arguments, 8 84 Properties common, 8 16 displaying, 8 15 report, 8 15 Property sheets brief description of, 1 8 displaying, 8 15, 8 58 property sheets, common properties, 2 32 PVCS checking in a file, 8 7 checking out a file, 8 8 creating an archive, 8 7 creating archive reports, 8 9

how to link, 2 56 moving, 8 45 renaming, 8 43 resizing, 8 12 selecting, 8 10 Query objects multiple queries, 3 10 parentchild relationships, 3 11

R
R25CONV, executable description, 3 64 R25DES, executable description, 3 64 R25MREP, executable description, 3 64 R25RUN, executable description, 3 64 Ranking report brief description of, 4 29 concepts of, 6 47 distinguishing features, 6 47 explanation of, 6 47 Ranking report (rank by count) organization of, 6 48 steps to build, 6 486 51 Ranking report (rank by percentage) organization of, 6 50 steps to build, 6 516 54 Read from file, how to use, 6 87 Read from file , how to use, 6 83 Records, changing spacing between, 8 71 Rectangle, drawing, 8 52 Rectangle tool, how to use, 2 36 Reduce Data Model editor, 8 46 Layout editor, 8 64 Previewer, 2 53 References noncaching, 8 38 PL/SQL library, 8 31 to external PL/SQL libraries, 8 27, 8 28 to external queries, 8 27 Relative positioning of anchors, 3 32 Renaming boilerplate, 8 58 columns, 8 43

Q
Queries creating, 8 33 deleting, 8 44 description of, 1 5, 3 8

Index 15

data model objects, 8 43 external PL/SQL libraries, 8 5 external queries, 8 5 fields, 8 58 frames, 8 58 groups, 8 43 matrix objects, 8 58 modules, 8 5 parameters, 8 43 PL/SQL subprograms, 8 80 queries, 8 43 repeating frames, 8 58 reports, 8 5 Renumbering pages by repeating frame brief description of, 4 21 concepts of, 6 9 distinguishing features, 6 9 explanation of, 6 9 organization of, 6 10 steps to build, 6 116 15 Repeat setting See also print direction in the Default Layout dialog box, 5 13 Repeating frames creating, 8 53 deleting, 8 59 description of, 1 6, 2 21, 3 26 moving with enclosed objects, 8 62 properties of, 3 26 renaming, 8 58 resizing, 8 12 Replacing, boilerplate text, 8 64 Report definitions, 2 16, 5 3 See also Report designer Report designer, previewer, 2 15 Report object definition of, 3 5 dimensions, 3 5 sections, 3 6 Report progress dialog box, 5 6 Report properties, 2 46 how to modify, 2 46, 5 74 modifying, 2 46 Report Properties dialog box, page width setting, 5 63

Report sections body/margin, 3 6 header, 3 6 trailer, 3 7 Report triggers creating, 8 83 deleting, 8 83 Reportlevel objects, description of, 3 4 Reportlevel PL/SQL, description of, 3 58 Reportlevel summaries, 5 44 REPORT25_PATH, environment variable, 5 9 Reports cancelling at runtime, 8 24 charactermode, 8 18 converting, 8 24 converting from the command line (R25CONV), 3 64 converting from V1.1 to V2.5 (R25MREP), 3 64 copying, 8 5 creating, 8 17 deleting, 8 6, 8 7 description of, 3 3 designing (R25DES), 3 64 documenting, 8 26 executing using the runtime engine (R25RUN), 3 64 generating, 8 26 margin area , 2 33 matrix, 3 42, 8 35 migrating, 8 25 on reports, 8 26 opening, 8 5 opening in the designer (R20DES), 2 18 printing, 8 20 renaming, 8 5 running, 8 20 saving, 2 13, 8 5 saving changes, 8 5 using a single query, 3 9 viewing in the Previewer, 2 52 Reports server, 8 23 Reshaping tool, how to use, 6 18 Resizing anchor, 8 12

Index 16 Building Reports Manual

boilerplate, 8 12 fields, 8 12 frames, 8 12 groups, 8 12 margins, 8 69 matrix objects, 8 12 multiple objects, 8 12 queries, 8 12 repeating, 8 13 repeating frames, 8 12 single objects, 8 12 Right mouse button for breakpoints, 8 85 for displaying editors, 8 14 for displaying properties, 8 15 for OLE2 object servers, 8 54 for pasting PL/SQL, 8 84 in Layout editor, 8 48 Rotating graphics, 8 62 text, 8 62 Rounded rectangle, drawing, 8 52 Running reports, 8 20 cancelling, 8 24 Running summaries definition of, 5 48 modifying summary columns into, 5 49 Running summary report concepts of, 5 48 distinguishing features, 5 48 explanation of, 5 48 organization of, 5 49 steps to build, 5 50 Runtime Parameter Form brief description of, 3 41 customizing, 8 75 how to specify (overview), 1 7 Runtime settings, modifying, 2 54, 8 3

S
Saving external PL/SQL libraries, 8 5 external queries, 8 5 modules, 8 5

reports, 8 5 Save dialog box, 2 13 Save library dialog box, how to use, 6 43 Save to File dialog box, 2 13 Saving reports, 2 13 Scrolling through the Previewer, 2 52 Sections, description, 3 6 Select tool, how to use, 2 31 Selecting grouped objects, 8 11 multiple objects, 8 10 objects in a frame or repeating frame, 8 11 overlapped objects, 8 11 sets of objects, 8 10 single objects, 8 10 Selecting graphics at runtime concepts of, 6 85 distinguishing features, 6 85 explanation of, 6 85 organization of, 6 86 steps to build, 6 866 90 Selecting OLE2 objects from the database, 7 20 Server, reports, 8 23 Showing components, 8 13 Single queries, 3 9 Size changing boilerplate text, 8 65 changing field text, 8 66 sound, creating columns for, 8 37 Spacing changing between records, 8 71 changing boilerplate text, 8 65 changing field text, 8 66 Specifying format masks, 5 10 Spelling out cash amounts on checks brief description of, 4 25 concepts of, 6 27 distinguishing features, 6 27 explanation of, 6 27 organization of, 6 27 steps to build, 6 286 30 Split function in Previewer, 8 78

Index 17

SQL clause, 2 57 in data links, 2 57 Static graphics report brief description of, 4 35 concepts of, 6 76 distinguishing features, 6 76 explanation of, 6 76 organization of, 6 77 steps to build, 6 786 81 Stored Program Unit editor, displaying, 8 14 Stored program units, node in Object Navigator, 8 80 Style changing boilerplate text, 8 65 changing field text, 8 66 Substituting zeroes for empty values, 5 89 Sum function, how to use, 5 43 Summaries, 3 17 Summaries in a matrix, how to create, 5 91 Summary column function of (definition), 5 41 how to create, 5 43 report level (description of), 5 44 reset level of (definition), 5 41 running summaries , 5 48 source of (definition), 5 41 Summary column tool, 2 25 Summary columns creating, 8 39 description of, 3 17 how to assign a function, 2 25 how to assign a source, 2 25 how to create a report total, 2 26 how to create group summaries, 2 25 how to create running summaries, 2 25 how to specify Reset At, 2 25 Summary columns in a matrix, 3 45 description of, 3 45 Summary report brief description of, 4 10 concepts of, 5 40 distinguishing features, 5 40 explanation of, 5 40 organization of, 5 42 steps to build, 5 425 48

Suppressing blank lines concepts of, 5 15 distinguishing features, 5 15 explanation of, 5 15 organization of, 5 16 steps to build, 5 165 18 Suppressing labels report brief description of, 4 30 concepts of, 6 53 distinguishing features, 6 53 explanation of, 6 53 organization of, 6 54 steps to build, 6 546 57 System parameters, 3 19 BACKGROUND, 3 19 COPIES, 3 19 CURRENCY, 3 19 DECIMAL, 3 19 DESFORMAT, 3 19 DESNAME, 3 19 DESTYPE, 3 19 MODE, 3 19 ORIENTATION, 3 20 PRINTJOB, 3 20 THOUSANDS, 3 20

T
Table and Column Names, dialog box, 2 9 Tabular layout characteristics of, 5 4 how to build, 5 5 Tabular report brief description of, 4 3 concepts of, 5 3 distinguishing features, 5 3 explanation of, 5 3 organization of, 5 4 steps to build, 5 45 7 Text how to add, 2 27 how to add from a linked file, 2 39 importing, 8 72 rotating, 8 62 typing boilerplate, 8 51

Index 18 Building Reports Manual

Text color tool, how to use, 5 78 Text tool, how to use, 2 31 THOUSANDS, description of, 3 20 Time series calculations report brief description of, 4 19 concepts of, 6 3 distinguishing features, 6 3 explanation of, 6 3 organization of, 6 3 steps to build, 6 46 6 Timestamp, including in report, 8 57 Title page, 3 6 Tool palette, boilerplate tools, 3 30 Tool palettes, brief description of, 1 9 Toolbars brief description of, 1 9 hiding and showing, 8 13 Tools Anchor, 6 17 Confine, 5 77 Cross Product, 5 83 Data Link, 2 56 Ellipse, 5 77 fill, line, text, 2 27 formula column, 2 23 Line, 5 78 Link File, 2 39 Magnify, 6 17 Rectangle, 2 36 Reshaping, 6 18 Select, 2 31 summary column, 2 25 text, 2 31 text color, 5 78 tools, description of, 1 9 Tools Options dialog box preferences, 2 44 runtime parameters, 2 44 runtime settings, 2 45 Trace Options dialog box, 7 29 Trace settings, how to use, 7 29 Tracing and debugging reports brief description of, 4 44 explanation of, 7 23 Trailer page, 3 7 creating objects on, 8 58

Tutorial, 2 1 how to prepare, 1 10 Lesson I, 2 5 Lesson II, 2 17 Lesson III, 2 30 Lesson IV, 2 43 Lesson V, 2 55 overview of lessons, 2 2 Typing boilerplate text, 8 51

U
Undefined objects, 8 43 Unit of measurement, description of, 3 5 Updating report layouts, 3 41 Upgrading reports from V1.1 to V2.5, R25MREP, 3 64 Usercreated buttons creating, 8 55 steps to create, 7 87 10, 7 167 18 with attached PL/SQL, 7 8, 7 16 Using magnify and reduce, 2 53 Using PL/SQL with your reports, 3 56

V
Validating, parameter values at runtime, 8 42 Version control. See PVCS Vertical gap. See Preferences Vertical interfield. See Preferences Vertical sizing, how to use, 5 66 Vertical spacing definition of, 2 60 how to use, 5 13 video, creating columns for, 8 37

W
Weight changing boilerplate text, 8 65 changing field text, 8 66 White space, adding to default layout, 8 50

Index 19

Wrapped break report brief description of, 4 14 concepts of, 5 64 distinguishing features, 5 64 explanation of, 5 64 organization of, 5 65 steps to build, 5 655 67

Index 20 Building Reports Manual

Report Name
Across Break Report Advanced Mailing Label Report Aggregating Data within Ranges Anchors Report ASCII File Report Break Report Check Printing Report Conditional Form Letter Report Conditional Highlighting Report DrillDown Report with Parameter List of Values Dynamic Graphics Report External Query Report Form Letter Report Formula Report Graphics and Text Report Header and Footer Report Intermixing Fields from Different Repeating Frames Invoice Report Introductory Mailing Label Report Mailing Reports to Multiple Users Master/Detail Report Master/Detail/Summary Report Master/Master Report Matrix Report Matrix Report with Summaries Matrix Break Report Multimedia Report Nested Matrix Report OLE2 Report PL/SQL Report Placing Database Values in Page Headings Report Printing Reports on Preprinted Forms Ranking Report Renumbering Pages by Repeating Frame Spelling Out Cash Amounts on Checks Static Graphics Report Summary Report Suppressing Column Headings When No Detail Records Are Retrieved Tabular Report Time Series Calculations Report Tracing and Debugging Report Execution Wrapped Break Report

Sample Output Page


4 13 4 31 4 20 4 22 4 40 48 4 24 4 33 4 34 4 41 4 36 44 46 4 12 4 17 4 15 4 23 4 27 45 4 32 49 4 11 47 4 18 4 39 4 38 4 42 4 37 4 43 4 28 4 16 4 26 4 29 4 21 4 25 4 35 4 10 4 30 43 4 19 4 44 4 14

Report Page
5 61 6 57 66 6 14 6 104 5 25 6 23 6 66 6 71 75 6 81 57 5 18 5 56 5 75 5 67 6 20 6 35 5 11 6 61 5 35 5 51 5 22 5 81 6 100 6 97 7 14 6 89 7 19 6 41 5 71 6 30 6 47 69 6 27 6 76 5 40 6 53 53 63 7 23 5 64

Report Name
Across Break Report Advanced Mailing Label Report Aggregating Data within Ranges Anchors Report ASCII File Report Break Report Check Printing Report Conditional Form Letter Report Conditional Highlighting Report DrillDown Report with Parameter List of Values Dynamic Graphics Report External Query Report Form Letter Report Formula Report Graphics and Text Report Header and Footer Report Intermixing Fields from Different Repeating Frames Invoice Report Introductory Mailing Label Report Mailing Reports to Multiple Users Master/Detail Report Master/Detail/Summary Report Master/Master Report Matrix Report Matrix Report with Summaries Matrix Break Report Multimedia Report Nested Matrix Report OLE2 Report PL/SQL Report Placing Database Values in Page Headings Report Printing Reports on Preprinted Forms Ranking Report Renumbering Pages by Repeating Frame Spelling Out Cash Amounts on Checks Static Graphics Report Summary Report Suppressing Column Headings When No Detail Records Are Retrieved Tabular Report Time Series Calculations Report Tracing and Debugging Report Execution Wrapped Break Report

Sample Output Page


4 13 4 31 4 20 4 22 4 40 48 4 24 4 33 4 34 4 41 4 36 44 46 4 12 4 17 4 15 4 23 4 27 45 4 32 49 4 11 47 4 18 4 39 4 38 4 42 4 37 4 43 4 28 4 16 4 26 4 29 4 21 4 25 4 35 4 10 4 30 43 4 19 4 44 4 14

Report Page
5 61 6 57 66 6 14 6 104 5 25 6 23 6 66 6 71 75 6 81 57 5 18 5 56 5 75 5 67 6 20 6 35 5 11 6 61 5 35 5 51 5 22 5 81 6 100 6 97 7 14 6 89 7 19 6 41 5 71 6 30 6 47 69 6 27 6 76 5 40 6 53 53 63 7 23 5 64

The Tool Palettes

The Tool Palettes

The Default Layout Styles

The Default Layout Styles

Readers Comment Form


Name of Document: Building Reports Manual Part No. A324881 Oracle Corporation welcomes your comments and suggestions on the quality and usefulness of this publication. Your input is an important part of the information used for revision.

Did you find any errors? Is the information clearly presented? Do you need more information? If so, where? Are the examples correct? Do you need more examples? What features did you like most about this manual?
If you find any errors or have any other suggestions for improvement, please indicate the topic, chapter, and page number below:

Please send your comments to: Oracle Reports Documentation Manager Oracle Corporation 400 Oracle Parkway Redwood City, CA 94065 Fax: (415) 5067200 If you would like a reply, please give your name, address, and telephone number below:

Thank you for helping us improve our documentation.

*A32488-1* *A32488-1*
A324881

Building Reports Manual

Release 2.5

You might also like