October 16, 2002 at 7:25 am
Hi
I am executing stored procedures through ODBC and binding the parameters using "Named Parameters" and I am facing problem if the stored procedures has return statement in it.
Say for the case 1,
Procedures without return values.
CREATE PROCEDURE test @quote char(30) AS
select * from TABLE1
I am binding as follows (illustrated in msdn)
SQLPrepare(hstmt, "{call test(?)}", SQL_NTS);
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT,
SQL_C_CHAR, SQL_CHAR, 30, 0, szQuote, 0, &cbValue);
SQLGetStmtAttr(hstmt,SQL_ATTR_IMP_PARAM_DESC, &hIpd, 0, 0);
SQLSetDescField(hIpd, 1, SQL_DESC_NAME, "@quote", SQL_NTS);
Case 2:
Procedures with return values.
CREATE PROCEDURE test @quote char(30) AS
select * from TABLE1
return @@RowCount
So, for the above stored procedure (case 2) the prepare statement is as follows :-
SQLPrepare(hstmt, "{? = call test(?)}", SQL_NTS);
But will anyone pl tell me how to bind the return value and other parameters using "Named Parameters".
Thanks
October 16, 2002 at 8:24 am
Infering from what ADO does, just create another parameter for the return but ensure you create it first, the name should be irelevant but sould be declare as a return rather than SQL_PARAM_INPUT and use integer.
Just guessing really.
Simon Sabin
Co-author of SQL Server 2000 XML Distilled
http://www.amazon.co.uk/exec/obidos/ASIN/1904347088
Simon Sabin
SQL Server MVP
http://sqlblogcasts.com/blogs/simons
October 16, 2002 at 8:38 am
Good guess Simon .
Doing this from memory, Simon is right. The correct type is SQL_PARAM_OUTPUT. Just check SQLBindParam in the MSDN for more information.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy