CREATE OR REPLACE PROCEDURE "ELYLQXJYBAHF_IN_XKZ" (ywid in varchar2, --业务主键
v_xkzbh in varchar2, --许可证编号
flag out varchar2 --存储过程返回状态
) is
v_raise exception;
begin
--第一步,更新许可证状态
update GG_XKZ_QXJYELBA t
set t.xkzbh = v_xkzbh,
t.fzrq = to_char(sysdate, 'yyyymmdd'),
t.yxq = to_char(add_months(sysdate, 60) - 1, 'yyyymmdd'),
t.czbs = 'V',
t.instnum = f_getslbs(),
t.lastdate = sysdate,
t.datexc = '11'
where sqid = ywid;
--更新经营范围表中的许可证号
update GG_XKZ_QXJYELBA_JYFW set XKZBH=v_xkzbh where XKZID=(select XKZID from GG_XKZ_QXJYELBA where sqid = ywid);
--第二步,插入信息全表
insert into xzxk_qxjyelba_xx_qb
(xxqbid,
qyid,
qymc,
lsgx,
yyzzzch,
zzjgdm,
clrq,
zs,
yyqx,
jycsqx,
jycsjd,
jycs,
zczb,
jyfs,
yzbm,
jyms,
kfdzqx,
kfdzjd,
kfdz,
kflxr,
kflxdh,
jyfw,
lxrxm,
lxrzjlx,
lxrzjhm,
lxrdh,
lxrsj,
lxrcz,
lxrdzyj,
qyryzs,
qyzlglry,
qyshfwry,
qyzyjsry,
jymj,
kfmj,
jycstj,
kftj,
kfsfkqy,
bz,
bjbs,
sffrqy,
instnum,
lastdate,
datexc)
select sqid,
qyid,
qymc,
lsgx,
yyzzzch,
zzjgdm,
clrq,
zs,
yyqx,
jycsqx,
jycsjd,
jycs,
zczb,
jyfs,
yzbm,
jyms,
kfdzqx,
kfdzjd,
kfdz,
kflxr,
kflxdh,
jyfw,
lxrxm,
lxrzjlx,
lxrzjhm,
lxrdh,
lxrsj,
lxrcz,
lxrdzyj,
qyryzs,
qyzlglry,
qyshfwry,
qyzyjsry,
jymj,
kfmj,
jycstj,
kftj,
kfsfkqy,
bz,
bjbs,
sffrqy,
f_getslbs(),
sysdate,
'11'
from xzxk_qxjyelba_hf_sq
where sqid = ywid;
--第三步,把许可证表信息更新到全表中
update xzxk_qxjyelba_xx_qb
set (xkzbh, fzbm, yxq, fzrq, zzywlx) =
(select xkzbh, fzbm, yxq, fzrq, zzywlx
from GG_XKZ_QXJYELBA
where sqid = ywid)
where xxqbid = ywid;
--第四步,插入人员信息全表
insert into xzxk_qxjyelba_xx_ry
(ryid,
xxqbid,
rylx,
xm,
zjlx,
zjhm,
zw,
xl,
sxzy,
zc,
bz,
instnum,
lastdate,
datexc)
select ryid,
sqid,
rylx,
xm,
zjlx,
zjhm,
zw,
xl,
sxzy,
zc,
bz,
f_getslbs(),
sysdate,
'11'
from xzxk_qxjyelba_hf_ry
where sqid = ywid;
--第五步,插入经营范围信息全表
insert into xzxk_qxjyelba_xx_jyfw
(jyfwid, xxqbid, cplmc, gllb, cpldh, instnum, lastdate, datexc)
select jyfwid, sqid, cplmc, gllb, cpldh, f_getslbs(), sysdate, '11'
from xzxk_qxjyelba_hf_jyfw
where sqid = ywid;
--插入库房地址
insert into xzxk_qxjyelba_xx_kfdz
(dzid, xxqbid, qx, jd, xxdz, lxr, lxdh, kfmj, kftj, bz, instnum, lastdate, datexc)
select dzid, sqid, qx, jd, xxdz, lxr, lxdh, kfmj, kftj, bz, f_getslbs(),sysdate,'11'
from xzxk_qxjyelba_hf_kfdz where sqid=ywid;
--第六步,插入产品信息全表
insert into xzxk_qxjyelba_xx_cp
(cpid, xxqbid, jycpmc, gllb, cpldh, cpzch, instnum, lastdate, datexc)
select cpid,
sqid,
jycpmc,
gllb,
cpldh,
cpzch,
f_getslbs(),
sysdate,
'11'
from xzxk_qxjyelba_hf_cp
where sqid = ywid;
--第七步,插入设备信息全表
insert into xzxk_qxjyelba_xx_sssb
(sssbid, xxqbid, mc, ggxh, jd, sl, yt, instnum, lastdate, datexc)
select sssbid, sqid, mc, ggxh, jd, sl, yt, f_getslbs(), sysdate, '11'
from xzxk_qxjyelba_hf_sssb
where sqid = ywid;
flag := 'Y';
commit;
exception
when no_data_found then
flag := 'N';
rollback;
when too_many_rows then
flag := 'N';
rollback;
when v_raise then
flag := 'N';
rollback;
end ELYLQXJYBAHF_IN_XKZ;