About the PLSQL Editor About the Stored PLSQL Editor About the Syntax Palette About program units

2-36 Oracle Reports Users Guide to Building Reports

2.6 PLSQL

The topics in this section discuss the use of PLSQL in Oracle Reports Builder. ■ About the PLSQL Editor ■ About the Stored PLSQL Editor ■ About the Syntax Palette ■ About program units ■ About stored program units ■ About external PLSQL libraries ■ About attached libraries ■ About formulas ■ About group filters ■ About REF CURSOR queries ■ About DML and DDL ■ About built-in packages ■ About triggers

2.6.1 About the PLSQL Editor

The PLSQL Editor enables you to create and edit PLSQL program units. Usage notes When you make changes to a program unit, dependent program units lose their compiled status, which is indicated by an asterisk after their name under the Program Units node in the Object Navigator. You can navigate to those program units directly in the PLSQL Editor using the Name list to recompile them. Restrictions ■ If you delete a PLSQL package, function, or procedure, you must also delete all references to it in your report. Otherwise, you will get an error when you compile, generate, or run the report. ■ PLSQL package, function, and procedure names must be unique within the report and may not duplicate the names of any columns, groups, queries, or printable objects. See also Section 4.13.2.3.1, Editing features in the PLSQL Editor

2.6.2 About the Stored PLSQL Editor

The Stored PLSQL Editor enables you to create and edit stored PLSQL program units in a database listed under the Database Objects node in the Object Navigator. See also Section 4.13.3.2, Creating a stored program unit Advanced Concepts 2-37

2.6.3 About the Syntax Palette

The Syntax Palette is a programming tool that enables you to display and copy the constructs of PLSQL language elements and built-in packages into the PLSQL Editor and Stored PLSQL Editor. See also Section 4.13.2.4, Inserting syntax into the PLSQL Editor

2.6.4 About program units

Program units are packages, functions, or procedures that you can reference from any PLSQL within the current report. For a detailed example of using PLSQL in a report, see Chapter 40, Building a Report that Includes PLSQL . Restrictions ■ If you delete a PLSQL package, function, or procedure, you must also delete all references to it in your report. Otherwise, you will get an error when you compile, generate, or run the report. ■ PLSQL package, function, and procedure names must be unique within the report and may not duplicate the names of any columns, groups, queries, or printable objects. Example: Referencing a PLSQL function in formulas Suppose that you have a report with the following groups and columns: Groups Columns Summary ----------------------------------------- RGN REGION RGNSUMSAL SUMDEPTSUMSAL COSTOFLIVING DEPT DNAME DEPTNO DEPTSUMSAL SUMEMP.SAL JOB JOB HEADCOUNT COUNTEMP.EMPNO EMP ENAME EMPNO SAL COMM Given these groups and columns, you might create multiple formulas that apply the cost of living factor COSTOFLIVING to salaries. To avoid duplication of effort, you could create the following PLSQL function and reference it from the formulas: function CompSalsalary number return number is Note: Program units cannot be referenced from other documents. If you want to create a package, function, or procedure that can be referenced from multiple documents, create an external PLSQL library see Section 4.13.5.1, Creating an external PLSQL library . 2-38 Oracle Reports Users Guide to Building Reports begin return salaryCostofLiving; end; Following are some examples of how you might reference the PLSQL function in formulas: CompSal:RGNSUMSAL or CompSal:SAL + COMM See also Section 4.13.3.1, Creating a local program unit

2.6.5 About stored program units