[freetds] problem with ODBC and store procedure output params

ZIGLIO, Frediano, VF-IT Frediano.Ziglio at vodafone.com
Thu Apr 22 11:32:05 EDT 2004


> 
> Not sure whether this is something I'm doing wrong,
> a general characteristic of ODBC, or a new or existing
> problem with the freetds ODBC mechanism...
> 
...
> 
> >From freetds ODBC however, things aren't so good...
> 
> I prepare the statement as
> 
>    {call sp_test_1(9,9,?)}
> 

This syntax is still not supported...

> and bind parameter like so:
> 
>    int val=0, indicator=0;
>    SQLBindParameter(stmtHandle, 1, SQL_PARAM_OUTPUT,
>  			  SQL_C_LONG, SQL_INTEGER, 
> 			  0, 0, &val, sizeof(val), &indicator);
> 
> The problem is, when I SQLExecute the statement, it returns
> SQL_SUCCESS_WITH_INFO. Using SqlGetDiagRec I see the
> error code is 8162 and the message is 
> [FreeTDS][SQL Server]Formal parameter '@P1' was defined as 
>  OUTPUT but the actual parameter not declared OUTPUT.
> 
> 
> However, I have noticed that if I change the invocation to
>    { call sp_test_1(?,?,?) }
> and then also bind parameters for the first two parameters,
> then the SQLExecute returns SQL_SUCCESS, and the output
> parameter value is properly returned to my application.
> 
> 
> I was able to demonstrate the same behavior by
> mucking around with the odbc/unittest/params.c slightly,
> and I have included the full version of that file below.
> 
> 
> So, the question is - what's up here? 
> 
> Any help would be much appreciated.
> 

A workaround is to prepare a ms sql syntax like "sp_test_1 9,9,?" (I'm
not that sure is works....). Or prepare something like "{call
sp_test_1(?,?,?)}" and bind parameters according.

> 
> Modified odbc/unittest/params.c:
> 

I'll have a look

bye
  freddy77



More information about the FreeTDS mailing list