Neoview Guide to Stored Procedures in Java (R2.3, R2.4)
100250 6301 245.00 15 GRAPHIC CARD, HR
.
.
.
--- 70 row(s) selected.
--- SQL operation complete.
For other result set examples, see Appendix A (page 77).
Calling SPJs From an ODBC Client Application
You can execute a CALL statement in an ODBC client application. Microsoft ODBC requires that
you put the CALL statement in an escape clause:
{call procedure-name ([parameter][,[parameter]]...)}
For IN or INOUT parameters, use a literal or a parameter marker (?). You cannot use an empty
string as an IN or INOUT parameter in the argument list. If you specify a literal for an INOUT
parameter, the driver discards the output value.
For OUT parameters, you can use only a parameter marker (?). You must bind all parameter
markers with the SQLBindParameter function before you can execute the CALL statement.
In this example, a CALL statement is executed from an ODBC client application:
/* Declare variables. */
SQLHSTMT hstmt;
SQL_NUMERIC_STRUCT salary;
SDWORD cbParam = SQL_NTS;
/* Bind the parameter markers. */
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_NUMERIC,
SQL_NUMERIC, 4, 0, 202, 0, &cbParam);
SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_FLOAT,
SQL_FLOAT, 0, 0, 5.5, 0, &cbParam);
SQLBindParameter(hstmt, 3, SQL_PARAM_OUTPUT, SQL_C_NUMERIC,
SQL_NUMERIC, 8, 2, &salary, 0, &cbParam);
/* Execute the CALL statement. */
SQLExecDirect(hstmt, "{call adjustsalary(?,?,?)}", SQL_NTS);
For more information about ODBC client applications, see the Neoview ODBC Drivers Manual.
Returning Result Sets in an ODBC Client Application
This example shows how an ODBC client application processes the result sets returned by a
CALL statement. The SQLMoreResults() function closes the current result set and moves
processing to the next available result set.
NOTE: The Neoview ODBC API does not currently support interleaved result set processing,
where more than one returned result set can be open at a time.
/* Allocate a statement handle */
SQLHSTMT s;
RETCODE rc = SQLAllocHandle(SQL_HANDLE_STMT, myConnection, &s);
/* Prepare a CALL */
char *stmtText = "{call sales.ordersummary('01-01-2001', ?)}";
rc = SQLPrepare(s, (SQLCHAR *) stmtText, strlen(stmtText));
/* Bind the output parameter */
_int64 num_orders = 0;
68 Executing SPJs