create or replace trigger tr_x_af_insert
before insert ON x
FOR EACH ROW
BEGIN
-- by lxm 实现修改报文功能(电子口岸提交修改报文,先对已经存在的数据打上删除标记,否则会报数据重复的错误)
-- EXISTS2('select * from dual where 1=1')=1
IF(exists2('select * from x x where x.is_delete=0 and x.unique_waybill_no='''|| :new.UNIQUE_WAYBILL_NO || '''')>=1) THEN
update xx set x.is_delete=1 where x.is_delete=0 and x.unique_waybill_no = :new.UNIQUE_WAYBILL_NO and x.id != :new.id;
END IF;
-- by lml 20170712实现 中航信过来的原始舱单ciq_org_code不对的问题
if(:new.source_code ='INFOSKY') then
:new.ciq_org_code:='y';
end if;
end;
before insert ON x
FOR EACH ROW
BEGIN
-- by lxm 实现修改报文功能(电子口岸提交修改报文,先对已经存在的数据打上删除标记,否则会报数据重复的错误)
-- EXISTS2('select * from dual where 1=1')=1
IF(exists2('select * from x x where x.is_delete=0 and x.unique_waybill_no='''|| :new.UNIQUE_WAYBILL_NO || '''')>=1) THEN
update xx set x.is_delete=1 where x.is_delete=0 and x.unique_waybill_no = :new.UNIQUE_WAYBILL_NO and x.id != :new.id;
END IF;
-- by lml 20170712实现 中航信过来的原始舱单ciq_org_code不对的问题
if(:new.source_code ='INFOSKY') then
:new.ciq_org_code:='y';
end if;
end;