之前工作中做数据同步用到的触发器,做了如下笔记,总结如下:数据中心----------------------------------学院create or replace trigger tger_XX_YXSDWJBSJZL_istbefore insert on zfdxc.XX_YXSDWJBSJZLfor each rowbegininsert into xgxt.zxbz_xxbmdm@dblink_dxctoxgxt (bmdm,bmmc,bmjb,bmlb) values(:new.dwh,:new.dwmc,1,5);end;/create or replace trigger tger_XX_YXSDWJBSJZL_udtbefore update on zfdxc.XX_YXSDWJBSJZLfor each rowbeginupdate xgxt.zxbz_xxbmdm@dblink_dxctoxgxt set bmdm=:new.dwh,bmmc=:new.dwmc where bmdm=:old.dwh;end;/create or replace trigger tger_XX_YXSDWJBSJZL_delbefore delete on zfdxc.XX_YXSDWJBSJZLfor each rowbegindelete  zxbz_xxbmdm@dblink_dxctoxgxt where bmdm=:old.dwh;end;/create or replace trigger trig_xydmbtojwgl after INSERT OR DELETE OR UPDATEof dwh,dwmc ON xx_yxsdwjbsjzl FOR EACH ROWBEGIN   IF INSERTING THEN       insert into xydmb@dblink_dxctojwgl (xydm,xymc) values (:new.dwh,:new.dwmc);        insert into xydmb@dblink_dxctozfoa (xydm,xymc) values (:new.dwh,:new.dwmc);    ELSIF DELETING THEN      delete from  xydmb@dblink_dxctojwgl where xydm=:old.dwh;      delete from  xydmb@dblink_dxctozfoa where xydm=:old.dwh;         ELSIF UPDATING THEN      update xydmb@dblink_dxctojwgl set xydm=:new.dwh,xymc=:new.dwmc  where xydm=:old.dwh;      update xydmb@dblink_dxctozfoa set xydm=:new.dwh,xymc=:new.dwmc  where xydm=:old.dwh;   END IF;END;/-----------------------------------------专业create or replace trigger tger_jx_zyxxsjl_istbefore insert on zfdxc.jx_zyxxsjlfor each rowbegininsert into bks_zydm@dblink_dxctoxgxt (zydm,bmdm,zymc,zyjc,zyywmc) values(:new.zyh,:new.dwh,:new.zymc,:new.zyjc,:new.zyywmc);end;/create or replace trigger tger_jx_zyxxsjl_udtbefore update on zfdxc.jx_zyxxsjlfor each rowbeginupdate bks_zydm@dblink_dxctoxgxt set zydm=:new.zyh,bmdm=:new.dwh,zymc=:new.zymc,zyjc=:new.zyjc,zyywmc=:new.zyywmc where zydm=:old.zyh;end;/create or replace trigger tger_jx_zyxxsjl_delbefore delete on zfdxc.jx_zyxxsjlfor each rowbegindelete  bks_zydm@dblink_dxctoxgxt where zydm=:old.zyh;end;/---------------------------------------班级create or replace trigger tger_xx_bjsjl_istbefore insert on zfdxc.xx_bjsjlfor each rowbegininsert into bks_bjdm@dblink_dxctoxgxt (bjdm,zydm,bmdm,bjmc,nj) values (:new.bh,:new.zyh,:new.ssxydm,:new.bj,:new.nj);end;/create or replace trigger tger_xx_bjsjl_udtbefore update on zfdxc.xx_bjsjlfor each rowbeginupdate bks_bjdm@dblink_dxctoxgxt set bjdm=:new.bh,zydm=:new.zyh,bmdm=:new.ssxydm,bjmc=:new.bj,nj=:new.nj where bjdm=:old.bh;end;/create or replace trigger tger_xx_bjsjl_delbefore delete on zfdxc.xx_bjsjlfor each rowbegindelete  bks_bjdm@dblink_dxctoxgxt where bjdm=:old.bh;end;/---------教职工基础数据create or replace trigger trig_jzgjcsjzl_jsxxbafter insert or delete or update of jgh,dwh,xm,xbm,csrq,jg,mzm,whcdm,jzglbm,zwon jg_jzgjcsjzl for each rowdeclarev_bmmc varchar2(100);v_xb   dm_gb_rdxbdm.mc%type;v_mz   varchar2(10);v_whcdmc varchar2(10);v_jzglbmc varchar2(10);maxxh varchar2(100);kyyhbid varchar2(20);kyyhjbxxbid varchar2(20);BEGINif :new.sjly='教务' thennull;elsebegin       update kyglxtsequence@zfky_dblink set seqvalue=seqvalue + cachesize where seqname='SeqYHBID';      update kyglxtsequence@zfky_dblink set seqvalue=seqvalue + cachesize where seqname='SeqYHJBXXBID';      select seqvalue into kyyhbid from kyglxtsequence@zfky_dblink where seqname='SeqYHBID';      select seqvalue into kyyhjbxxbid from kyglxtsequence@zfky_dblink where seqname='SeqYHJBXXBID';end;begin     select dwmc into v_bmmc from xx_yxsdwjbsjzl where dwh=:new.dwh;exception    when others then      v_bmmc:='-9';end;begin     select mc into v_xb from dm_gb_rdxbdm where dm=:new.xbm;exception     when others then      v_xb:='-9';end;begin    select mc into v_mz from DM_GB_ZGGMZDLMZMPXFHDM where dm=:new.mzm;exception    when others then      v_mz:='-9';end;begin    select mc into v_whcdmc from DM_HB_WHCD where dm=:new.whcdm;exception    when others then      v_whcdmc:='-9';end;begin    select to_char(to_number(max(yhsx)) + 1) into maxxh from bmryxxb@dblink_dxctozfoa where xydm=:new.dwh;exception    when others then      maxxh:='-9';end;begin     select mc into v_jzglbmc from DM_HB_JZGLB where dm=:new.JZGLBM;exception    when others then      v_jzglbmc:='-9';end;if inserting then     insert into jsxxb@dblink_dxctojwgl(zgh,bm,xm,xb,csrq,jg,mz,xl,lbmc,sjly) values(:new.jgh,v_bmmc,:new.xm,v_xb,:new.csrq,:new.jg,v_mz,v_whcdmc,v_jzglbmc,'人事');     insert into bmryxxb@dblink_dxctozfoa(xydm,yhm,ryid,yhsx) values(:new.dwh,:new.jgh,bmryxx_ryid.nextval@dblink_dxctozfoa,maxxh);     insert into yhjbxxb@zfky_dblink(yhjbxxbid,xm,xbdmbid,jgdmbid,xzzw) values(kyyhjbxxbid,:new.xm,:new.xbm,:new.dwh,:new.zw);     insert into yhb@zfky_dblink(yhbid,yhm,mm,yhlybid,yhlyb,yhzt) values(kyyhbid,:new.jgh,'u',kyyhjbxxbid,'YHJBXXB','1');       elsif deleting  then     delete from jsxxb@dblink_dxctojwgl where zgh=:old.jgh;     delete from bmryxxb@dblink_dxctozfoa where yhm=:old.jgh;     delete from yhjbxxb@zfky_dblink where xm=:old.xm;     delete from yhb@zfky_dblink where yhm=:old.jgh;  elsif  updating then     update jsxxb@dblink_dxctojwgl set zgh=:new.jgh,bm=v_bmmc,xm=:new.xm,xb=v_xb,csrq=:new.csrq,jg=:new.jg,mz=v_mz,xl=v_whcdmc,lbmc=v_jzglbmc where zgh=:old.jgh;     update bmryxxb@dblink_dxctozfoa set xydm=:new.dwh,yhm=:new.jgh,yhsx=maxxh where yhm=:old.jgh;     update yhjbxxb@zfky_dblink set xm=:new.xm where xm=:old.xm;     update yhb@zfky_dblink set yhm=:new.jgh   where yhm=:old.jgh;  end if;end if;end;/create or replace trigger trig_jzgjcsjzl_portalyhbafter insert or delete or update of jgh,xmon jg_jzgjcsjzl for each rowBEGINif inserting then     insert into yhb@dblink_dxctoportal(yhm,kl,xm,yhlx) values(:new.jgh,'u',:new.xm,'2');  elsif deleting  then     delete from yhb@dblink_dxctoportal where yhm=:old.jgh;  elsif  updating then     update yhb@dblink_dxctoportal set yhm=:new.jgh,xm=:new.xm where yhm=:old.jgh;  end if;END;/create or replace trigger trig_jzgjcsjzl_zfoayhbafter insert or delete or update of jgh,xmon jg_jzgjcsjzl for each rowBEGINif inserting then     insert into yhb@dblink_dxctozfoa(yhm,kl,zdm,xm,yhlx) values(:new.jgh,'u','21',:new.xm,'2');  elsif deleting  then     delete from yhb@dblink_dxctozfoa where yhm=:old.jgh;  elsif  updating then     update yhb@dblink_dxctozfoa set yhm=:new.jgh,xm=:new.xm where yhm=:old.jgh;  end if;END;/create or replace trigger trig_zyjszw_jsxxb after insert or delete or update of przwm on jg_zyjszwzl for each rowdeclarev_przwmc varchar2(100);BEGINbegin   select zwxlmc into v_przwmc from dm_gb_zyjszwdm where dm=:new.przwm;exception      when others then      v_przwmc:='-9';end;     update jsxxb@dblink_dxctojwgl set zw=v_przwmc where zgh=:new.jgh;END;/create or replace trigger trig_zzmm_jsxxbafter insert or delete or updateof zzmmm on jg_zzmmsjl for each rowdeclarev_zzmmmc varchar2(100);BEGINbegin     select mc into v_zzmmmc from dm_gb_zzmmdm where dm=:new.zzmmm;exception    when others then      v_zzmmmc:='-9';end;     update jsxxb@dblink_dxctojwgl set zzmm=v_zzmmmc where zgh=:new.jgh;END;/----------------------------------------------学生create or replace trigger tger_xs_xsjbsjzl_istbefore insert on zfdxc.xs_xsjbsjzlfor each rowbegin----学工系统学生基本信息insert into xgxt.bks_xsjbxx@dblink_dxctoxgxt(xh,bmdm,bjdm,zydm,xm,xmpy,cym,pyfs,xz,rxny,nj,sfzh,xbm,xjztm,xxnx,zyfx,ksh,bz,mm) values(:new.xh,(case when :new.xymc in(select dwmc from XX_YXSDWJBSJZl) then (select dwh from XX_YXSDWJBSJZl where:new.xymc=dwmc ) else 'NU' end),(case when :new.bjmc in(select bj from xx_bjsjl) then (select bh fromxx_bjsjl where :new.bjmc=bj ) else 'NULL' end) ,(case when :new.zydm  is null then 'NULL' else:new.zydm end),:new.xm,:new.xmpy,:new.cym,:new.pyfs,:new.xz,:new.rxrq,:new.nj,:new.sfzjh,(case:new.xb when '男' then 1 when '女' then 2 else 0end),:new.xjzt,:new.xxnx,:new.zyfx,:new.ksh,:new.bz,:new.mm);----学工系统学生其他信息insert into xgxt.bks_xsqtxx@dblink_dxctoxgxt (xh,mzdm,hkszd,byzx,lydq,csrq) values(:new.xh,:new.mzm,:new.jg,:new.byzx,:new.lydq,:new.csrq);----学工系统学生密码表insert into xgxt.xsmmb@dblink_dxctoxgxt (xh,mm) values(:new.xh,:new.mm);end;/create or replace trigger tger_xs_xsjbsjzl_udtbefore update on zfdxc.xs_xsjbsjzlfor each rowbegin----学工系统学生基本信息update xgxt.bks_xsjbxx@dblink_dxctoxgxt set xh=:new.xh,bmdm=(case when :new.xymc in(select dwmc fromXX_YXSDWJBSJZl) then (select dwh from XX_YXSDWJBSJZl where :new.xymc=dwmc ) else 'NU' end),bjdm=(casewhen :new.bjmc in(select bj from xx_bjsjl) then (select bh from xx_bjsjl where :new.bjmc=bj ) else'NULL' end) ,zydm=(case when :new.zydm  is null then 'NULL' else :new.zydm end),xm=(case when :new.xmis null then 'NULL' else :new.xmend),xmpy=:new.xmpy,cym=:new.cym,pyfs=:new.pyfs,xz=:new.xz,rxny=:new.rxrq,nj=:new.nj,sfzh=:new.sfzjh,xbm=(case :new.xb when '男' then 1 when '女' then 2 else 0end),xjztm=:new.xjzt,xxnx=:new.xxnx,zyfx=:new.zyfx,ksh=:new.ksh,bz=:new.bz,mm=:new.mm wherexh=:old.xh;----学工系统学生其他信息update xgxt.bks_xsqtxx@dblink_dxctoxgxt setxh=:new.xh,mzdm=:new.mzm,hkszd=:new.jg,byzx=:new.byzx,lydq=:new.lydq,csrq=:new.csrq where xh=:old.xh;end;/create or replace trigger tger_xs_xsjbsjzl_delbefore delete on zfdxc.xs_xsjbsjzlfor each rowbegindelete xgxt.bks_xsjbxx@dblink_dxctoxgxt where xh=:old.xh;delete xgxt.bks_xsqtxx@dblink_dxctoxgxt where xh=:old.xh;delete xgxt.xsmmb@dblink_dxctoxgxt      where xh=:old.xh;end;/------------------------------------------------------------------------------------------------------------人事create or replace trigger trig_xydmbtozfdxc after INSERT OR DELETE OR UPDATEof code,info ON dm_def_org FOR EACH ROWBEGIN   IF INSERTING THEN       insert into xx_yxsdwjbsjzl@MEDI_DBLINK_zfdxc (dwh,dwmc) values (:new.code,:new.info);    ELSIF DELETING THEN     delete from  xx_yxsdwjbsjzl@MEDI_DBLINK_zfdxc where dwh=:old.code;   ELSIF UPDATING THEN      update xx_yxsdwjbsjzl@MEDI_DBLINK_zfdxc set dwh=:new.code,dwmc=:new.info  where dwh=:old.code;   END IF;END;/CREATE OR REPLACE TRIGGER trig_overall AFTER INSERT OR DELETE OR UPDATE--of X__STAFFID,X__NAME,X__NAMESPELL,X__OLDNAME,X__BIRTHDAY,X__SEX,X__NATIONALITY,X__NATION,X__NATIVEPLACE,X__BORNPLACE,X__IDCARD,X__WORKTIME,X__HEALTHSTATE,X__BLOODTYPE,X__COLONY,X__MARRIAGESTATE,X__ORIGIN,X__PERSONSTATION,X__FILENO,X__JOINCOLLEGETIME,X__ORG,X__EDUCATIONLEVEL,X__AUTHSORT,X__STAFFSORTON overall  FOR EACH ROWBEGIN   IF INSERTING THEN       insert into jg_jzgjcsjzl@MEDI_DBLINK_zfdxc(JGH,XM,XMPY,CYM,CSRQ,XBM,GJM,MZM,JG,CSDM,SFZJH,CJGZNY,JKZKM,XXM,GATQWM,HYZKM,JTCSM,BRCFM,DABH,LXRQ,DWH,WHCDM,BZLBM,JZGLBM,MM,xjxdm,zgxl,zgxw,rdsj,rzwsj) values (:new.X__STAFFID,:new.X__NAME,:new.X__NAMESPELL,:new.X__OLDNAME,:new.X__BIRTHDAY,:new.X__SEX,:new.X__NATIONALITY,:new.X__NATION,:new.X__NATIVEPLACE,:new.X__BORNPLACE,:new.X__IDCARD,:new.X__WORKTIME,:new.X__HEALTHSTATE,:new.X__BLOODTYPE,:new.X__COLONY,:new.X__MARRIAGESTATE,:new.X__ORIGIN,:new.X__PERSONSTATION,:new.X__FILENO,:new.X__JOINCOLLEGETIME,:new.X__ORG,:new.X__EDUCATIONLEVEL,:new.X__AUTHSORT,:new.X__STAFFSORT,'u',:new.X__FILENO,:new.X__EDUCATIONLEVEL,:new.X__DEGREE,:new.X__JOINDATE,:new.X__APPOINTDATE);       insert into JG_ZYJSZWZL@MEDI_DBLINK_zfdxc (JGH,RZZGMCM,PRZWM) values (:new.X__STAFFID,:new.X__MAJORQUALIFICATION,:new.X__APPOINTDUTY);       insert into JG_ZZMMSJL@MEDI_DBLINK_zfdxc (JGH,ZZMMM,CJRQ) values (:new.X__STAFFID,:new.X__POLITICS,:new.X__JOINDATE);   ELSIF DELETING THEN      delete from  jg_jzgjcsjzl@MEDI_DBLINK_zfdxc where jgh=:old.X__STAFFID;      delete from  JG_ZYJSZWZL@MEDI_DBLINK_zfdxc where jgh=:old.X__STAFFID;      delete from JG_ZZMMSJL@MEDI_DBLINK_zfdxc where jgh=:old.X__STAFFID;   ELSIF UPDATING THEN      update  jg_jzgjcsjzl@MEDI_DBLINK_zfdxc set JGH=:new.X__STAFFID,XM=:new.X__NAME,XMPY=:new.X__NAMESPELL,CYM=:new.X__OLDNAME,CSRQ=:new.X__BIRTHDAY,XBM=:new.X__SEX,GJM=:new.X__NATIONALITY,MZM=:new.X__NATION,JG=:new.X__NATIVEPLACE,CSDM=:new.X__BORNPLACE,SFZJH=:new.X__IDCARD,CJGZNY=:new.X__WORKTIME,JKZKM=:new.X__HEALTHSTATE,XXM=:new.X__BLOODTYPE,GATQWM=:new.X__COLONY,HYZKM=:new.X__MARRIAGESTATE,JTCSM=:new.X__ORIGIN,BRCFM=:new.X__PERSONSTATION,DABH=:new.X__FILENO,LXRQ=:new.X__JOINCOLLEGETIME,DWH=:new.X__ORG,WHCDM=:new.X__EDUCATIONLEVEL,BZLBM=:new.X__AUTHSORT,JZGLBM=:new.X__STAFFSORT,XJXDM=:new.X__FILENO,ZGXL=:new.X__EDUCATIONLEVEL,ZGXW=:new.X__DEGREE,RDSJ=:new.X__JOINDATE,RZWSJ=:new.X__APPOINTDATE where jgh=:old.X__STAFFID;      update JG_ZYJSZWZL@MEDI_DBLINK_zfdxc set JGH=:new.X__STAFFID,RZZGMCM=:new.X__MAJORQUALIFICATION,PRZWM=:new.X__APPOINTDUTY where jgh=:old.X__STAFFID;      update JG_ZZMMSJL@MEDI_DBLINK_zfdxc set JGH=:new.X__STAFFID,ZZMMM=:new.X__POLITICS,CJRQ=:new.X__JOINDATE where jgh=:old.X__STAFFID;   END IF;END;/--------------------------------------------------------------------------------------------------------------------教务---校区create or replace trigger tger_xqdm_istbefore insert on zfxfzb.xqdmbfor each rowbegininsert into xx_xqjbsjzl@dblink_jwgltodxc (xqh,xqm) values(:new.xqdm,:new.xqmc);end;/create or replace trigger tger_xqdm_udtbefore update on zfxfzb.xqdmbfor each rowbeginupdate xx_xqjbsjzl@dblink_jwgltodxc  set xqh=:new.xqdm,xqm=:new.xqmc where xqh=:old.xqdm;end;/create or replace trigger tger_xqdm_delbefore delete on zfxfzb.xqdmbfor each rowbegindelete  xx_xqjbsjzl@dblink_jwgltodxc where xqh=:old.xqdm;end;---专业create or replace trigger tger_zydm_istbefore insert on zfxfzb.zydmbfor each rowbegininsert into jx_zyxxsjl@dblink_jwgltodxc (zyh,zymc,zyjc,zyywmc,dwh,xz,bzkzym) values(:new.zydm,:new.zymc,:new.zyjc,:new.zyywmc,:new.ssxydm,:new.xz,:new.tjzydm);end;/create or replace trigger tger_zydm_udtbefore update on zfxfzb.zydmbfor each rowbeginupdate jx_zyxxsjl@dblink_jwgltodxc  set zyh=:new.zydm,zymc=:new.zymc,zyjc=:new.zyjc,zyywmc=:new.zyywmc,dwh=:new.ssxydm,xz=:new.xz,bzkzym=:new.ssxydm where zyh=:old.zydm;end;/create or replace trigger tger_zydm_delbefore delete on zfxfzb.zydmbfor each rowbegindelete  jx_zyxxsjl@dblink_jwgltodxc where zyh=:old.zydm;end;/---班级create or replace trigger tger_bjdm_istbefore insert on zfxfzb.bjdmbfor each rowbegininsert into xx_bjsjl@dblink_jwgltodxc (bh,bj,bzrjgh,fdyh,zyh,bjjc,zyfx,ssxydm,nj,ssxqdm,xz,cc) values(:new.bjdm,:new.bjmc,:new.bzrzgh,:new.fdyxm,:new.sszydm,:new.bjjc,:new.zyfx,:new.ssxydm,:new.nj,:new.ssxqdm,:new.xz,:new.cc);end;/create or replace trigger tger_bjdm_udtbefore update on zfxfzb.bjdmbfor each rowbeginupdate xx_bjsjl@dblink_jwgltodxc  set bh=:new.bjdm,bj=:new.bjmc,bzrjgh=:new.bzrzgh,fdyh=:new.fdyxm,zyh=:new.sszydm,bjjc=:new.bjjc,zyfx=:new.zyfx,ssxydm=:new.ssxydm,nj=:new.nj,ssxqdm=:new.ssxqdm,xz=:new.xz,cc=:new.cc where bh=:old.bjdm;end;/create or replace trigger tger_bjdm_delbefore delete on zfxfzb.bjdmbfor each rowbegindelete  xx_bjsjl@dblink_jwgltodxc where bh=:old.bjdm;end;/--学生create or replace trigger tger_xsjbxx_istbefore insert on zfxfzb.xsjbxxbfor each rowdeclarev_bjdm varchar2(50);v_xydm varchar2(50);beginbeginselect xydm into v_xydm from xydmb where xymc=:new.xy;exception   when others then   v_xydm:='9';end;beginselect bjdm into v_bjdm from bjdmb where bjmc=:new.xzb;exception   when others then   v_bjdm:='9';end;----数据中心学生基本数据子类insert into zfdxc.xs_xsjbsjzl@dblink_jwgltodxc(xh,xm,xmpy,cym,csrq,jg,sfzjh,xymc,zydm,zymc,bjmc,mz,pyfs,ksh,xxnx,xz,xb,zyfx,pyfx,xjzt,sfzx,sfzc,bz,nj,rxrq,LYDQ,BYZX,SSH,DZYXDZ,LXDH,ZKZH,JTSZD,SFLXS,TELNUMBER,TELLX,CC,YZBM,RXZF,YYCJ,zzmm,mm) values(:new.xh,:new.xm,:new.xmpy,:new.zym,:new.csrq,:new.jg,:new.sfzh,:new.xy,:new.zydm,:new.zymc,:new.xzb,:new.mz,:new.xxxs,:new.ksh,:new.xxnx,:new.xz,:new.xb,:new.zyfx,:new.pyfx,:new.xjzt,:new.sfzx,:new.sfzc,:new.bz,:new.dqszj,:new.rxrq,:new.LYDQ,:new.BYZX,:new.SSH,:new.DZYXDZ,:new.LXDH,:new.ZKZH,:new.JTSZD,:new.SFLXS,:new.TELNUMBER,:new.TELLX,:new.CC,:new.YZBM,:new.RXZF,:new.YYCJ,:new.zzmm,:new.mm);----数据中心学籍基本数据子类insert into zfdxc.xs_xjjbsjzl@dblink_jwgltodxc (xh,yxsh,zym,bh) values(:new.xh,v_xydm,:new.zydm,v_bjdm);end;/create or replace trigger tger_xsjbxx_udtbefore update on zfxfzb.xsjbxxbfor each rowdeclarev_bjdm varchar2(50);v_xydm varchar2(50);begin----数据中心学生基本数据子类beginselect xydm into v_xydm from xydmb where xymc=:new.xy;exception   when others then   v_xydm:='9';end;beginselect bjdm into v_bjdm from bjdmb where bjmc=:new.xzb;exception   when others then   v_bjdm:='9';end;update xs_xsjbsjzl@dblink_jwgltodxc  set xh=:new.xh,xm=:new.xm,xmpy=:new.xmpy,cym=:new.zym,csrq=:new.csrq,jg=:new.jg,sfzjh=:new.sfzh,xymc=:new.xy,zydm=:new.zydm,zymc=:new.zymc,bjmc=:new.xzb,mz=:new.mz,pyfs=:new.xxxs,ksh=:new.ksh,xxnx=:new.xxnx,xz=:new.xz,xb=:new.xb,zyfx=:new.zyfx,pyfx=:new.pyfx,xjzt=:new.xjzt,sfzx=:new.sfzx,sfzc=:new.sfzc,bz=:new.bz,nj=:new.dqszj,rxrq=:new.rxrq,lydq=:new.LYDQ,byzx=:new.BYZX,ssh=:new.SSH,dzyxdz=:new.DZYXDZ,lxdh=:new.LXDH,zkzh=:new.ZKZH,jtszd=:new.JTSZD,sflxs=:new.SFLXS,TELNUMBER=:new.TELNUMBER,TELLX=:new.TELLX,cc=:new.CC,YZBM=:new.YZBM,RXZF=:new.RXZF,YYCJ=:new.YYCJ,zzmm=:new.zzmm,mm=:new.mm where xh=:old.xh;----数据中心学籍基本数据子类update xs_xjjbsjzl@dblink_jwgltodxc  set xh=:new.xh,yxsh=v_xydm,zym=:new.zydm,bh=v_bjdm where xh=:old.xh;end;/create or replace trigger tger_xsjbxx_delbefore delete on zfxfzb.xsjbxxbfor each rowbegindelete  xs_xsjbsjzl@dblink_jwgltodxc where xh=:old.xh;delete  xs_xjjbsjzl@dblink_jwgltodxc where xh=:old.xh;end;/--外聘教师create or replace trigger trig_wpjs_zfdxc after insert or delete or update of zgh,xm,bm on jsxxb for each rowdeclarev_bmdm varchar2(10);len number;beginselect count(jgh) into len from jg_jzgjcsjzl@dblink_jwgltodxc where jgh=:old.zgh and sjly='人事';if len=0 and :new.sjly||'A''人事A' then--不存在人事的数据begin  select xydm into v_bmdm from xydmb where xymc=:new.bm;exception    when others then      v_bmdm:='-9';end;  if inserting then    insert into jg_jzgjcsjzl@dblink_jwgltodxc(jgh,xm,dwh,sjly) values(:new.zgh,:new.xm,v_bmdm,'教务');  elsif deleting  then    delete from jg_jzgjcsjzl@dblink_jwgltodxc where jgh=:old.zgh;  elsif  updating then    update jg_jzgjcsjzl@dblink_jwgltodxc set jgh=:new.zgh,xm=:new.xm,dwh=v_bmdm where jgh=:old.zgh;  end if;end if;end;/**********本博客所有内容均为原创,如有转载请注明作者和出处!!!**********QQ: 252803295Email:[email protected]尖峰官网:http://www.jianfengedu.com尖峰淘宝:http://jianfengedu.taobao.comWEIBO:http://weibo.com/guoyJoe0218尖峰OCP认证考试群297227448 尖峰OCM认证考试群99606943尖峰MySQL研究院群314746420尖峰JAVA研究院群315405063  尖峰Hadoop研究院群366294602尖峰线上技术分享群252296815尖峰SQL优化研究院群250057366
12-14 13:11