From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | "Poul L(dot) Christiansen" <plc(at)faroenet(dot)fo> |
Cc: | pgsql-sql <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: update rule loops |
Date: | 2000-08-18 15:21:45 |
Message-ID: | Pine.BSF.4.10.10008180819210.1321-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Fri, 18 Aug 2000, Poul L. Christiansen wrote:
> Hi
>
> I'm trying to make a field in my table (datechanged) to automatically be
> updated with the value 'now()' when an update on the table occurs.
>
> plc=# create rule datechanged_radius AS ON update to radius do update
> radius set datechanged ='now()';
> CREATE 22025360 1
> plc=# update radius set destinationip = '212.055.059.001';
> ERROR: query rewritten 10 times, may contain cycles
>
> This means that it's going in a loop, because the rule triggers itself.
>
> Is there another way to do this?
Two ways I can think of are either have a "view" where you do the work
on the view, but the underlying table is named something else, which
means you actually need to do an instead rule that does the update on
that table and the setting of datechanged. (Not 100% sure of this,
but should work).
Second is use triggers. Write a pl/pgsql before update trigger.
Assigning to NEW.datechanged should work I believe.
From | Date | Subject | |
---|---|---|---|
Next Message | Graham Vickrage | 2000-08-18 17:28:34 | RE: sequences in functions |
Previous Message | Stephan Szabo | 2000-08-18 15:18:07 | Re: Continuous inserts... |