Reputation: 781
i am experimenting with triggers in postgreSQL, but the trigger insert i would like to make is being done twice for some reason(THIS IS USING THE FOR EACH ROW), when i changed it to FOR EACH STATEMENT it was executing the insert 3 times. this is my sql script
CREATE OR REPLACE FUNCTION forest_aud_func() returns trigger as $tree_stamp$
BEGIN
insert into Audit values('k',124,'l');
return null;
END;
$tree_stamp$
LANGUAGE plpgsql;
create trigger forest_aud_ins after insert on forest
for each row execute procedure forest_aud_func()
insert into forest values('Blue',1600,'Austria','Health Ltd')
any idea why this is happening? Thanks
Upvotes: 1
Views: 2337
Reputation: 781
i found out the problem, i was always creating new triggers but not deleting the previous ones, so each time i do an insert it was firing all the triggers i had done, sorry and thanks for your help
Upvotes: 2