question on rules

From: weigelt(at)metux(dot)de
To: PGSQL-SQL <pgsql-sql(at)postgresql(dot)org>
Subject: question on rules
Date: 2003-06-13 01:26:11
Message-ID: 20030613012611.GA25276@metux.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


hi folks,

i'd like to write an rule which fills out some empty attrs on
insert (w/ data from other given attrs).

the table structure is:
CREATE TABLE foo (start date, duration integer, endtime date);

and the rule is:
CREATE RULE foo1 AS ON INSERT TO foo WHERE new.endtime = NULL DO
INSERT INTO foo SELECT new.start, new.duration, new.start + new.duration;

when i try to insert some data (INSERT INTO foo SELECT '2003-01-01', '12';)
i get the error: query rewritten 10 times, may contain cycles.

how can i avoid this loop ?

cu
--
---------------------------------------------------------------------
Enrico Weigelt == metux ITS
Webhosting ab 5 EUR/Monat. UUCP, rawIP und vieles mehr.

phone: +49 36207 519931 www: http://www.metux.de/
fax: +49 36207 519932 email: contact(at)metux(dot)de
cellphone: +49 174 7066481 smsgate: sms(dot)weigelt(at)metux(dot)de
---------------------------------------------------------------------
Diese Mail wurde mit UUCP versandt. http://www.metux.de/uucp/

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-06-13 01:57:25 Re: question on rules
Previous Message Josh Berkus 2003-06-12 17:10:45 Re: help