create or replace trigger S_UPDATE_CUSTBANK before update on bd_custbank for each row declare -- local variables here pk_bas char(20); cursor basjob(id char) is select pk_custbank from ncv5.bd_custbank /*目标数据库表*/ where pk_custbank = id and nvl(dr, 0) = 0; begin /*判断数据是否在目标数据库存在*/ open basjob(:new.pk_custbank); loop fetch basjob into pk_bas; exit when basjob%notfound; end loop; close basjob; /******************************/ if pk_bas is not null then if :new.account<>:old.account or :new.accname<>:old.accname or :new.memo<>:old.memo then raise_application_error(-20001, '请点击客商开户银行修改,此处不可修改!'); else begin update ncv5.bd_custbank /*目标数据库表*/ set pk_custbank = :new.pk_custbank, pk_cubasdoc = :new.pk_cubasdoc, accname = :new.accname, account = :new.account, accaddr = :new.accaddr, defflag = :new.defflag, memo = :new.memo, pk_accbank = :new.pk_accbank, pk_corp = :new.pk_corp, pk_currtype = :new.pk_currtype, ts = :new.ts, dr = :new.dr where pk_custbank = :new.pk_custbank; end; end if; end if; end S_UPDATE_CUSTBANK;
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)