存储过程系列五:完整的存储过程备份使用函数REPLACE()substr()

CREATE OR REPLACE PROCEDURE "YLQXSCXKESL_GGXKZ_TO_QB" (
                                              xkzbh_idIn in varchar2,
                                              bgid_idIn in varchar2,
                                              fzrqIn in varchar2,
                                              yxqzIn in varchar2,
                                              flag   out varchar2) is


v_raise EXCEPTION ;
  V_sqid_q  VARCHAR2(32);
  V_sqid_h  VARCHAR2(32);
  V_xkzbh    VARCHAR2(100);
  V_qbid     VARCHAR2(32);
  V_fzrqIn   VARCHAR2(8);
  V_yxqzIn   VARCHAR2(8);

  V_QYMC    INTEGER;
  V_ZS      INTEGER;
 -- V_ryxx    INTEGER; --人员信息
  --V_FDDBR   INTEGER;
  --V_QYFZR   INTEGER;
  V_ryxx1    INTEGER; --法定代表人人员信息
  V_ryxx2    INTEGER; --企业负责人人员信息
  V_SCFW    INTEGER;

 -- V_QYSCDZ  INTEGER;
  V_QYSCDZ1  INTEGER; -- SCDZFWZXBG
  V_QYSCDZ2  INTEGER; -- SCDZWZXBG

 -- V_SCCP    INTEGER;
  V_SCCP1    INTEGER;-- JSSCCP
  V_SCCP2    INTEGER;-- ZJSSCCP

  V_BS    INTEGER;  -- 0 长流程
                    -- 1 短流程

  V_FRXGZM          INTEGER;
  V_FZRXGZM         INTEGER;

  V_length        INTEGER;         -- 求长度
  V_name2         VARCHAR2(100);   -- 用于存储替换后的字段信息
begin

  ----------------更新------医疗器械生产许可证-----------真实数据  状态------结束--------------
  select t.sqid into V_sqid_q from gg_xkz_ylqxscxkesl t where xkzbh = xkzbh_idIn  and czzt = 'V' and xkzzt = '0'; -- 查询出许可证表中 元数据为V的状态的ID  V_xkzid_q 表示原来的ID
  select t.sqid into V_sqid_h from gg_xkz_ylqxscxkesl t where xkzbh = xkzbh_idIn  and czzt = 'T' and xkzzt = '0' and sqid = bgid_idIn; -- 查询出许可证表中 元数据为T的状态的ID  V_xkzid_h 表示插入后的ID
  select  fzrqIn  into V_fzrqIn from dual;
  select  yxqzIn  into V_yxqzIn from dual;

  -- 定义变更变量
  select  0  into V_BS from dual;

  update GG_XKZ_YLQXSCXKESL set DZRQ=to_char(sysdate, 'yyyyMMdd')  where sqid=V_sqid_h;

 -- select  t.xkzbh into V_xkzbh from gg_xkz_ylqxscxkesl t where xkzbh = xkzbh_idIn  and czzt = 'V' and xkzzt = '0'; -- 查询出许可证表中 元数据为V的状态的ID  V_xkzid_q 表示原来的ID
  select  t.xkzbh into V_xkzbh from gg_xkz_ylqxscxkesl t where xkzbh = xkzbh_idIn and czzt = 'V'; -- 查询出许可证表中 许可证编号作为唯一条件
  update gg_xkz_ylqxscxkesl  set   czzt = 'I' where  sqid = V_sqid_q  and czzt = 'V' ;
  update gg_xkz_ylqxscxkesl  set   czzt = 'V' where  sqid = V_sqid_h  and czzt = 'T' ;

  -- 根据修改证面信息 更新人员法定代表人和企业负责人(后加)
  --判断法人是否被修改
  select count(1) into V_FRXGZM from GG_XKZ_YLQXSCXKESL_RYXX r where r.xm=(
      select g.fddbr from GG_XKZ_YLQXSCXKESL g where g.sqid = V_sqid_h
  ) and r.sqid = V_sqid_h and r.rylx = '0';

  --判断负责人是否被修改
  select count(1) into V_FZRXGZM from GG_XKZ_YLQXSCXKESL_RYXX r where r.xm=(
      select g.qyfzr from GG_XKZ_YLQXSCXKESL g where g.sqid = V_sqid_h
  ) and r.sqid = V_sqid_h and r.rylx = '1';

  if V_FRXGZM = 0 then
    update GG_XKZ_YLQXSCXKESL_RYXX set XM = ( select FDDBR from GG_XKZ_YLQXSCXKESL  where sqid = V_sqid_h )  where sqid = V_sqid_h and rylx = '0' ;
  end if;

  if V_FZRXGZM = 0 then
     update GG_XKZ_YLQXSCXKESL_RYXX set XM = ( select QYFZR from GG_XKZ_YLQXSCXKESL  where sqid = V_sqid_h )  where sqid = V_sqid_h and rylx = '1' ;
  end if;

 ----------------更新------医疗器械生产许可证-----------真实数据  状态--------结束-------------

 ----------------插入------医疗器械生产许可信息全表------------------开始-------------

 -- 查询出全表ID 根据xkzbh 字段查出全表ID 用于操作子表
 -- select qbid into V_qbid from xzxk_ylqxscxkesl_xx_qb qb where  qb.xkzbh = V_xkzbh  and czzt = 'V';
  select qbid into V_qbid from xzxk_ylqxscxkesl_xx_qb qb where  qb.xkzbh = V_xkzbh  ;
        SELECT COUNT(t.SQBGSXDM)
          into V_QYMC
          FROM XZXK_YLQXSCXKESL_BG_SX t
         where t.SQBGSXDM = 'QYMC'
           AND t.sqid = bgid_idIn;

        SELECT COUNT(t.SQBGSXDM)
          into V_ZS
          FROM XZXK_YLQXSCXKESL_BG_SX t
         where t.SQBGSXDM = 'ZS'
           AND t.sqid = bgid_idIn;

        SELECT COUNT(t.SQBGSXDM)
          into V_ryxx1
          FROM XZXK_YLQXSCXKESL_BG_SX t
         where t.SQBGSXDM = 'FDDBR'
           AND t.sqid = bgid_idIn;

        SELECT COUNT(t.SQBGSXDM)
          into V_ryxx2
          FROM XZXK_YLQXSCXKESL_BG_SX t
         where  t.SQBGSXDM = 'QYFZR'
           AND t.sqid = bgid_idIn;

        SELECT COUNT(t.SQBGSXDM)
          into V_SCFW
          FROM XZXK_YLQXSCXKESL_BG_SX t
         where t.SQBGSXDM = 'SCFW'
           AND t.sqid = bgid_idIn;

        SELECT COUNT(t.SQBGSXDM)
          into V_QYSCDZ1
          FROM XZXK_YLQXSCXKESL_BG_SX t
         where t.SQBGSXDM = 'SCDZFWZXBG'
           AND t.sqid = bgid_idIn;  --  长

        SELECT COUNT(t.SQBGSXDM)
          into V_QYSCDZ2
          FROM XZXK_YLQXSCXKESL_BG_SX t
         where  t.SQBGSXDM = 'SCDZWZXBG' -- 短
           AND t.sqid = bgid_idIn;


        SELECT COUNT(t.SQBGSXDM)
          into V_SCCP1
          FROM XZXK_YLQXSCXKESL_BG_SX t
         where t.SQBGSXDM = 'JSSCCP'   -- 短
           AND t.sqid = bgid_idIn;


        SELECT COUNT(t.SQBGSXDM)
          into V_SCCP2
          FROM XZXK_YLQXSCXKESL_BG_SX t
         where  t.SQBGSXDM = 'ZJSCCP' --长
           AND t.sqid = bgid_idIn;

  -- 更新全表信息
  -- 更新企业名称

   if V_QYMC > 0 then
    update xzxk_ylqxscxkesl_xx_qb
     set( qymc , sqid ) =
     ( select qymc, bgid_idIn from GG_XKZ_YLQXSCXKESL where sqid = V_sqid_h and czzt = 'V')
     where qbid = V_qbid ;

     select 1 into V_BS from dual ;
    else
        update  xzxk_ylqxscxkesl_xx_qb set  sqid  = V_sqid_h  where QBID = V_qbid ;
    end if;
  -- where xkzbh = V_xkzbh;

--更新全表住所
          SELECT COUNT(t.SQBGSXDM)
          into V_ZS
          FROM XZXK_YLQXSCXKESL_BG_SX t
         where t.SQBGSXDM = 'ZS'
           AND t.sqid = V_sqid_h;


          if V_ZS>0 then
          update xzxk_ylqxscxkesl_xx_qb
             set (ZSDZQX, ZSDZJD, ZSDZ, ZSYB, ZSDH) =
                 (select ZSQX, ZSJD, ZSDZ, ZSYB, ZSDH
                    from xzxk_ylqxscxkesl_bg_zs z
                   where z.sqid = V_sqid_h and z.bgqhbs='2')  where qbid = V_qbid ;

          select 1 into V_BS from dual ;
          end if;

--更新全表生产范围
          SELECT COUNT(t.SQBGSXDM)
          into V_SCFW
          FROM XZXK_YLQXSCXKESL_BG_SX t
         where t.SQBGSXDM = 'SCFW'
           AND t.sqid = V_sqid_h;


          if V_SCFW > 0 then
          update xzxk_ylqxscxkesl_xx_qb
             set SCFW =
                 (select SCFW from xzxk_ylqxscxkesl_bg_sq z where z.sqid = V_sqid_h)  where qbid = V_qbid ;

          select 1 into V_BS from dual ;
          end if;

--更新生产地址  -- 长流程V_BS  不赋值
        SELECT COUNT(t.SQBGSXDM)
        into V_QYSCDZ1
        FROM XZXK_YLQXSCXKESL_BG_SX t
       where ( t.SQBGSXDM = 'SCDZFWZXBG')
         AND t.sqid = V_sqid_h;

        if V_QYSCDZ1 > 0 then
            update xzxk_ylqxscxkesl_xx_qb
               set (SCDZ, SCDZYB, SCDZDH) =
                   (select wm_concat(JTDZ), wm_concat(YB), wm_concat(LXDH)
                    from xzxk_ylqxscxkesl_bg_scdz z
                   where z.sqid = V_sqid_h and z.bgqhbs = '2')  where qbid = V_qbid ;
        end if;


        SELECT COUNT(t.SQBGSXDM)
        into V_QYSCDZ2
        FROM XZXK_YLQXSCXKESL_BG_SX t
       where ( t.SQBGSXDM = 'SCDZWZXBG')
         AND t.sqid = V_sqid_h;

        if V_QYSCDZ2 > 0 then
            update xzxk_ylqxscxkesl_xx_qb
               set (SCDZ, SCDZYB, SCDZDH) =
                   (select wm_concat(JTDZ), wm_concat(YB), wm_concat(LXDH)
                    from xzxk_ylqxscxkesl_bg_scdz z
                   where z.sqid = V_sqid_h and z.bgqhbs = '2')  where qbid = V_qbid ;

            select 1 into V_BS from dual ;
        end if;


   --1.1.2 住所
    if V_ZS > 0 then
    INSERT INTO PUB_TABLE_DATA_DELEXC(ID, TABLENAME, TABLEPKNAME, TABLEPK, DELFLAG, INSTNUM, LASTDATE, DATEXC)
          select sys_guid(), 'XZXK_YLQXSCXKESL_XX_ZS', 'BZJ', BZJ as TABLEPK, 'N', f_getslbs(), sysdate, '11' from XZXK_YLQXSCXKESL_XX_ZS where qbid = V_qbid;

        delete XZXK_YLQXSCXKESL_XX_ZS where qbid = V_qbid;
        insert into XZXK_YLQXSCXKESL_XX_ZS
          (bzj,   QBID,   sqid, zsqx, zsjd, zsdz, zsyb, zsdh, instnum, lastdate, datexc)
        select
      sys_guid(), V_qbid, sqid, zsqx, zsjd, zsdz, zsyb, zsdh, f_getslbs(),sysdate,'11'
          from GG_XKZ_YLQXSCXKESL_ZS
          where  sqid = V_sqid_h ;
     select 1 into V_BS from dual ;
    else
        update  XZXK_YLQXSCXKESL_XX_ZS set  sqid  = V_sqid_h  where QBID = V_qbid ;
    end if;
  --1.1.3 人员信息
    if V_ryxx1 > 0 then
    INSERT INTO PUB_TABLE_DATA_DELEXC(ID, TABLENAME, TABLEPKNAME, TABLEPK, DELFLAG, INSTNUM, LASTDATE, DATEXC)
          select sys_guid(), 'XZXK_YLQXSCXKESL_XX_RYXX', 'BZJ', BZJ as TABLEPK, 'N', f_getslbs(), sysdate, '11' from XZXK_YLQXSCXKESL_XX_RYXX where qbid = V_qbid;

        delete XZXK_YLQXSCXKESL_XX_RYXX where qbid = V_qbid and rylx = '0';
        insert into XZXK_YLQXSCXKESL_XX_RYXX
         (bzj,    QBID,    sqid, rylx, xm, zjlx, zjhm, zc, zw, xl, instnum, lastdate, datexc)
        select
      sys_guid(), V_qbid,  sqid, rylx, xm, zjlx, zjhm, zc, zw, xl, f_getslbs(),sysdate,'11'
          from GG_XKZ_YLQXSCXKESL_RYXX
          where sqid = V_sqid_h and rylx = '0';
        select 1 into V_BS from dual ;
    else
        update  XZXK_YLQXSCXKESL_XX_RYXX set  sqid  = V_sqid_h  where QBID = V_qbid and rylx = '0';
    end if;

    if V_ryxx2 > 0 then
    INSERT INTO PUB_TABLE_DATA_DELEXC(ID, TABLENAME, TABLEPKNAME, TABLEPK, DELFLAG, INSTNUM, LASTDATE, DATEXC)
          select sys_guid(), 'XZXK_YLQXSCXKESL_XX_RYXX', 'BZJ', BZJ as TABLEPK, 'N', f_getslbs(), sysdate, '11' from XZXK_YLQXSCXKESL_XX_RYXX where qbid = V_qbid;

        delete XZXK_YLQXSCXKESL_XX_RYXX where qbid = V_qbid and rylx = '1';
        insert into XZXK_YLQXSCXKESL_XX_RYXX
         (bzj,    QBID,    sqid, rylx, xm, zjlx, zjhm, zc, zw, xl, instnum, lastdate, datexc)
        select
      sys_guid(), V_qbid,  sqid, rylx, xm, zjlx, zjhm, zc, zw, xl, f_getslbs(),sysdate,'11'
          from GG_XKZ_YLQXSCXKESL_RYXX
          where sqid = V_sqid_h and rylx = '1';
        select 1 into V_BS from dual ;
    else
        update  XZXK_YLQXSCXKESL_XX_RYXX set  sqid  = V_sqid_h  where QBID = V_qbid and rylx = '1';
    end if;


  --1.1.4 生产地址信息
     if V_QYSCDZ1 > 0 then
    INSERT INTO PUB_TABLE_DATA_DELEXC(ID, TABLENAME, TABLEPKNAME, TABLEPK, DELFLAG, INSTNUM, LASTDATE, DATEXC)
          select sys_guid(), 'XZXK_YLQXSCXKESL_XX_SCDZ', 'BZJ', BZJ as TABLEPK, 'N', f_getslbs(), sysdate, '11' from XZXK_YLQXSCXKESL_XX_SCDZ where qbid = V_qbid;

            delete XZXK_YLQXSCXKESL_XX_SCDZ where qbid = V_qbid;
              insert into XZXK_YLQXSCXKESL_XX_SCDZ
               (bzj,  QBID,   sqid, jtdz, gb, szsf, szqx, szjd, lxr, lxdh, yb, dzyx, instnum, lastdate, datexc)
              select
          sys_guid(), V_qbid, sqid, jtdz, gb, szsf, szqx, szjd, lxr, lxdh, yb, dzyx, f_getslbs(),sysdate,'11'
                from GG_XKZ_YLQXSCXKESL_SCDZ
                where sqid = V_sqid_h ;
    else
        update  XZXK_YLQXSCXKESL_XX_SCDZ set  sqid  = V_sqid_h  where QBID = V_qbid ;
    end if;

     if V_QYSCDZ2 > 0 then
    INSERT INTO PUB_TABLE_DATA_DELEXC(ID, TABLENAME, TABLEPKNAME, TABLEPK, DELFLAG, INSTNUM, LASTDATE, DATEXC)
          select sys_guid(), 'XZXK_YLQXSCXKESL_XX_SCDZ', 'BZJ', BZJ as TABLEPK, 'N', f_getslbs(), sysdate, '11' from XZXK_YLQXSCXKESL_XX_SCDZ where qbid = V_qbid;

            delete XZXK_YLQXSCXKESL_XX_SCDZ where qbid = V_qbid;
              insert into XZXK_YLQXSCXKESL_XX_SCDZ
               (bzj,  QBID,   sqid, jtdz, gb, szsf, szqx, szjd, lxr, lxdh, yb, dzyx, instnum, lastdate, datexc)
              select
          sys_guid(), V_qbid, sqid, jtdz, gb, szsf, szqx, szjd, lxr, lxdh, yb, dzyx, f_getslbs(),sysdate,'11'
                from GG_XKZ_YLQXSCXKESL_SCDZ
                where sqid = V_sqid_h ;
    select 1 into V_BS from dual ;
    else
        update  XZXK_YLQXSCXKESL_XX_SCDZ set  sqid  = V_sqid_h  where QBID = V_qbid ;
    end if;


  --1.1.5 生产范围信息表
    if V_SCFW > 0 then
    INSERT INTO PUB_TABLE_DATA_DELEXC(ID, TABLENAME, TABLEPKNAME, TABLEPK, DELFLAG, INSTNUM, LASTDATE, DATEXC)
          select sys_guid(), 'XZXK_YLQXSCXKESL_XX_SCFW', 'BZJ', BZJ as TABLEPK, 'N', f_getslbs(), sysdate, '11' from XZXK_YLQXSCXKESL_XX_SCFW where qbid = V_qbid;

          delete XZXK_YLQXSCXKESL_XX_SCFW where qbid = V_qbid;
              insert into XZXK_YLQXSCXKESL_XX_SCFW
               (bzj,  QBID,   sqid, gllb, cpldh, cplmc, cplxh, yjcplb, ejcplb, pmjl, cpms, yqyt, instnum, lastdate, datexc, cplx, lybz)
              select
          sys_guid(), V_qbid ,sqid, gllb, cpldh, cplmc, cplxh, yjcplb, ejcplb, pmjl, cpms, yqyt,  f_getslbs(),sysdate,'11', cplx, lybz
                from GG_XKZ_YLQXSCXKESL_SCFW
                where sqid = V_sqid_h ;
        select 1 into V_BS from dual ;
    else
        update  XZXK_YLQXSCXKESL_XX_SCFW set  sqid  = V_sqid_h  where QBID = V_qbid ;
   end if;

  --1.1.6 生产产品信息
   if V_SCCP1 > 0 then
    INSERT INTO PUB_TABLE_DATA_DELEXC(ID, TABLENAME, TABLEPKNAME, TABLEPK, DELFLAG, INSTNUM, LASTDATE, DATEXC)
          select sys_guid(), 'XZXK_YLQXSCXKESL_XX_SCCP', 'BZJ', BZJ as TABLEPK, 'N', f_getslbs(), sysdate, '11' from XZXK_YLQXSCXKESL_XX_SCCP where qbid = V_qbid;

         delete XZXK_YLQXSCXKESL_XX_SCCP where qbid = V_qbid;
            insert into XZXK_YLQXSCXKESL_XX_SCCP
             (bzj,  QBID,   sqid, sxh, sfstsc, zczh, gllb, cpldh, cplmc, cplxh, yjcplb, ejcplb, cpmc, lb, bz, instnum, lastdate, datexc, cplx, dzrq)
            select
        sys_guid(), V_qbid, sqid, sxh, sfstsc, zczh, gllb, cpldh, cplmc, cplxh, yjcplb, ejcplb, cpmc, lb, bz, f_getslbs(),sysdate,'11', cplx, dzrq
              from GG_XKZ_YLQXSCXKESL_SCCP
              where  sqid = V_sqid_h ;

    select 1 into V_BS from dual ;
    else
        update  XZXK_YLQXSCXKESL_XX_SCCP set  sqid  = V_sqid_h  where QBID = V_qbid ;
   end if;

   if V_SCCP2 > 0 then
    INSERT INTO PUB_TABLE_DATA_DELEXC(ID, TABLENAME, TABLEPKNAME, TABLEPK, DELFLAG, INSTNUM, LASTDATE, DATEXC)
          select sys_guid(), 'XZXK_YLQXSCXKESL_XX_SCCP', 'BZJ', BZJ as TABLEPK, 'N', f_getslbs(), sysdate, '11' from XZXK_YLQXSCXKESL_XX_SCCP where qbid = V_qbid;

         delete XZXK_YLQXSCXKESL_XX_SCCP where qbid = V_qbid;
            insert into XZXK_YLQXSCXKESL_XX_SCCP
             (bzj,  QBID,   sqid, sxh, sfstsc, zczh, gllb, cpldh, cplmc, cplxh, yjcplb, ejcplb, cpmc, lb, bz, instnum, lastdate, datexc, cplx, dzrq)
            select
        sys_guid(), V_qbid, sqid, sxh, sfstsc, zczh, gllb, cpldh, cplmc, cplxh, yjcplb, ejcplb, cpmc, lb, bz, f_getslbs(),sysdate,'11', cplx, dzrq
              from GG_XKZ_YLQXSCXKESL_SCCP
              where  sqid = V_sqid_h ;
    else
        update  XZXK_YLQXSCXKESL_XX_SCCP set  sqid  = V_sqid_h  where QBID = V_qbid ;
   end if;

   --long flow
   if (V_QYSCDZ1 > 0 or V_SCCP2 > 0) then
      select 0 into V_BS from dual ;
   else
   --short flow
      select 1 into V_BS from dual ;
   end if;
   --
-- 短变更
   if V_BS > 0  then
       update GG_XKZ_YLQXSCXKESL set  FZRQ = fzrqIn  where sqid=V_sqid_h;
       update  xzxk_ylqxscxkesl_xx_qb set ( xkzbh,    qymc, scfw,   ZSDZ,   czzt,   fzjgmc, scfzrq, FZRQ,  dzrq , DYBS ) =
                                ( select  xkzbh_idIn, qymc, scfw,   ZS,      'V',   FZJGMC, SCFZRQ, fzrqIn,DZRQ , DYBS from GG_XKZ_YLQXSCXKESL where sqid = V_sqid_h and czzt = 'V') where QBID = V_qbid ;
   else
-- 长变更
       update GG_XKZ_YLQXSCXKESL set FZRQ = fzrqIn, YXQZ = yxqzIn  where sqid=V_sqid_h;
       update  xzxk_ylqxscxkesl_xx_qb set ( xkzbh,    qymc, scfw,   ZSDZ,   czzt,   fzjgmc, scfzrq, FZRQ,   YXQZ,     dzrq , DYBS ) =
                                ( select  xkzbh_idIn, qymc, scfw,   ZS,      'V',   FZJGMC, SCFZRQ, fzrqIn ,yxqzIn,   DZRQ , DYBS from GG_XKZ_YLQXSCXKESL where sqid = V_sqid_h and czzt = 'V') where QBID = V_qbid ;
   end if ;

 ----------------插入------医疗器械生产许可信息全表------------------结束-------------

 --------------------------更新信息全表中  个别字段-----------------开始--------------

 update  xzxk_ylqxscxkesl_xx_qb set ( LXRXM , LXDH, ZZJGDM, datexc )   =
         ( select  LXRXM , LXDH , ZZJGDM, '11' from XZXK_YLQXSCXKESL_BG_SQ where sqid = bgid_idIn )  where QBID = V_qbid ;

 update XZXK_YLQXSCXKESL_xx_RYXX set  XM  =
       ( select XM from GG_XKZ_YLQXSCXKESL_RYXX where   sqid = V_sqid_h  and  RYLX = '0' and rownum = 1 )  where QBID = V_qbid  and RYLX = '0' ;

 update XZXK_YLQXSCXKESL_xx_RYXX set  XM  =
       ( select XM from GG_XKZ_YLQXSCXKESL_RYXX where   sqid = V_sqid_h  and  RYLX = '1' and rownum = 1 )  where QBID = V_qbid  and RYLX = '1' ;

 --  更新企业类型
 update   xzxk_ylqxscxkesl_xx_qb set qylx =
       ( select qylx from XZXK_YLQXSCXKESL_BG_SQ  where sqid = bgid_idIn ) where QBID = V_qbid ;

  -- 修改许可证编号添加‘食’字
   select  length(xkzbh) into V_length  from gg_xkz_ylqxscxkesl t where xkzbh =  xkzbh_idIn  and czzt = 'V';
  -- 修改旧数据
     IF  V_length < 17  THEN
              SELECT REPLACE(xkzbh,(substr( xkzbh, 0, 2 )), '京食药') into V_name2 from xzxk_ylqxscxkesl_xx_qb t where xkzbh = xkzbh_idIn  ;
              update    xzxk_ylqxscxkesl_xx_qb set xkzbh = V_name2  where QBID = V_qbid ;
              update   gg_xkz_ylqxscxkesl  set   xkzbh = V_name2  where  sqid = V_sqid_h  and czzt = 'V' ;
              update   XZXK_YLQXSCXKESL_BG_SQ  set  xkzbh = V_name2  where sqid = bgid_idIn ;
     END IF ;
 --------------------------更新信息全表中  个别字段-----------------开始--------------
    flag := 'Y';
  commit;
Exception
  WHEN v_raise THEN
    flag := 'N';
    rollback;
  WHEN NO_DATA_FOUND THEN
    flag := 'E';
    rollback;
end YLQXSCXKESL_GGXKZ_TO_QB;

原文地址:https://www.cnblogs.com/meimao5211/p/4118772.html