pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
update rule loops
2+ messages / 2 participants
[nested] [flat]

* update rule loops
@ 2000-08-18 15:01 Poul L. Christiansen <plc@faroenet.fo>
  2000-08-18 15:21 ` Re: update rule loops Stephan Szabo <sszabo@megazone23.bigpanda.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Poul L. Christiansen @ 2000-08-18 15:01 UTC (permalink / raw)
  To: pgsql-sql

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?

Thanks,
Poul L. Christiansen




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: update rule loops
  2000-08-18 15:01 update rule loops Poul L. Christiansen <plc@faroenet.fo>
@ 2000-08-18 15:21 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Stephan Szabo @ 2000-08-18 15:21 UTC (permalink / raw)
  To: Poul L. Christiansen <plc@faroenet.fo>; +Cc: 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.






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2000-08-18 15:21 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-08-18 15:01 update rule loops Poul L. Christiansen <plc@faroenet.fo>
2000-08-18 15:21 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox