[freetds] Update statement & SQL_NO_DATA
James K. Lowden
jklowden at freetds.org
Mon Jan 26 22:48:19 EST 2009
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
More information about the FreeTDS
mailing list