[freetds] Update statement & SQL_NO_DATA

Sebastien FLAESCH sf at 4js.com
Tue Jan 27 03:29:41 EST 2009


Hi all,

 From my own experience, writing different ODBC interfaces to DB2, SQL Server
(Native Client and older NDAC client), I am always doing:

     r = SQLExecute(st->stmtHandle);
     if (!SQL_SUCCEEDED(r) && r != SQL_NO_DATA) {
         /* handle error */
     }

My 2 cents.
Seb

James K. Lowden wrote:
> Raju Mohanapu wrote:
>> SQLExecute (preparedUpdateStatement) returns SQL_SUCCESS even when no 
>> rows are affected. [...] I believe this 
>> is the behavior indicated in ODBC docs as well.
> 
> http://msdn.microsoft.com/en-us/library/ms713584(VS.85).aspx
> 
> 	"If SQLExecute executes a searched update or delete statement that does
> not affect any rows at the data source, the call to SQLExecute returns
> SQL_NO_DATA."
> 
> This was discussed extensively toward the end of February 2008.  See
> specifically Peter Deacon's post Wed, 27 Feb 2008 17:29:30 PST Sb:
> "SQL_NO_DATA or SQL_SUCCESS".  Observed driver behavior differs from the
> vague documented specified behavior, if that's possible!  
> 
>> For performance reasons, I wouldn't like to execute 
>> another command on the database to find whether any rows are affected by
>>
>> the just executed update statement. It would be ideal for me if the 
>> SQLExecute returned SQL_NO_DATA if no rows are affected. 
> 
> http://msdn.microsoft.com/en-us/library/ms711835(VS.85).aspx
> 
> 	"SQLRowCount returns the number of rows affected by an UPDATE, INSERT, or
> DELETE statement...."
> 
> SQLRowCount does not interrogate the server.  It returns information the
> driver already has.  The server included the rowcount in the DONE packet
> it sent to indicate the command was successfully completed.  
> 
> SQLRowCount is also the only portable way to learn the rowcount, zero or
> nonzero.  :-)
> 
> HTH.  
> 
> --jkl
> 
> 
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
> 



More information about the FreeTDS mailing list