Re: Getting actual number of rows updated

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: CSN <cool_screen_name90001(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Getting actual number of rows updated
Date: 2005-08-08 08:38:56
Message-ID: 1123490337.15416.103.camel@sabrina.peacock.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Am Montag, den 08.08.2005, 00:32 -0700 schrieb CSN:
> Is it possible to have PG report the actual number of
> rows that actually CHANGED in an update command? e.g.
>
> UPDATE items set name=replace(name,'abc','def');
> UPDATE 9000 -- Actually only 3 were changed
>
> rather than update reporting all rows have been
> "updated"?

Since you have no where clause all rows have indeed been
updated. No matter if you write the same data which is
already in the row the update happens nevertheless.

(How would PG know? Also there might be a trigger or
something. So best is to just do what you request)

Add a where clause like WHERE name ~'abc';

And both you and PG will be happy :-)
--
Tino Wildenhain <tino(at)wildenhain(dot)de>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lipy Reis 2005-08-08 08:53:51 remove
Previous Message Patrick.FICHE 2005-08-08 08:14:26 Re: Getting actual number of rows updated