Stored procedure CALL

In ODBC, you can use the extended SQL syntax for calling a stored procedure in a vendor escape clause to make stored procedure calls portable in your SQL statements.

The following extended SQL syntax calls a stored procedure.
Read syntax diagramSkip visual syntax diagram?=callprocedure-name (,parameter)
?=
Specifies that you want Db2 ODBC to return the SQLCODE of the stored procedure call in the first parameter that you specify in SQLBindParameter(). If ?= is not present, you can retrieve the SQLCA with SQLGetSQLCA() .
procedure-name
Specifies the name of a procedure that is stored at the data source.
parameter
Specifies a procedure parameter. A procedure can have zero or more parameters.

Important: Unlike ODBC, Db2 ODBC does not support literals as procedure arguments. You must use parameter markers to specify a procedure parameter.

Example: You can use either of the following forms of the escape clause to call a stored procedure. In this example, the statements call the procedure NETB94, which uses three parameters.
  • Short-form syntax:
    {CALL NETB94(?,?,?)}
  • Long-form syntax:
    --(*vendor(Microsoft),product(ODBC) CALL NEBT94(?,?,?)*)--
    

To determine if a particular data source supports stored procedure calls, call SQLGetInfo() with the InfoType argument set to SQL_PROCEDURES.