Re: [GENERAL] UPDATE RULE to be invoked when UPDATE .. WHERE fails the WHERE predicate ?‏ - Mailing list pgsql-general

From Pavan Deolasee
Subject Re: [GENERAL] UPDATE RULE to be invoked when UPDATE .. WHERE fails the WHERE predicate ?‏
Date
Msg-id CABOikdPoyuZ0G7RPLYw9ySTXqV6fXL=6hNCw1XKU4yRZBLHgbA@mail.gmail.com
Whole thread Raw
In response to UPDATE RULE to be invoked when UPDATE .. WHERE fails the WHERE predicate ?‏  (John Lumby <johnlumby@hotmail.com>)
Responses RE: [GENERAL] UPDATE RULE to be invoked when UPDATE .. WHERE fails the WHERE predicate ?‏  (John Lumby <johnlumby@hotmail.com>)
List pgsql-general


On Thu, Aug 30, 2012 at 6:31 PM, John Lumby <johnlumby@hotmail.com> wrote:

I would like to use an UPDATE RULE to modify the action performed
when any UPDATE is attempted on a certain table,
*including* an UPDATE which would fail because of no rows matching the WHERE.

Is this at all possible?    I have tried with variations of ALSO|INSTEAD etc
but the RULE is never invoked in the failing case.      And my reading of
chapter 38.3.1. How Update Rules Work
is that the original query's quallification is always present.


You did not mention why you need such a facility, but AFAICS RULEs will only be applied on the qualifying rows. So as you rightly figured out, you won't see them firing unless there are any qualifying rows. Is this not something you can achieve via statement-level triggers though ?

Thanks,
Pavan

pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: psql & unix env variables
Next
From: Dipti Bharvirkar
Date:
Subject: Error stopping postgresql service on a standby server.