Re: Create Rule
От | Jeremy Semeiks |
---|---|
Тема | Re: Create Rule |
Дата | |
Msg-id | 20040217211415.GT31948@64.81.242.180 обсуждение исходный текст |
Ответ на | Create Rule ("Luc ROLLAND" <luc@rolland-fr.com>) |
Ответы |
Re: Create Rule
|
Список | 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
В списке pgsql-novice по дате отправления: