[freetds] Procedure question

Fernando fer.pantaneiro at gmail.com
Wed Mar 17 09:49:38 EDT 2010


Hi folks,

I have one doubt on the execution of one store procedure that I'm
sending to the MS SqlServer 2008.

Everything is working fine, but I want to know the correct way to
handle the output parameters I'm retrieving. This is how I'm doing
today:

if ( dbrpcparam(dbproc, "@param1", DBRPCRETURN, SYBCHAR,
sizeof(valorAbast), 0, (BYTE *)&param1) == FAIL)
{ ... }
.
.
.
if ( dbrpcsend(dbproc) == FAIL)
{ ... }

if(dbsqlok(dbproc) == FAIL)
{ ... }

while ((erc = dbresults(dbproc)) != NO_MORE_RESULTS)
{   /* nop */  }

And then, I get the output parameters here:

for (i = 1; i <= dbnumrets(dbproc); i++)
{
	retname = dbretname(dbproc, i);
	rettype = dbrettype(dbproc, i);
	retlen = dbretlen(dbproc, i);
	dbconvert(dbproc, rettype, dbretdata(dbproc, i), retlen, SYBVARCHAR,
(BYTE*) str, -1);
        ...
}

So my question is, Can I handle the procedure like I described
before?, or I have to handle the dbresults just like the rpc.c example
in the unittests? with the dbresults loop like this:
while ((erc = dbresults(dbproc)) != NO_MORE_RESULTS)
{
       if (erc == SUCCEED)
       {
	    dbbind(dbproc, 1, STRINGBIND, 0, (BYTE *) teststr);
	    while ((row_code = dbnextrow(dbproc)) != NO_MORE_ROWS)
            {
		...
	    }
       }
}
PS. when I tried it, my app did not enter in the loop.

My ./tsql -C
Compile-time settings (established with the "configure" script)
                            Version: freetds v0.82
             freetds.conf directory: /usr/local//etc
     MS db-lib source compatibility: yes
        Sybase binary compatibility: no
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 8.0
                              iODBC: no
                           unixodbc: no

Regards,
Fernando



More information about the FreeTDS mailing list