DB Access Module for DB2 CLI User’s Guide : Chapter 2 Technical Information : Open SQL and DB2 CLI : Stored Procedures and Open SQL
Stored Procedures and Open SQL
Standard DB2 CLI stored procedure invocation syntax can be used when executing stored procedures with RWDBOSql.
 
RWDBOSql myOpenSqlObject("{ CALL myStoredProc(?, ?) }", RWDBOSql::Procedure);
In this example, myStoredProc is the name of the stored procedure, and ? characters are the placeholders for the parameters to be passed to the stored procedure. Note the provided hint RWDBOSql::Procedure.
 
RWDBOSql myOpenSqlObject("{ ? = CALL myStoredProc(?, ?)}", RWDBOSql::Procedure);
This example uses an additional placeholder to receive the return value of the stored procedure as an OUT parameter. A DB2 stored procedure is allowed to have a return value only of type integer.
Please see “An Open SQL Stored Procedure Example” for an example that uses RWDBOSql with stored procedures.
NOTE >> Stored procedure execution is not supported with the data callback classes.
Sequence of Fetching Result Sets and Out Parameters
DB2 stored procedures have no requirement regarding the sequence in which result sets and OUT parameters are fetched. Function fetchReturnParams() could be called any time after the stored procedure execution to retrieve the OUT parameters.
However, to make your application portable across different access modules, it is recommended to fetch OUT parameters after completely processing the result sets.