triggers - Transactions - Oracle Vs PostgreSQL -
postgresql not have feature insert save points in trigger functions , when there exception ( exception no_data_found) entire transaction rolled back. instead of rolling entire transaction , wanted roll last saved point.
is there other aternative way can have multiple save points within trigger functions in postgresql.
here code :
create or replace function func_ex() returns trigger $func_ex$ declare var_name name; begin insert log_table (empid, empname) values (100, 'name'); -- savepoint my_savepoint; "cannot have savepoints in triggers select empname strict var_name emp_table1 empid = 3232332; exception when no_data_found raise notice 'no data found'; return new; end; return new $func_ex$ language plpgsql; -- end of function -- creation of trigger create trigger insert_trigger1 after update of empname on emp_table1 execute procedure func_ex();
postgresql not have feature insert save points in trigger functions
actually, does, they're implicit in begin ... exception
blocks.
your code looks correct, , it's not clear trying achieve doesn't do.
if want multiple savepoints in triggers, nest begin ... exception
blocks. can use raise
custom sqlstate
flow control.
it'd nice if pl/pgsql supported explicit named savepoints, using exception blocks works in experience.
Comments
Post a Comment