Skip to Content.
Sympa Menu

freetds - Re: [freetds] dbresults() behavior different between RH7.3 and CentOS4

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "David Chang" <dchang AT fsautomation.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] dbresults() behavior different between RH7.3 and CentOS4
  • Date: Fri, 20 Oct 2006 14:30:49 -0700

Hi,

I build a batch (e.g. 100) of stored procedure calls that simply insert (or update) one row of data into a table using dbfcmd(). Then, I submit this batch to SQL Server using dbsqlexec(). I was under the impression that calling dbresults() after a dbsqlexec() would iterate through one 'exec' at a time and tell me if that stored procedure ran OK. Then, after the last one in the batch finished, dbresults() would return NO_MORE_RESULTS (2). At least that's how Sybase DB-Library worked. Instead, what I see is that the first call to dbresults() returns NO_MORE_RESULTS (and all 100 stored procedures ran OK). If that's the case, how can I tell which stored procedure failed (e.g. unique constraint violation) out of the 100 that ran?

Here's a snipet of the code...

for (i=0; i<_Bcount; i++)
{
dbcmd (_Dbproc2, "exec dbpsp_update_rating_master ");
dbfcmd(_Dbproc2, " %d ", _Batch[i].dbpulse_id);
dbfcmd(_Dbproc2, ", %d ", _Batch[i].summary_level);
dbfcmd(_Dbproc2, ", %d ", _Batch[i].db_id);
dbfcmd(_Dbproc2, ", %.0f ", _Batch[i].good_query);
dbfcmd(_Dbproc2, ", %.0f ", _Batch[i].total_query);
}

dbsqlexec(_Dbproc2);

r_count = 0;
while ((r = dbresults(_Dbproc2)) != NO_MORE_RESULTS)
{
if (r != SUCCEED)
{
_Batch[r_count]._status = 2;
e_count++;
}
else
{
status = 0;
if (dbhasretstat(_Dbproc2))
status = dbretstatus(_Dbproc2);

if (status == 0)
{
_Batch[r_count]._status = 1;
g_count++;
}
else
{
_Batch[r_count]._status = 9;
e_count++;
}
}

r_count++;
}

I always get r_count = 0 and r = 2 (NO_MORE_RESULTS) when running this code.

Any help would be appreciated.

DC






Archive powered by MHonArc 2.6.24.

Top of Page