pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomasz Myrta <jasiek@bt.jordan.pl>
To: weigelt@metux.de
Cc: PGSQL-SQL <pgsql-sql@postgresql.org>
Subject: Re: question on rules
Date: Fri, 13 Jun 2003 08:00:04 +0200
Message-ID: <3EE96864.1000504@bt.jordan.pl> (raw)
In-Reply-To: <20030613012611.GA25276@metux.de>
References: <20030613012611.GA25276@metux.de>

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





view thread (4+ messages)  latest in thread

Message-ID: <3EE96864.1000504@bt.jordan.pl>
Permalink:  ../3EE96864.1000504@bt.jordan.pl/
Also on:    postgresql.org/message-id/3EE96864.1000504@bt.jordan.pl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jasiek@bt.jordan.pl, weigelt@metux.de
  Subject: Re: question on rules
  In-Reply-To: <3EE96864.1000504@bt.jordan.pl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox