Stored procedure calls in a Db2 ODBC application
To invoke stored procedures from a Db2 ODBC application, pass a CALL statement to SQLExecDirect(),
or to SQLPrepare() followed by SQLExecute().
- procedure-name
- The name of the stored procedure to execute. Call
SQLProcedures()to obtain a list of stored procedures that are available at the database.
Although the CALL statement cannot be prepared dynamically, Db2 ODBC accepts the CALL statement as if it can be dynamically prepared. You can also call stored procedures with the ODBC vendor escape sequence.
The question mark (?) in the CALL statement syntax diagram denotes
parameter markers that correspond to the arguments for a stored procedure.
Call SQLProcedureColumns() to determine the input
and output parameters for a stored procedure. You must pass all arguments
to a stored procedure with parameter markers. Literals, the NULL keyword,
and special registers are not allowed. However, you can use literals
if you include a vendor escape clause in your CALL statement.
You bind the parameter markers in a CALL statement to application
variables with SQLBindParameter(). Although you can
use stored procedure arguments that are both input and output arguments,
you should avoid sending unnecessary data between the client and the
server. Specify either SQL_PARAM_INPUT for input arguments or SQL_PARAM_OUTPUT
for output arguments when you call SQLBindParameter().
Specify SQL_PARAM_INPUT_OUTPUT only if the stored procedure uses arguments
that are both input and output arguments. Literals are considered
type SQL_PARAM_INPUT only.
