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
---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html