Once a stored procedure is created and stored in the database, any application (or other stored procedure) can execute it by calling it. You can call stored procedures from ODBC, JDBC, or .NET applications, or directly from the Interactive SQL utility, isql.
For example, the following example shows an excerpt from an ODBC application that calls a stored procedure (order_parts) using the ODBC syntax:
{ call procedure_name ( param ) }.
Executing a Stored Procedure Through ODBC
SQLUINTEGER Part_num;
SQLINTEGER Part_numInd = 0;
// Bind the parameter.
SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0,
&Part_num, 0, Part_numInd);
// Place the department number in Part_num.
Part_num = 318;
// Execute the statement.
SQLExecDirect(hstmt, "{call order_parts(?)}", SQL_NTS);
Executing a stored procedure involves the following steps:
The following figure illustrates the steps in executing a stored procedure.