we had a similar problem using ruby and ActiveRecord and solved it with RETURN NEW; at the end of the insert trigger which would result in inserting the row into the master table as well that is then deleted right away in an AFTER INSERT trigger CREATE OR REPLACE FUNCTION delete_master_trigger() DECLARE r master%rowtype; BEGIN DELETE FROM ONLY master WHERE id = NEW.id returning * into r; RETURN r; END; $$ LANGUAGE plpgsql; Returning the inserted row here also solves the problem that ORM often need auto increment values back. regards Manuel Kniep |