Skip to Content.
Sympa Menu

freetds - Re: [freetds] Update statement & SQL_NO_DATA

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: rmohanapu AT nyx.com, FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Update statement & SQL_NO_DATA
  • Date: Mon, 26 Jan 2009 22:48:19 -0500

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






Archive powered by MHonArc 2.6.24.

Top of Page