Re: question on rules

From: Tomasz Myrta <jasiek(at)bt(dot)jordan(dot)pl>
To: weigelt(at)metux(dot)de
Cc: PGSQL-SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: question on rules
Date: 2003-06-13 06:00:04
Message-ID: 3EE96864.1000504@bt.jordan.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Dnia 2003-06-13 03:26, Uz.ytkownik weigelt(at)metux(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message javier garcia - CEBAS 2003-06-13 11:44:09 date question
Previous Message Tom Lane 2003-06-13 01:57:25 Re: question on rules