Re: Problem with RULE to update tables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sean Reifschneider <jafo(at)tummy(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Problem with RULE to update tables
Date: 2003-03-17 19:41:29
Message-ID: 7798.1047930089@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Sean Reifschneider <jafo(at)tummy(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2003-03-17 21:41:48 Re: Bug #904: Deallocating of prepared statement in ECPG at
Previous Message pgsql-bugs 2003-03-17 19:27:19 Bug #912: pg_restore cannot restore individual rule from custom dump