建立一个临时表:
CREATE GLOBAL TEMPORARY TABLE northsnow_tmp(
northsnow_id varchar2(20))ON COMMIT DELETE ROWS;
在业务表上创建一个行级触发器:
create or replace trigger trg_northsnow
after insert on tb_northsnow
for each row
begin
if :new.column_a='japan' then
insert into northsnow_tmp values(:new.rowid);
end if;
end trg_northsnow ;
在创建一个表级触发器:
create or replace trigger trg_northsnow_del
after insert on tb_northsnow
begin
delete from tb_northsnow where exists(select 1 from northsnow_tmp where northsnow_id=tb_northsnow.rowid);
end trg_northsnow_del;
这样当你插入一条 column_a为japan的记录时,将会在行级触发器进行检查,并将rowid存入临时表,然后在触发的表级触发器中删除该记录。