Adapter for Oracle Stored Procedure Support

How to:

Reference:

The Adapter for Oracle allows you to use Direct SQL Passthru to call an Oracle stored procedure using any necessary input parameters. These procedures need to be developed within Oracle using the CREATE PROCEDURE command. They can either return an answer set or a return code indicating the result of the invocation when no data is returned. When an answer set is returned, the adapter creates a temporary Master File named SQLOUT that can be used to generate reports against the answer set.

Note: Oracle stored procedure support only allows the processing of one answer set per invocation. Attempts to retrieve multiple answer sets generate an error message.


Top of page

x
Syntax: How to Invoke an Oracle Stored Procedure
{ENGINE|SQL} SQLORA EX spnameparm1,parm2,...,parmn;

where:

spname

Is the Oracle stored procedure, it is of the form:

packagename.procedurename 
parmn

Are the parameter values to be supplied as input for the procedure and must be scalar in type. That is, only single values are acceptable as opposed to vector or array types. Non-supported parameter types will generate an error message.


Top of page

x
Reference: Rules for Oracle Stored Procedures

Note: Any application error that is issued by the stored procedure is available in the variable &ORAMSGTXT. The variable &ORAMSGTXT can be used in conjunction with &RETCODE to process errors and/or messages that are returned by the stored procedure.


Top of page

x
Syntax: How to Set a Maximum Number of Input Parameters for Oracle Stored Procedures

An adapter parameter can be used to set the maximum number of input parameters.

{ENGINE|SQL} SQLORA SET SPMAXPRM value 

where:

value

Is a numeric value indicating the maximum number of input parameters that may be entered for stored procedures. The default value is 256. This value is displayed by the SQL SQLORA ? query.



Example: Sample Oracle Stored Procedure
CREATE OR REPLACE PACKAGE pack1 AS
TYPE nfrectype IS RECORD (
employee NF29005.EMPLOYEE_ID5%TYPE,
ssn5     NF29005.SSN5%TYPE,
l_name   NF29005.LAST_NAME5%TYPE,
f_name   NF29005.FIRST_NAME5%TYPE,
birthday NF29005.BIRTHDATE5%TYPE,
salary   NF29005.SALARY5%TYPE,
joblevel NF29005.JOB_LEVEL5%TYPE);
TYPE nfcurtype IS REF CURSOR RETURN nfrectype ;
PROCEDURE proc1(c_saltable IN OUT nfcurtype);
END pack1 ;
/
CREATE OR REPLACE PACKAGE BODY pack1 AS
PROCEDURE proc1 (c_saltable IN OUT nfcurtype)
IS
BEGIN
OPEN c_saltable FOR SELECT 
EMPLOYEE_ID5,SSN5,LAST_NAME5,FIRST_NAME5,BIRTHDAT
E5,SALARY5,JOB_LEVEL5 FROM NF29005;
END proc1 ;  -- end of procedure
END pack1; -- end of package body
/


Example: Invoking an Oracle Stored Procedure That Returns an Answer Set

This example invokes a stored procedure that returns an answer set. The results can then be displayed using a TABLE request against the Master File SQLOUT that is created by the adapter to describe the returned answer set:

SQL SQLORA EX  pkg1.tblproc  parma;
TABLE FILE SQLOUT
PRINT *
END


Example: Invoking an Oracle Stored Procedure That Returns a Return Code

In the following example, the return code from the Oracle stored procedure is inspected to determine the flow of control.

SQL SQLORA EX pkg1.insrtproc parm1;
-IF &RETCODE EQ 0 GOTO OK;
-TYPE &ORAMSGTXT 
-OK;

Information Builders