On 7/18/07, Scott Hess <sh....@google.com> wrote:
On 7/18/07, mich...@google.com <mich...@gmail.com> wrote:
Is there a simple way to determine the number of rows affected by an
UPDATE query?
Not at this time.
BTW, there _is_ a workaround. Use a transaction as follows:
BEGIN;
SELECT COUNT(*) FROM t WHERE value = ?;
UPDATE t SET othervalue = ? WHERE value = ?;
END;
This is cumbersome, but should be fairly efficient in most cases. The
SELECT will pull all the database pages into the memory cache, so the
UPDATE will run a bit faster. Overall, it will probably be only very
slightly slower than an UPDATE alone, unless your UPDATE is modifying
a large number of values.
-scott