X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 4E12D30EB2B for ; Fri, 13 Jun 2003 06:00:09 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 27442-10 for ; Fri, 13 Jun 2003 02:59:58 -0300 (ADT) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by svr1.postgresql.org (Postfix) with ESMTP id 1345030E9B4 for ; Fri, 13 Jun 2003 02:59:58 -0300 (ADT) Received: from bt.jordan.pl (tv126.internetdsl.tpnet.pl [80.55.125.126]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 143792B3F3; Fri, 13 Jun 2003 07:59:56 +0200 (CEST) Message-ID: <3EE96864.1000504@bt.jordan.pl> Date: Fri, 13 Jun 2003 08:00:04 +0200 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: weigelt@metux.de Cc: PGSQL-SQL Subject: Re: question on rules References: <20030613012611.GA25276@metux.de> In-Reply-To: <20030613012611.GA25276@metux.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Archive-Number: 200306/152 X-Sequence-Number: 13910 Dnia 2003-06-13 03:26, Uz.ytkownik weigelt@metux.de napisa?: > 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 ? For this case creating trigger would be much better than rule. I think, you can't use rules this way. Regards, Tomasz Myrta