Re: Problem with RULE to update tables - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Problem with RULE to update tables
Date
Msg-id 7798.1047930089@sss.pgh.pa.us
Whole thread Raw
In response to Problem with RULE to update tables  (Sean Reifschneider <jafo@tummy.com>)
Responses Re: Problem with RULE to update tables  (Sean Reifschneider <jafo@tummy.com>)
List pgsql-bugs
Sean Reifschneider <jafo@tummy.com> writes:
> I've tried this on both 7.3 and 7.2.3, and am running into an odd
> problem.  Basically I have one table that is a count of available and one
> that has allocations against that.  I wanted to use rules to auto-update the
> available count, and everything works fine as long as I do deletes
> one-by-one...

> If I delete multiple records, the available count is only updated once.

Yup.  A rule is invoked once per query, not once per operated-on record.
You'll find that a trigger acts more like what you are expecting.

            regards, tom lane

pgsql-bugs by date:

Previous
From: pgsql-bugs@postgresql.org
Date:
Subject: Bug #912: pg_restore cannot restore individual rule from custom dump
Next
From: Bruce Momjian
Date:
Subject: Re: Bug #904: Deallocating of prepared statement in ECPG at