Jochem van Dieten wrote:
> I wouldn't use a RULE but a TRIGGER. Something like the one below
> (please check syntax ;) ).
Thanks, this works perfect for me now.
Is it correct that this is not possible to do when using pure "language 'sql'"
? As this language type can't refere to the "new" attribute.
> CREATE TRIGGER tr_insert_on_a AFTER INSERT OR UPDATE ON A
> FOR EACH ROW EXECUTE PROCEDURE fn_insert_on_a();
>
> CREATE function fn_insert_on_a() RETURNS OPAQUE AS '
> BEGIN
> INSERT INTO B name, a_ref VALUES(NEW.name, NEW.id);
> END;
> ' LANGUAGE 'plpgsql';
You only needed the "RETURN new;" line and this was perfect, thanks.
/BL