BackPrevious Page Next PageNext

Example 4: Functions Declared and Defined in a Package and Package Body

Suppose that an Oracle stored procedure is defined as:

CREATE OR REPLACE PACKAGE "SCOTT"."SHDEMO_PKG" AS
type curtype is ref cursor;
Procedure empquery_proc (p_job in varchar2, cur OUT SHDEMO_PKG.curtype);
Function deptquery_func (p_dname in varchar2) return SHDEMO_PKG.curtype;
end SHDEMO_PKG;
CREATE OR REPLACE PACKAGE BODY "SCOTT"."SHDEMO_PKG" AS
Procedure empquery_proc (p_job in varchar2, cur OUT SHDEMO_PKG.curtype)
as
lcur SHDEMO_PKG.curtype;
begin
  open lcur for
  select * from EMP WHERE JOB = p_job;
  cur:=lcur;
end empquery_proc;
Function deptquery_func (p_dname in varchar2) return SHDEMO_PKG.curtype
as
lcur SHDEMO_PKG.curtype;
begin
  open lcur for
  select * from dept where dname = p_dname;
  return lcur;
end deptquery_func;
end SHDEMO_PKG;

To add the stored procedure into a JReport catalog, follow the steps below:

  1. Start JReport Designer and open an existing catalog.
  2. In the Catalog Manager, right-click the data source to which the stored procedure is to be added, then select New User Defined Data Source. The New User Defined Data Source dialog appears.
  3. In the Name field, specify a name for the UDS, for example, UDS1.
  4. In the Class Name field, input the UDS class jet.datasource.oracle.OracleProcedureUDS.
  5. In the Parameter box, enter one of the following:

    Add User Defined Data Source dialog

  6. Click the OK button. The UDS class will then be added into the catalog.

BackPrevious Page Next PageNext