数据库里有A表和B表,A表新增数据的时候,也往B表里新增数据,A表在修改数据的时候,B表会记录这条数据,同样是新增数据,但是当这条数据再次被修改时,B表里的记录永远是修改后的数据,求告知触发器insert 与update 写在一起时,是怎么写的
create or replace xxx_trg trigger as
after update or insert on table a
for each row
declare
begin
when inserting then
insert into b
end ;
when updating then
select count(*) from b
if count(*) > 0 then
update b;
else
insert into b
end;
end;
end;