create or replace trigger tmu_tmars.aux_bmzt
before insert or update of result_code on tmu_tmars.t_tmars_aux_adjudication
for each row
begin
:new.show_result := 'BMZT';
end;
千万不要这么写,这么写会有问题,会有毫不相干的数据行被修改。
应该使用如下的写法
create or replace trigger tmu_tmars.aux_bmzt
before insert or update of result_code on tmu_tmars.t_tmars_aux_adjudication
for each row
begin
case
when inserting then
:new.show_result := 'BMZT';
when updating then
if (nvl(:new.result_code, 'null') <> nvl(:old.result_code, 'null')) then
:new.show_result := 'BMZT';
end if;
end case;
end;