create or replace trigger tri_test after insert or update or delete on test pragma autonomous_transaction; begin if updating then dbms_output.put_line('修改'); elsif deleting then dbms_output.put_line('删除'); elsif inserting then dbms_output.put_line('插入'); end if; end;
表不变,仍然只插入一条记录AAABBB。为该表建一个视图,视图采用union方式动态加上BBBAAA的记录,对该表的查询改为对视图的查询,这样就不需要那么麻烦的维护两条数据了。
这样可否
after insert or update or delete on test
pragma autonomous_transaction;
begin
if updating then
dbms_output.put_line('修改');
elsif deleting then
dbms_output.put_line('删除');
elsif inserting then
dbms_output.put_line('插入');
end if;
end;