oracle操作同一张表触发器,数据正常执行insert,否则不执行 实例

create or replace trigger trigger_demo
before insert
on table1
for each row
declare
-- local variables here


pragma autonomous_transaction;--自治事物


BEGIN

--自定义逻辑

IF ('不满足条件')
THEN
ROLLBACK;
RAISE_APPLICATION_ERROR(-20020, '条件不满足,不能执行insert操作!');
ELSE
UPDATE table t SET
t.字段名1=:new.字段名1,
t.字段名2=:new.字段名2
WHERE t.字段名1=:new.字段名1;
END IF;
COMMIT;


end trigger_demo;

原文地址:https://www.cnblogs.com/kcwang/p/14888257.html