A script-enabled browser is required for this page to function properly.

About program units

Program units are packages, functions, or procedures that you can reference from any PL/SQL within the current report.

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

For a detailed example of using PL/SQL in a report, see the chapter "Building a PL/SQL Report" in the Oracle Reports Building Reports manual, available on the Oracle Technology Network Oracle Reports Documentation page (http://www.oracle.com/technology/documentation/reports.html).

Restrictions

Example: Referencing a PL/SQL function in formulas

Suppose that you have a report with the following groups and columns:


Groups    Columns         Summary 
-----------------------------------------
RGN       REGION
          RGNSUMSAL       SUM(DEPTSUMSAL)
		  COSTOFLIVING
		   
DEPT      DNAME
          DEPTNO
		  DEPTSUMSAL      SUM(EMP.SAL)
		   
JOB       JOB
          HEADCOUNT       COUNT(EMP.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 PL/SQL function and reference it from the formulas:


function CompSal(salary number) return number is
begin
  return (salary*CostofLiving);
end;

Following are some examples of how you might reference the PL/SQL function in formulas:

CompSal(:RGNSUMSAL)

or

CompSal(:SAL) + COMM

See also

Creating a local program unit

About attached libraries

About external PL/SQL libraries