大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

工作中使用了一些触发器

之前工作中做数据同步用到的触发器,做了如下笔记,总结如下:

成都创新互联公司专注于钟楼网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供钟楼营销型网站建设,钟楼网站制作、钟楼网页设计、钟楼网站官网定制、微信平台小程序开发服务,打造钟楼网络公司原创品牌,更为您提供钟楼网站排名全网营销落地服务。

数据中心

----------------------------------学院
create or replace trigger tger_XX_YXSDWJBSJZL_ist
before insert on zfdxc.XX_YXSDWJBSJZL
for each row
begin
insert 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_udt
before update on zfdxc.XX_YXSDWJBSJZL
for each row
begin
update xgxt.zxbz_xxbmdm@dblink_dxctoxgxt set bmdm=:new.dwh,bmmc=:new.dwmc where bmdm=:old.dwh;
end;
/
create or replace trigger tger_XX_YXSDWJBSJZL_del
before delete on zfdxc.XX_YXSDWJBSJZL
for each row
begin
delete  zxbz_xxbmdm@dblink_dxctoxgxt where bmdm=:old.dwh;
end;
/
create or replace trigger trig_xydmbtojwgl after INSERT OR DELETE OR UPDATE
of dwh,dwmc ON xx_yxsdwjbsjzl FOR EACH ROW
BEGIN
   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_ist
before insert on zfdxc.jx_zyxxsjl
for each row
begin
insert 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_udt
before update on zfdxc.jx_zyxxsjl
for each row
begin
update 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_del
before delete on zfdxc.jx_zyxxsjl
for each row
begin
delete  bks_zydm@dblink_dxctoxgxt where zydm=:old.zyh;
end;
/
---------------------------------------班级
create or replace trigger tger_xx_bjsjl_ist
before insert on zfdxc.xx_bjsjl
for each row
begin
insert 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_udt
before update on zfdxc.xx_bjsjl
for each row
begin
update 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_del
before delete on zfdxc.xx_bjsjl
for each row
begin
delete  bks_bjdm@dblink_dxctoxgxt where bjdm=:old.bh;
end;
/


---------教职工基础数据
create or replace trigger trig_jzgjcsjzl_jsxxb
after insert or delete or update of jgh,dwh,xm,xbm,csrq,jg,mzm,whcdm,jzglbm,zw
on jg_jzgjcsjzl for each row
declare
v_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);
BEGIN
if :new.sjly='教务' then
null;
else
begin 
      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_portalyhb
after insert or delete or update of jgh,xm
on jg_jzgjcsjzl for each row
BEGIN
if 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_zfoayhb
after insert or delete or update of jgh,xm
on jg_jzgjcsjzl for each row
BEGIN
if 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 row
declare
v_przwmc varchar2(100);
BEGIN
begin
   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_jsxxb
after insert or delete or update
of zzmmm on jg_zzmmsjl for each row
declare
v_zzmmmc varchar2(100);
BEGIN
begin
     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_ist
before insert on zfdxc.xs_xsjbsjzl
for each row
begin
----学工系统学生基本信息
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 from
xx_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 0
end),: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_udt
before update on zfdxc.xs_xsjbsjzl
for each row
begin
----学工系统学生基本信息
update xgxt.bks_xsjbxx@dblink_dxctoxgxt set xh=:new.xh,bmdm=(case when :new.xymc in(select dwmc from
XX_YXSDWJBSJZl) then (select dwh from XX_YXSDWJBSJZl where :new.xymc=dwmc ) else 'NU' end),bjdm=(case
when :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.xm
is null then 'NULL' else :new.xm
end),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 0
end),xjztm=:new.xjzt,xxnx=:new.xxnx,zyfx=:new.zyfx,ksh=:new.ksh,bz=:new.bz,mm=:new.mm where
xh=:old.xh;
----学工系统学生其他信息
update xgxt.bks_xsqtxx@dblink_dxctoxgxt set
xh=: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_del
before delete on zfdxc.xs_xsjbsjzl
for each row
begin
delete 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 UPDATE
of code,info ON dm_def_org FOR EACH ROW
BEGIN
   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__STAFFSORT
ON overall  FOR EACH ROW
BEGIN
   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_ist
before insert on zfxfzb.xqdmb
for each row
begin
insert into xx_xqjbsjzl@dblink_jwgltodxc (xqh,xqm) values(:new.xqdm,:new.xqmc);
end;
/
create or replace trigger tger_xqdm_udt
before update on zfxfzb.xqdmb
for each row
begin
update xx_xqjbsjzl@dblink_jwgltodxc  set xqh=:new.xqdm,xqm=:new.xqmc where xqh=:old.xqdm;
end;
/
create or replace trigger tger_xqdm_del
before delete on zfxfzb.xqdmb
for each row
begin
delete  xx_xqjbsjzl@dblink_jwgltodxc where xqh=:old.xqdm;
end;
---专业
create or replace trigger tger_zydm_ist
before insert on zfxfzb.zydmb
for each row
begin
insert 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_udt
before update on zfxfzb.zydmb
for each row
begin
update 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_del
before delete on zfxfzb.zydmb
for each row
begin
delete  jx_zyxxsjl@dblink_jwgltodxc where zyh=:old.zydm;
end;
/
---班级
create or replace trigger tger_bjdm_ist
before insert on zfxfzb.bjdmb
for each row
begin
insert 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_udt
before update on zfxfzb.bjdmb
for each row
begin
update 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_del
before delete on zfxfzb.bjdmb
for each row
begin
delete  xx_bjsjl@dblink_jwgltodxc where bh=:old.bjdm;
end;
/
--学生
create or replace trigger tger_xsjbxx_ist
before insert on zfxfzb.xsjbxxb
for each row

declare
v_bjdm varchar2(50);
v_xydm varchar2(50);
begin
begin
select xydm into v_xydm from xydmb where xymc=:new.xy;
exception
   when others then
   v_xydm:='9';
end;
begin
select 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_udt
before update on zfxfzb.xsjbxxb
for each row

declare
v_bjdm varchar2(50);
v_xydm varchar2(50);
begin
----数据中心学生基本数据子类
begin
select xydm into v_xydm from xydmb where xymc=:new.xy;
exception
   when others then
   v_xydm:='9';
end;
begin
select 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_del
before delete on zfxfzb.xsjbxxb
for each row
begin
delete  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 row

declare
v_bmdm varchar2(10);
len number;
begin
select 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;

/




**********本博客所有内容均为原创,如有转载请注明作者和出处!!!**********
Name:    guoyJoe

QQ:        252803295

Email:    oracledba_cn@hotmail.com

Blog:      http://blog.csdn.net/guoyJoe

ITPUB:   http://www.itpub.net/space-uid-28460966.html

OCM:     http://education.oracle.com/education/otn/YGuo.HTM
 _____________________________________________________________
加群验证问题:哪些SGA结构是必需的,哪些是可选的?否则拒绝申请!!!

答案在:http://blog.csdn.net/guoyjoe/article/details/8624392

Oracle@Paradise  总群:127149411

Oracle@Paradise No.1群:177089463(已满)

Oracle@Paradise No.2群:121341761

Oracle@Paradise No.3群:140856036



分享标题:工作中使用了一些触发器
文章出自:http://dzwzjz.com/article/jcsgjj.html
在线咨询
服务热线
服务热线:028-86922220
TOP