From: | Jeremy Semeiks <jrs(at)denny(dot)farviolet(dot)com> |
---|---|
To: | Luc ROLLAND <luc(at)rolland-fr(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Create Rule |
Date: | 2004-02-17 21:14:15 |
Message-ID: | 20040217211415.GT31948@64.81.242.180 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Tue, Feb 17, 2004 at 09:01:51PM +0100, Luc ROLLAND wrote:
> Hello !
>
> I would use a rule to store in each modified records the name of the user and the date of modification.
> I try :
>
> CREATE RULE shoe_mod AS ON UPDATE TO shoe_data
> DO INSTEAD UPDATE shoe_data
> SET shoename = NEW.shoename,
> sh_avail = NEW.sh_avail,
> slcolor = NEW.slcolor,
> slminlen = NEW.slminlen,
> slmaxlen = NEW.slmaxlen,
> slunit = NEW.slunit,
> shuser = current_user,
> shdatmod = current_date
> WHERE shoename = OLD.shoename ;
>
> but I obtain an infinite loop ...
> How can I do that.
Hi Luc,
Your rule specifies to update the table, and updating the table
triggers the rule, which specifies to update the table... ad
infinitum.
Try creating the rule on a view instead, then updating the view:
CREATE RULE shoe_data_v AS SELECT * FROM shoe_data;
CREATE RULE shoe_v_mod AS ON UPDATE TO shoe_data_v
DO INSTEAD UPDATE shoe_data
...
HTH,
Jeremy
From | Date | Subject | |
---|---|---|---|
Next Message | Sugrue, Sean | 2004-02-17 21:46:56 | Big databases vs small databases |
Previous Message | Luc ROLLAND | 2004-02-17 20:01:51 | Create Rule |