"Tomislav Karastojkovic" <karastojko@gmail.com> writes:
> CREATE OR REPLACE RULE r AS ON INSERT TO parent WHERE id>=1 AND id <= 100 DO
> INSTEAD INSERT INTO child VALUES(NEW.id, NEW.message);
> then the sequence is increasing by 5 when inserting into 'parent' table.
"id" is basically a macro that gets replaced with the expression being
inserted, ie, the nextval() call. So you're getting bit with multiple
evaluation.
There isn't any very safe way to do this sort of thing with a rule.
Consider using a trigger instead.
regards, tom lane