Adding an Oracle stored procedure

Suppose that the Oracle stored procedure is defined as follows:

Package SHDEMO as type curtype is ref cursor;
end SHDemo;
Procedure empquery (param1 in varchar2, cur OUT SHdemo.curtype)
as
lcur shdemo.curtype;
begin
  open lcur for select * from EMP WHERE JOB = param1;
  cur:=lcur;
end empquery;
To add the stored procedure into a JReport catalog, follow the steps below:
  1. Start JReport Designer and open the catalog to which you want to add the stored procedure.
  2. In the Catalog Browser, right-click the data source the stored procedure is to be added, then select Add User Defined Data Source.
  3. In the Name field of the Add User Defined Data Source dialog, specify a name for the UDS.
  4. In the Class Name field, input the UDS class jet.datasource.oracle.OracleProcedureUDS.
  5. In the Parameter box, enter any of the following three:
  6. Click OK, and the UDS class will be added into the catalog.
Formats of the PARAMETER string

In the Add User Defined Data Source dialog, the format of the PARAMETER string is in either of the following. You can choose one according to your requirement. When the stored procedures used in Oracle have different names, either of the following two formats can be used. However, when the stored procedures used in Oracle have same names, you can only use the second PARAMETER string. In addition, when you use the second PARAMETER string, the parameter value only contains value. You need to add the data type and index of the parameter value in the user defined data source class.

Substitute the words in lower case according to your requirements.

Where:

Below is an example of the PARAMETER string:

DRIVER=oracle.jdbc.driver.OracleDriver&URL="jdbc:oracle:thin:@dbserver:1521:orcl" &USER=scott&PSWD=tiger&OWNER=SCOTT&PROCNAME=getAuthor&SQL={call getAuthor(?, ?, ?}&REFCURSORINDEX=2&PARAMVALUE=0.5,1999-7-10

If you want to change the connection dynamically, you can define the parameters in this way:

oracle.jdbc.driver.OracleDriver=@driver, jdbc:oracle:thin:@dbserver:1521:orcl=@url, scott=@user,

The PARAMETER string will then be either of the following:

You can change the parameter dynamically to suit your requirements.

Notes:

The following are some specific examples of adding Oracle stored procedures UDS to a catalog: