This trigger updated every row in the table to with a new value after each insert ALTER TRIGGER "tr_insert_eopi"
END |
You are mixing a row-level AFTER INSERT with a statement-level UPDATE, so the fact that multiple rows are updated should not come as a surprise (and the UPDATE might be called several times in case you would insert several times at once, say by a INSERT SELECT)... If you want to alter the contents of a row during the insert, I'd highly recommend a BEFORE INSERT trigger. That would simply have a body with something like
and all should be fine... If you prefer to use an AFTER INSERT trigger, make sure to restrict the UPDATE statement to a single row by filtering on the primary key of the just inserted row. |