TRIGGER_15.8.3BACKUP

时间:2021-10-07 19:47:04

TRIGGER_15.8.3BACKUP

1

CREATE OR REPLACE TRIGGER "XMV502"."ADDAREA12"

  before insert on bd_areacl
for each row
declare
-- local variables here
vsupply char(40);
vname char(20);
i number;
begin for i in 2..12 loop select areaclname into vname from bd_areacl where pk_areacl=:new.pk_fatherarea;
if length(:new.areaclcode)='' and substr(:new.areaclcode,-2,2)='' then
case when i=2 then vsupply:='块材类供应商名录';
when i=3 then vsupply:='水泥类供应商名录';
when i=4 then vsupply:='木材类供应商名录';
when i=5 then vsupply:='金属类供应商名录';
when i=6 then vsupply:='高分子材料类供应商名录';
when i=7 then vsupply:='电工材料类供应商名录';
when i=8 then vsupply:='安全防护用品器材供应商名录';
when i=9 then vsupply:='其他材料类供应商名录';
when i=10 then vsupply:='器材租赁供应商名录';
when i=11 then vsupply:='专业分包供应商名录';
else vsupply:='税款、投标类他项名录';
end case;
insert into bd_areacl
(
areaclcode,
areaclname,
def1,
def2,
def3,
def4,
def5,
dr,
mnecode,
pk_areacl,
pk_corp,
pk_fatherarea,
ts
)
values
(
substr(:new.areaclcode,0,6)||lpad(i,2,''),
trim(replace(vname,'市',''))||vsupply ,
:new.def1,
:new.def2,
:new.def3,
:new.def4,
:new.def5,
:new.dr,
:new.mnecode,
lpad(i,2,'')||substr(:new.pk_areacl,-18,18),
:new.pk_corp,
:new.pk_fatherarea,
:new.ts
); end if;
end loop;
end ADDAREA12;

2

CREATE OR REPLACE TRIGGER "XMV502"."ADDARECL"
before insert on bd_areacl
for each row
declare
-- local variables here pk_bas char(20); cursor basjob(id char) is
select pk_areacl
from ncv5.bd_areacl /*目标数据库表*/
where pk_areacl = id
and nvl(dr, 0) = 0;
begin
/*判断数据是否在目标数据库存在*/
open basjob(:new.pk_areacl); loop fetch basjob
into pk_bas; exit when basjob%notfound; end loop;
close basjob;
/******************************/ if pk_bas is null then
begin
insert into ncv5.bd_areacl /*目标数据库表*/
(
areaclcode,
areaclname,
def1,
def2,
def3,
def4,
def5,
dr,
mnecode,
pk_areacl,
pk_corp,
pk_fatherarea,
ts
)
values
(
:new.areaclcode,
:new.areaclname,
:new.def1,
:new.def2,
:new.def3,
:new.def4,
:new.def5,
:new.dr,
:new.mnecode,
:new.pk_areacl,
:new.pk_corp,
:new.pk_fatherarea,
:new.ts
);
end; end if;
end addarecl;

3

CREATE OR REPLACE TRIGGER "XMV502"."ADDBANK"
before insert on bd_accbank
for each row
declare
-- local variables here pk_bas char(20); cursor basjob(id char) is
select pk_accbank
from ncv5.bd_accbank /*目标数据库表*/
where pk_accbank = id
and nvl(dr, 0) = 0;
begin
/*判断数据是否在目标数据库存在*/
open basjob(:new.pk_accbank); loop fetch basjob
into pk_bas; exit when basjob%notfound; end loop;
close basjob;
/******************************/ if pk_bas is null then
begin
insert into ncv5.bd_accbank /*目标数据库表*/
(pk_corp,
bankacc,
bankname,
accopendate,
address,
tel,
contactpsn,
sealflag,
memo,
netbankflag,
banktype,
areacode,
unitname,
bankowner,
pk_settlecent,
pk_settleunit,
genebranprop,
ctlprop,
arapprop,
pk_accid,
combineaccnum,
orgnumber,
branchname,
bankarea,
province,
city,
remcode,
iscontrolled,
beginmny,
beginmnydate,
abcarea,
pk_createunit,
groupid,
netqueryflag,
pk_currtype,
isautoreturn,
pk_accbank,
def2,
def3,
def4,
def5,
def1,
custcode,
groupaccount,
signflag,
ts,
dr)
values
(:new.pk_corp,
:new.bankacc,
:new.bankname,
:new.accopendate,
:new.address,
:new.tel,
:new.contactpsn,
:new.sealflag,
:new.memo,
:new.netbankflag,
:new.banktype,
:new.areacode,
:new.unitname,
:new.bankowner,
:new.pk_settlecent,
:new.pk_settleunit,
:new.genebranprop,
:new.ctlprop,
:new.arapprop,
:new.pk_accid,
:new.combineaccnum,
:new.orgnumber,
:new.branchname,
:new.bankarea,
:new.province,
:new.city,
:new.remcode,
:new.iscontrolled,
:new.beginmny,
:new.beginmnydate,
:new.abcarea,
:new.pk_createunit,
:new.groupid,
:new.netqueryflag,
:new.pk_currtype,
:new.isautoreturn,
:new.pk_accbank,
:new.def2,
:new.def3,
:new.def4,
:new.def5,
:new.def1,
:new.custcode,
:new.groupaccount,
:new.signflag,
:new.ts,
:new.dr);
end; end if;
end addBank;

4

CREATE OR REPLACE TRIGGER "XMV502"."ADDBD_ACCBANK_FTS"
before insert on bd_accbank_fts
for each row
declare
-- local variables here pk_bas char(20); cursor basjob(id char) is
select pk_accbank
from ncv5.bd_accbank_fts /*目标数据库表*/
where pk_accbank = id
and nvl(dr, 0) = 0;
begin
/*判断数据是否在目标数据库存在*/
open basjob(:new.pk_accbank_fts); loop fetch basjob
into pk_bas; exit when basjob%notfound; end loop;
close basjob;
/******************************/ if pk_bas is null then
begin
insert into ncv5.bd_accbank_fts /*目标数据库表*/
(arapprop,
beginmny,
beginmnydate,
ctlprop,
dr,
genebranprop,
iscontrolled,
pk_accbank,
pk_accbank_fts,
pk_accid,
pk_corp,
pk_createunit,
pk_settlecent,
pk_settleunit,
ts)
values
(:new.arapprop,
:new.beginmny,
:new.beginmnydate,
:new.ctlprop,
:new.dr,
:new.genebranprop,
:new.iscontrolled,
:new.pk_accbank,
:new.pk_accbank_fts,
:new.pk_accid,
:new.pk_corp,
:new.pk_createunit,
:new.pk_settlecent,
:new.pk_settleunit,
:new.ts);
end; end if;
end addBd_accbank_fts;

5 noUSER

CREATE OR REPLACE TRIGGER "XMV502"."ADDBD_CUSTBANK"
before insert on bd_custbank
for each row
declare
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 null then begin insert into ncv5.bd_custbank /*目标数据库表*/
(pk_custbank,
pk_cubasdoc,
accname,
account,
accaddr,
defflag,
memo,
pk_accbank,
pk_corp,
pk_currtype,
ts,
dr)
values
(:new.pk_custbank,
:new.pk_cubasdoc,
:new.accname,
:new.account,
:new.accaddr,
:new.defflag,
:new.memo,
:new.pk_accbank,
:new.pk_corp,
:new.pk_currtype,
:new.ts,
:new.dr);
end; end if; end addbd_custbank;

6

CREATE OR REPLACE TRIGGER "XMV502"."ADDC4"
before insert on bd_cubasdoc
for each row
declare
-- local variables here
v_exp varchar2(200); begin --空格的客商
if regexp_like(:new.custname,'[[:space:]]')
then raise_application_error(-20001, '客商名称:' || :new.custname || '有空格,请修改');
end if; --重复名称、营业执照、纳税人登记号客商
select case
when custname = :new.custname then
'客商名称:' || :new.custname || '已存在,请在已有客商修改增行!'
when engname = :new.engname and length(:new.engname) > 3 then
'客商营业执照:' || :new.engname || '已存在,请在已有客商修改增行!'
when taxpayerid = :new.taxpayerid and length(:new.taxpayerid) > 3 then
'客商纳税人登记号:' || :new.taxpayerid || '已存在,请在已有客商修改增行!'
ELSE
'其他错误'
END
INTO v_exp
from bd_cubasdoc
where custname = :new.custname
or (engname = :new.engname and length(:new.engname) > 3) --营业执照或身份照
or (taxpayerid = :new.taxpayerid and length(:new.taxpayerid) > 3);--纳税人登记号
if v_exp is not null then
raise_application_error(-20001, v_exp);
end if;--相当于前面 else return? --正常客商通过exception,否则触发器提示“未找到任何数据”
exception
when no_data_found then
return; end;

7

CREATE OR REPLACE TRIGGER "XMV502"."ADDCUST"
before insert on bd_cubasdoc
for each row
declare
-- local variables here
pk_bas char(20); corp char(4); /*查询目标公司目录*/
cursor bdcorp is
select pk_corp
from ncv5.bd_corp /*目标数据库表*/
where nvl(dr, 0) = 0
and pk_corp <> '';
/*查询目标公司是否存在基本档案*/
cursor basjob(id char) is
select pk_cubasdoc
from ncv5.bd_cubasdoc
where pk_cubasdoc = id
and nvl(dr, 0) = 0; begin /*判断目标公司数据是否存在*/
/* dbms_output.put_line('aaa');
select pk_cubasdoc into pk_bas from bd_cubasdoc1\*目标数据库表*\ where pk_cubasdoc=:new.pk_cubasdoc and nvl(dr,0)=0;*/ open basjob(:new.pk_cubasdoc); loop fetch basjob
into pk_bas; exit when basjob%notfound; end loop;
close basjob;
-- dbms_output.put_line('ddd');
/*插入目标基本档案数据*/
if pk_bas is null then begin /*--目标基本档案表/*目标数据库表*/ insert into ncv5.bd_cubasdoc
(pk_cubasdoc,
pk_corp,
custcode,
custname,
custshortname,
engname,
mnecode,
trade,
freecustflag,
drpnodeflag,
isconnflag,
pk_cubasdoc1,
custprop,
pk_areacl,
pk_corp1,
taxpayerid,
legalbody,
creditmny,
ecotypesincevfive,
saleaddr,
conaddr,
zipcode,
phone1,
phone2,
phone3,
fax1,
fax2,
linkman1,
linkman2,
linkman3,
bp1,
bp2,
bp3,
mobilephone1,
mobilephone2,
mobilephone3,
email,
url,
def1,
def2,
def3,
def4,
def5,
def6,
def7,
def8,
def9,
def10,
def11,
def12,
def13,
def14,
def15,
def16,
def17,
def18,
def19,
def20,
registerfund,
sealflag,
memo,
pk_pricegroup,
correspondunit,
ts,
dr)
values
(:new.pk_cubasdoc,
:new.pk_corp,
:new.custcode,
:new.custname,
:new.custshortname,
:new.engname,
:new.mnecode,
:new.trade,
:new.freecustflag,
:new.drpnodeflag,
:new.isconnflag,
:new.pk_cubasdoc1,
:new.custprop,
:new.pk_areacl,
:new.pk_corp1,
:new.taxpayerid,
:new.legalbody,
:new.creditmny,
:new.ecotypesincevfive,
:new.saleaddr,
:new.conaddr,
:new.zipcode,
:new.phone1,
:new.phone2,
:new.phone3,
:new.fax1,
:new.fax2,
:new.linkman1,
:new.linkman2,
:new.linkman3,
:new.bp1,
:new.bp2,
:new.bp3,
:new.mobilephone1,
:new.mobilephone2,
:new.mobilephone3,
:new.email,
:new.url,
:new.def1,
:new.def2,
:new.def3,
:new.def4,
:new.def5,
:new.def6,
:new.def7,
:new.def8,
:new.def9,
:new.def10,
:new.def11,
:new.def12,
:new.def13,
:new.def14,
:new.def15,
:new.def16,
:new.def17,
:new.def18,
:new.def19,
:new.def20,
:new.registerfund,
:new.sealflag,
:new.memo,
:new.pk_pricegroup,
:new.correspondunit,
:new.ts,
:new.dr);
--dbms_output.put_line('ccc');
/*插入目标管理档案数据*/
open bdcorp;
loop fetch bdcorp
into corp;
exit when bdcorp%notfound; -- dbms_output.put_line(:new.pk_cubasdoc);
/*管理档案有两条数据,插入两次*/
insert into ncv5.bd_cumandoc /*目标数据库表*/
(pk_cumandoc,
pk_corp,
pk_cubasdoc,
custflag,
linkman,
bp,
mobilephone,
pk_defbusitype,
frozenflag,
frozendate,
discountrate,
creditlevel,
creditmny,
creditlimitnum,
accawmny,
busawmny,
ordawmny,
pk_respdept1,
pk_resppsn1,
diffcurrflag,
developdate,
credlimitflag,
pk_currtype1,
pk_cusmandoc2,
pk_cusmandoc3,
pk_sendtype,
pk_stordoc2,
def1,
def2,
def3,
def4,
def5,
def6,
def7,
def8,
def9,
def10,
def11,
def12,
def13,
def14,
def15,
def16,
def17,
def18,
def19,
def20,
def21,
def22,
def23,
def24,
def25,
def26,
def27,
def28,
def29,
def30,
memo,
pk_payterm,
cooperateflag,
creditmoney,
testsalemoney,
pk_salestru,
pk_calbody,
iounit,
ratifydate,
sealflag,
custstate,
pk_pricegroupcorp,
freeofcremnycheck,
freeofacclmtcheck,
balancemny,
acclimit,
acclmtbegindate,
cmnecode,
grade,
cooperatingdayfrom,
cooperatingdayto,
correspsettleunit,
pk_settleunit,
innerctldays,
ispromtesettlement,
stockpriceratio,
ts,
dr)
values
('A100' ||corp|| substr(:new.pk_cubasdoc,9, 20),
corp /*公司*/,
:new.pk_cubasdoc,
'',
null,
null,
null,
null,
'N',
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
'N',
null,
0,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
'N',
null,
null,
null,
null,
'N',
null,
null,
0,
null,
'N',
'N',
null,
30,
null,
:new.mnecode,
0,
null,
null,
null,
null,
null,
'Y',
100,
sysdate,
0); insert into ncv5.bd_cumandoc /*目标数据库表*/
(pk_cumandoc,
pk_corp,
pk_cubasdoc,
custflag,
linkman,
bp,
mobilephone,
pk_defbusitype,
frozenflag,
frozendate,
discountrate,
creditlevel,
creditmny,
creditlimitnum,
accawmny,
busawmny,
ordawmny,
pk_respdept1,
pk_resppsn1,
diffcurrflag,
developdate,
credlimitflag,
pk_currtype1,
pk_cusmandoc2,
pk_cusmandoc3,
pk_sendtype,
pk_stordoc2,
def1,
def2,
def3,
def4,
def5,
def6,
def7,
def8,
def9,
def10,
def11,
def12,
def13,
def14,
def15,
def16,
def17,
def18,
def19,
def20,
def21,
def22,
def23,
def24,
def25,
def26,
def27,
def28,
def29,
def30,
memo,
pk_payterm,
cooperateflag,
creditmoney,
testsalemoney,
pk_salestru,
pk_calbody,
iounit,
ratifydate,
sealflag,
custstate,
pk_pricegroupcorp,
freeofcremnycheck,
freeofacclmtcheck,
balancemny,
acclimit,
acclmtbegindate,
cmnecode,
grade,
cooperatingdayfrom,
cooperatingdayto,
correspsettleunit,
pk_settleunit,
innerctldays,
ispromtesettlement,
stockpriceratio,
ts,
dr)
values
('A200' ||corp|| substr(:new.pk_cubasdoc,9,20),
corp /*公司*/,
:new.pk_cubasdoc,
'',
null,
null,
null,
null,
'N',
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
'N',
null,
0,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
'N',
null,
null,
null,
null,
'N',
null,
null,
0,
null,
'N',
'N',
null,
30,
null,
:new.mnecode,
0,
null,
null,
null,
null,
null,
'Y',
100,
sysdate,
0);
end loop;
close bdcorp;
end;
end if; end addcust;

8

CREATE OR REPLACE TRIGGER "XMV502"."C_ACCBANK_NET"
before UPDATE on BD_ACCBANK
for each row
declare
-- local variables here
pk_bas bd_accbank.pk_accbank%type; cursor basjob(id varchar2) is
select pk_accbank from ncv5.bd_cubasdoc,ncv5.arap_djfb,ncv5.bd_cumandoc,ncv5.bd_accbank
where ncv5.arap_djfb.ksbm_cl = ncv5.bd_cumandoc.pk_cumandoc
and ncv5.bd_cumandoc.pk_cubasdoc = ncv5.bd_cubasdoc.pk_cubasdoc
and ncv5.bd_accbank.pk_accbank = ncv5.arap_djfb.skyhzh
and ncv5.arap_djfb.payflag in ('', '')
and pk_accbank=id; begin
open basjob(:new.pk_accbank);
loop
fetch basjob into pk_bas;
exit when basjob%notfound;
end loop;
close basjob;
if pk_bas is not null then
/* if :new.bankacc<>:old.bankacc or
:new.unitname<>:old.unitname*/
if utl_match.edit_distance_similarity(:old.bankacc,:new.bankacc)<'' or
utl_match.edit_distance_similarity(:old.unitname,:new.unitname)<''
then
raise_application_error(-20001,'注意:账户已成功付款,不能修改账号或单位名称!');
end if;
end if;
end;

9

CREATE OR REPLACE TRIGGER "XMV502"."C_ACCBANK_SPACE"
before insert or update on bd_accbank
for each row
declare
-- local variables here begin
if regexp_like(:new.bankacc,'[[:space:]]') or
regexp_like(:new.combineaccnum,'[[:space:]]') or
regexp_like(:new.unitname,'[[:space:]]')
or
(length(:new.combineaccnum) not in ('',''))
then
raise_application_error(-20001,'注意:银行账号、联行号或单位名称中有空格或联行号:' ||:new.combineaccnum ||'长度不正确!'); end if;
end ;

10

CREATE OR REPLACE TRIGGER "XMV502"."S_DELETE_CUSTBANK"

  before delete 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
and pk_custbank not in
(select bd_custbank.pk_custbank
from ncv5.arap_djfb, ncv5.bd_accbank, ncv5.bd_custbank
where bd_accbank.pk_accbank = arap_djfb.skyhzh
and bd_accbank.pk_accbank = bd_custbank.pk_accbank); begin /*判断数据是否在目标数据库存在*/ open basjob(:old.pk_custbank); loop fetch basjob into pk_bas;
/*dbms_output.put_line('pa_bas:'||pk_bas);*/
exit when basjob%notfound; end loop; close basjob; /******************************/ if pk_bas is not null then begin delete ncv5.bd_custbank /*目标数据库表*/ where pk_custbank = :old.pk_custbank; end;
else
raise_application_error(-20001,
:old.account || '已从网银付款,不能修改或删行,请取消!'); end if;
end S_DELETE_CUSTBANK;

11

CREATE OR REPLACE TRIGGER "XMV502"."S_INSERT_CUSTBANK"
before insert on bd_custbank
for each row
declare
pk_bas char(20);
vname varchar2(80);
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 null then begin
select custname
into vname
from bd_cubasdoc
where pk_cubasdoc = :new.pk_cubasdoc; /*and custprop=0; --只同步更新外部客商的“单位名称 ”*/ update bd_accbank
set combineaccnum = :new.memo,
unitname = vname,
city = :new.accaddr,
bankarea = :new.accaddr
where pk_accbank = :new.pk_accbank; insert into ncv5.bd_custbank /*目标数据库表*/
(pk_custbank,
pk_cubasdoc,
accname,
account,
accaddr,
defflag,
memo,
pk_accbank,
pk_corp,
pk_currtype,
ts,
dr)
values
(:new.pk_custbank,
:new.pk_cubasdoc,
:new.accname,
:new.account,
:new.accaddr,
:new.defflag,
:new.memo,
:new.pk_accbank,
:new.pk_corp,
:new.pk_currtype,
:new.ts,
:new.dr);
end; end if; end S_INSERT_CUSTBANK;

12

CREATE OR REPLACE TRIGGER "XMV502"."UPDATEBANK"
before update on bd_accbank
for each row
declare
-- local variables here
pk_bas char(20); cursor basjob(id char) is
select pk_accbank
from ncv5.bd_accbank /*目标数据库表*/
where pk_accbank = id
and nvl(dr, 0) = 0;
begin
/*判断数据是否在目标数据库存在*/
open basjob(:new.pk_accbank); loop fetch basjob
into pk_bas; exit when basjob%notfound; end loop;
close basjob;
/******************************/ if pk_bas is not null then
begin
update ncv5.bd_accbank /*目标数据库*/
set pk_corp = :new.pk_corp,
bankacc = :new.bankacc,
bankname = :new.bankname,
accopendate = :new.accopendate,
address = :new.address,
tel = :new.tel,
contactpsn = :new.contactpsn,
sealflag = :new.sealflag,
memo = :new.memo,
netbankflag = :new.netbankflag,
banktype = :new.banktype,
areacode = :new.areacode,
unitname = :new.unitname,
bankowner = :new.bankowner,
pk_settlecent = :new.pk_settlecent,
pk_settleunit = :new.pk_settleunit,
genebranprop = :new.genebranprop,
ctlprop = :new.ctlprop,
arapprop = :new.arapprop,
pk_accid = :new.pk_accid,
combineaccnum = :new.combineaccnum,
orgnumber = :new.orgnumber,
branchname = :new.branchname,
bankarea = :new.bankarea,
province = :new.province,
city = :new.city,
remcode = :new.remcode,
iscontrolled = :new.iscontrolled,
beginmny = :new.beginmny,
beginmnydate = :new.beginmnydate,
abcarea = :new.abcarea,
pk_createunit = :new.pk_createunit,
groupid = :new.groupid,
netqueryflag = :new.netqueryflag,
pk_currtype = :new.pk_currtype,
isautoreturn = :new.isautoreturn,
pk_accbank = :new.pk_accbank,
def2 = :new.def2,
def3 = :new.def3,
def4 = :new.def4,
def5 = :new.def5,
def1 = :new.def1,
custcode = :new.custcode,
groupaccount = :new.groupaccount,
signflag = :new.signflag,
ts = :new.ts,
dr = :new.dr
where pk_accbank = :new.pk_accbank;
end; end if;
end updateBank;

13

CREATE OR REPLACE TRIGGER "XMV502"."UPDATEBD_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 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 updatebd_custbank;

14

CREATE OR REPLACE TRIGGER "XMV502"."UPDATEBD_EARECL"
before update on bd_areacl
for each row
declare
-- local variables here
pk_bas char(20); cursor basjob(id char) is
select pk_areacl
from ncv5.bd_areacl /*目标数据库表*/
where pk_areacl = id
and nvl(dr, 0) = 0;
begin
/*判断数据是否在目标数据库存在*/
open basjob(:new.pk_areacl); loop fetch basjob
into pk_bas; exit when basjob%notfound; end loop;
close basjob;
/******************************/ if pk_bas is not null then
begin
update ncv5.bd_areacl /*目标数据库*/
set areaclcode = :new.areaclcode,
areaclname = :new.areaclname,
def1 = :new.def1,
def2 = :new.def2,
def3 = :new.def3,
def4 = :new.def4,
def5 = :new.def5,
dr = :new.dr,
mnecode = :new.mnecode,
pk_areacl = :new.pk_areacl,
pk_corp = :new.pk_corp,
pk_fatherarea = :new.pk_fatherarea,
ts = :new.ts
where pk_areacl = :new.pk_areacl;
end; end if;
end updatebde_arecl;

15

CREATE OR REPLACE TRIGGER "XMV502"."UPDCUST"
before update on bd_cubasdoc
for each row
declare
-- local variables here pk_bas char(20); /*查询目标公司是否存在基本档案*/
cursor basjob(id char) is
select pk_cubasdoc
from ncv5.bd_cubasdoc /*目标数据库表*/
where pk_cubasdoc = id
and nvl(dr, 0) = 0; begin
/*判断目标公司数据是否存在*/ /*判断目标公司数据是否存在*/
/* dbms_output.put_line('aaa');
select pk_cubasdoc into pk_bas from bd_cubasdoc1\*目标数据库表*\ where pk_cubasdoc=:new.pk_cubasdoc and nvl(dr,0)=0;*/
-- dbms_output.put_line('aaa');
open basjob(:new.pk_cubasdoc); loop fetch basjob
into pk_bas; exit when basjob%notfound; end loop;
close basjob;
dbms_output.put_line(:new.pk_cubasdoc);
if pk_bas is not null then
begin
update ncv5.bd_cubasdoc /*目标数据库表*/
set pk_cubasdoc = :new.pk_cubasdoc,
pk_corp = :new.pk_corp,
custcode = :new.custcode,
custname = :new.custname,
custshortname = :new.custshortname,
engname = :new.engname,
mnecode = :new.mnecode,
trade = :new.trade,
freecustflag = :new.freecustflag,
drpnodeflag = :new.drpnodeflag,
isconnflag = :new.isconnflag,
pk_cubasdoc1 = :new.pk_cubasdoc1,
custprop = :new.custprop,
pk_areacl = :new.pk_areacl,
pk_corp1 = :new.pk_corp1,
taxpayerid = :new.taxpayerid,
legalbody = :new.legalbody,
creditmny = :new.creditmny,
ecotypesincevfive = :new.ecotypesincevfive,
saleaddr = :new.saleaddr,
conaddr = :new.conaddr,
zipcode = :new.zipcode,
phone1 = :new.phone1,
phone2 = :new.phone2,
phone3 = :new.phone3,
fax1 = :new.fax1,
fax2 = :new.fax2,
linkman1 = :new.linkman1,
linkman2 = :new.linkman2,
linkman3 = :new.linkman3,
bp1 = :new.bp1,
bp2 = :new.bp2,
bp3 = :new.bp3,
mobilephone1 = :new.mobilephone1,
mobilephone2 = :new.mobilephone2,
mobilephone3 = :new.mobilephone3,
email = :new.email,
url = :new.url,
def1 = :new.def1,
def2 = :new.def2,
def3 = :new.def3,
def4 = :new.def4,
def5 = :new.def5,
def6 = :new.def6,
def7 = :new.def7,
def8 = :new.def8,
def9 = :new.def9,
def10 = :new.def10,
def11 = :new.def11,
def12 = :new.def12,
def13 = :new.def13,
def14 = :new.def14,
def15 = :new.def15,
def16 = :new.def16,
def17 = :new.def17,
def18 = :new.def18,
def19 = :new.def19,
def20 = :new.def20,
registerfund = :new.registerfund,
sealflag = :new.sealflag,
memo = :new.memo,
pk_pricegroup = :new.pk_pricegroup,
correspondunit = :new.correspondunit,
ts = :new.ts,
dr = :new.dr
where pk_cubasdoc = :new.pk_cubasdoc;
update ncv5.bd_cumandoc
set cmnecode = :new.mnecode
where pk_cubasdoc = :new.pk_cubasdoc;
end; end if;
end updCust;

16

CREATE OR REPLACE TRIGGER "XMV502"."UPDCUSTALL"
before update on bd_cubasdoc
for each row declare
netpk number(1);
begin
--将从网银付款客商写入变量netname
select count(distinct pk_cubasdoc)
into netpk
from ncv5.arap_djfb, ncv5.bd_cumandoc
where arap_djfb.ksbm_cl = bd_cumandoc.pk_cumandoc
and bd_cumandoc.pk_cubasdoc = :new.pk_cubasdoc
and arap_djfb.payflag in ('', ''); --找到已从网银付款客商
if netpk >'' then
if utl_match.edit_distance_similarity(:old.custname, :new.custname) < '' then
raise_application_error(-20001, '已成功付款,不可任意修改');
end if;
--没有从网银付款客商
else
if utl_match.edit_distance_similarity(:old.custname, :new.custname) < '' then
raise_application_error(-20001, '不可任意修改,请新增客商');
end if; end if;
end;