Can not get output value for input/output parm 
Author Message
 Can not get output value for input/output parm

Hi,

I have encountered problem getting data from input/output parameter from C++
application that uses ODBC. ODBC application version is 3.
ODBC SQL Server driver version: 3.60.0319

The code is following:

// SOURCE CODE

        char* statementString = new char[MAX_STATEMENT_LENGTH];
        strcpy( statementString, "{call testProc(?,?,?,?,?,?,?,?,?)}" );

SLONG personId;
SDWORD cbPersonId;
cbPersonId = SQL_NULL_DATA;
// ...
// other code
// ...
// Binding parameter to
SQLBindParameter( hStatement, 1, SQL_PARAM_INPUT_OUTPUT, SQL_C_SLONG,
SQL_INTEGER, 0, 0, &personId, 0, &cbPersonId );
// Binding other parameter
// ...

// END OF SOURCE CODE

After statement has been successfully executed with SQLExecDirect,
cbPersonId still equals SQL_NULL_DATA, meaning that no data has been
returned into input/output parameter buffer (and it is :) ). SQLExecDirect
itself returns SQL_SUCCESS.

At the SQL Server the procedure testProc has following parameter
description:

CREATE PROCEDURE testProc


    // blah-blah
    // ...
AS
    // procedure body
GO

When procedure executes at SQL Server query window, it returns parameter the
way as it has to.

I know that I can pass this problem many different ways but now I'm very
interested what I have missed there.

So, please, can you suggest what I'm doing wrong in my application.

Any ideas would be greatly appreciated.

Arzhan



Mon, 02 Jul 2001 03:00:00 GMT
 Can not get output value for input/output parm

Quote:

> Hi,

> I have encountered problem getting data from input/output parameter from C++
> application that uses ODBC. ODBC application version is 3.
> ODBC SQL Server driver version: 3.60.0319

> The code is following:

> // SOURCE CODE

>         char* statementString = new char[MAX_STATEMENT_LENGTH];
>         strcpy( statementString, "{call testProc(?,?,?,?,?,?,?,?,?)}" );

> SLONG personId;
> SDWORD cbPersonId;
> cbPersonId = SQL_NULL_DATA;
> // ...
> // other code
> // ...
> // Binding parameter to
> SQLBindParameter( hStatement, 1, SQL_PARAM_INPUT_OUTPUT, SQL_C_SLONG,
> SQL_INTEGER, 0, 0, &personId, 0, &cbPersonId );
> // Binding other parameter
> // ...

> // END OF SOURCE CODE

> After statement has been successfully executed with SQLExecDirect,
> cbPersonId still equals SQL_NULL_DATA, meaning that no data has been
> returned into input/output parameter buffer (and it is :) ). SQLExecDirect
> itself returns SQL_SUCCESS.

> At the SQL Server the procedure testProc has following parameter
> description:

> CREATE PROCEDURE testProc


>     // blah-blah
>     // ...
> AS
>     // procedure body
> GO

> When procedure executes at SQL Server query window, it returns parameter the
> way as it has to.

> I know that I can pass this problem many different ways but now I'm very
> interested what I have missed there.

> So, please, can you suggest what I'm doing wrong in my application.

> Any ideas would be greatly appreciated.

> Arzhan

You may not be doing anything wrong.  I cannot get either return values or
output parameters from my ODBC3.0 set up either.  The best information I can
find is this:  my driver does not support named parameters, output (or
input/output, or return values which ODBC treats as output parameters)
parameters must be named parameters.  End of story.  If you can use named
parameters ... maybe you could make it work.

Susan



Mon, 02 Jul 2001 03:00:00 GMT
 Can not get output value for input/output parm
I got a sence that I have done such calls without use of named
parameters. But I can be wrong. Sometimes it's hard to follow  your ODBC
driver version you have installed. :)
Anyway I'll try named parameters...
Thanks a lot.

Arzhan

Quote:

>You may not be doing anything wrong.  I cannot get either return values or
>output parameters from my ODBC3.0 set up either.  The best information I
can
>find is this:  my driver does not support named parameters, output (or
>input/output, or return values which ODBC treats as output parameters)
>parameters must be named parameters.  End of story.  If you can use named
>parameters ... maybe you could make it work.

>Susan



Tue, 03 Jul 2001 03:00:00 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. Output parameter vs Input/Output parameter

2. Stored procedure - input/output value

3. Getting output values from stored procedures called from a C program

4. Q: getting literal values into row output

5. Getting OUTPUT parameters and return values from Stored Procedures

6. DB2/400 Stored Procedure Output Parm with .NET OLEDB

7. VFP:how to get output parm from SQL Server stored procedure

8. Using Output Parm vs Recordset in Stored Procedures

9. Stored Procedures / AS400 / ODBC / Output Parm / CWBNL.DLL

10. SQL2000 Stored proceedure with both output parm and resultset

11. ODBC Problem with CHAR(1) output parm in stored procedure

12. Stored Procedures / AS400 / ODBC / Output Parm / CWBNL.DLL


 
Powered by phpBB® Forum Software