freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Sebastien FLAESCH <sf AT 4js.com>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] Update statement & SQL_NO_DATA
- Date: Tue, 27 Jan 2009 09:29:41 +0100
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
-
[freetds] Update statement & SQL_NO_DATA,
Raju Mohanapu, 01/26/2009
-
Re: [freetds] Update statement & SQL_NO_DATA,
James K. Lowden, 01/26/2009
- Re: [freetds] Update statement & SQL_NO_DATA, Sebastien FLAESCH, 01/27/2009
- Re: [freetds] Update statement & SQL_NO_DATA, Raju Mohanapu, 01/27/2009
-
Re: [freetds] Update statement & SQL_NO_DATA,
James K. Lowden, 01/26/2009
Archive powered by MHonArc 2.6.24.