INF: Output Parameters, Return Codes and the ODBC DriverID: Q152174
|
This article discusses how the Microsoft SQL Server ODBC Driver returns stored procedure return codes and output parameters to an ODBC application. SQL Server ODBC drivers from other vendors may do this differently; users should consult the documentation for the driver.
SQL Server stored procedures can return both output parameters and return
codes to an application:
CREATE PROCEDURE odbcproc @ioparm int OUTPUT AS
SELECT name FROM sysusers WHERE uid < 2
SELECT @ioparm = 88
RETURN 99
GO
SQLRETURN rcd;
DWORD ProcRet = 0, OParm = 0;
long cbProcRet = 0, cbOParm = 0;
// Bind the return code.
rcd = SQLBindParameter(hstmt, 1, SQL_PARAM_OUTPUT,
SQL_C_SLONG, SQL_INTEGER, 0, 0, &ProcRet, 0, &cbProcRet);
// Bind the output parameter.
rcd = SQLBindParameter(hstmt, 2, SQL_PARAM_OUTPUT,
SQL_C_SLONG, SQL_INTEGER, 0, 0, &OParm, 0, &cbOParm;
// First ? marks the return code,
// second ? marks the output parameter.
rcd = (SQLExecDirect(hstmt, "{? = call odbcproc(?)}", SQL_NTS;
Additional query words: Fetch
Keywords :
Version : 6.0 6.5
Platform : WINDOWS
Issue type :
Last Reviewed: March 26, 1999