实际问题是A表中新增数据的时候,部分字段的信息如果在B表中不存在,则需要将该部分信息插入到B表中,因此参考网上其他解决方案重新编写相应SQL。
代码如下:
create or replace trigger test_bbb_trigger
after insert or update on test_aaa
for each row
declare
v_count number(10);
begin
select count(*)
into v_count
from test_bbb t
where t.columna= :new.columna
and t.columnb = :new.columnb
and t.columnc = :new.columnc;
if v_count = 0 then
insert into test_bbb
select sys_guid() id,
:new.columna,
:new.columnb,
:new.columnc,
'2023' work_year,
parent_id,
level_no,
is_leaf,
is_enabled,
remark,
is_standard,
sysdate update_time,
is_deleted
from test_bbb p
where p.columna = :new.columna
and rownum = 1;
end if;
end;