Re: Update statement & SQL_NO_DATA

Sebastien FLAESCH <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Organization Four J's Development Tools
Message-ID <[email protected]>
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
> [email protected]
> http://lists.ibiblio.org/mailman/listinfo/freetds
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.