CREATE OR REPLACE PROCEDURE "DYLYLQX_SC_BA_1" (YWID IN VARCHAR2,
FLAG OUT VARCHAR2) IS
V_RAISE EXCEPTION; --异常类型
V_YWLX CHAR(1); --业务类型
V_BABH VARCHAR2(50); --备案编号
V_XXQBZJ VARCHAR2(32); --信息表主键
V_PZBID VARCHAR2(32); --备案凭证主键
V_GG_XKZ_YLYLQXSC GG_XKZ_YLYLQXSC%ROWTYPE; --凭证表主表
V_XZXK_YLYLQXSC_BA_SQ XZXK_YLYLQXSC_BA_SQ%ROWTYPE; --申请表
V_XZXK_ZLFZR XZXK_YLYLQXSC_BA_RY%ROWTYPE; --质量负责人
V_XZXK_SCFZR XZXK_YLYLQXSC_BA_RY%ROWTYPE; --生产负责人
V_XZXK_JSFZR XZXK_YLYLQXSC_BA_RY%ROWTYPE; --技术负责人

BGSX XZXK_YLYLQXSC_BA_BGSX%ROWTYPE; --声明类型变量
CURSOR BGSX_LIST IS
SELECT * FROM XZXK_YLYLQXSC_BA_BGSX T WHERE T.SQID = YWID; --声明游标 根据id查询变更事项list

--查询凭证产品子表
V_GG_SC_SCCP GG_XKZ_YLYLQXSC_SCCP%ROWTYPE;
CURSOR V_GG_SC_SCCPS IS
SELECT T.*
FROM GG_XKZ_YLYLQXSC_SCCP T
WHERE T.BAPZID IN
(SELECT X.PZBID FROM GG_XKZ_YLYLQXSC X WHERE X.SQID = YWID);
V_GG_SC_SCDZ GG_XKZ_YLYLQXSC_SCDZ%ROWTYPE;
CURSOR V_GG_SC_SCDZS IS
SELECT T.*
FROM GG_XKZ_YLYLQXSC_SCDZ T
WHERE T.BAPZID IN
(SELECT X.PZBID FROM GG_XKZ_YLYLQXSC X WHERE X.SQID = YWID);
V_GG_SC_SCFW GG_XKZ_YLYLQXSC_SCFW%ROWTYPE;
CURSOR V_GG_SC_SCFWS IS
SELECT T.*
FROM GG_XKZ_YLYLQXSC_SCFW T
WHERE T.BAPZID IN
(SELECT X.PZBID FROM GG_XKZ_YLYLQXSC X WHERE X.SQID = YWID);
BEGIN
--根据申请id查询业务类型
SELECT T.YWLX INTO V_YWLX FROM XZXK_YLYLQXSC_BA_SQ T WHERE T.SQID = YWID;
--根据申请id查询备案编号
SELECT T.BAH INTO V_BABH FROM GG_XKZ_YLYLQXSC T WHERE T.SQID = YWID;
--根据不同的业务类型做相应处理
--业务类型 A-备案 G-变更 Z-补证
IF (V_YWLX = 'A') THEN
--备案
--更新凭证表信息
UPDATE GG_XKZ_YLYLQXSC T
SET T.DYBS = '000',
T.GSBS = 'Y',
T.CZZT = 'V',
T.BAZT = 'V',
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.SQID = YWID;
--向结果表中插入数据从业务表
INSERT INTO XZXK_YLYLQXSC_XX_QB
(BZJ,
QYID,
QYMC,
YYZZZCH,
YYZZJZRQ,
ZZJGDM,
QYLX,
CLRQ,
ZCZB,
ZCDZ,
ZCDSZSF,
ZCDSZQX,
ZCDZYB,
ZCDZDH,
SCDZ,
SCDZYB,
SCDZDH,
SCFW,
LXR,
LXRSFZH,
LXDH,
CZ,
DZYX,
ZGZS,
SCGLRYS,
ZLGLRYS,
ZYJSRYS,
QYCSJZMJ,
SCMJ,
JHMJ,
JYMJ,
CCMJ,
JYJGZRS,
JYJGJSRYS,
BABH,
BADW,
BARQ,
INSTNUM,
LASTDATE,
DATEXC)
SELECT T.SQID,
T.QYID,
T.QYMC,
T.YYZZZCH,
T.YYZZJZRQ,
T.ZZJGDM,
T.QYLX,
T.CLRQ,
T.ZCZB,
T.ZCDZ,
T.ZCDSZSF,
T.ZCDSZQX,
T.ZCDZYB,
T.ZCDZDH,
T.SCDZ,
T.SCDZYB,
T.SCDZDH,
T.SCFW,
T.LXR,
T.LXRSFZH,
T.LXDH,
T.CZ,
T.DZYX,
T.ZGZS,
T.SCGLRYS,
T.ZLGLRYS,
T.ZYJSRYS,
T.QYCSJZMJ,
T.SCMJ,
T.JHMJ,
T.JYMJ,
T.CCMJ,
T.JYJGZRS,
T.JYJGJSRYS,
T.BABH,
T.BADW,
T.BARQ,
F_GETSLBS,
SYSDATE,
'11'
FROM XZXK_YLYLQXSC_BA_SQ T
WHERE T.SQID = YWID;
-- 插入人员信息表
--先将人员列表清空
INSERT INTO PUB_TABLE_DATA_DELEXC
(ID,
TABLENAME,
TABLEPKNAME,
TABLEPK,
DELFLAG,
INSTNUM,
LASTDATE,
DATEXC)
SELECT SYS_GUID(),
'XZXK_YLYLQXSC_XX_RY',
'BZJ',
BZJ AS TABLEPK,
'N',
F_GETSLBS(),
SYSDATE,
'11'
FROM XZXK_YLYLQXSC_XX_RY
WHERE XXQBZJ = YWID;
DELETE FROM XZXK_YLYLQXSC_XX_RY T WHERE T.XXQBZJ = YWID;
--插入人员信息从业务人员表到信息全表人员表
INSERT INTO XZXK_YLYLQXSC_XX_RY
(BZJ,
XXQBZJ,
RYLX,
XM,
ZJLX,
ZJHM,
ZC,
SXZY,
XL,
INSTNUM,
LASTDATE,
DATEXC)
SELECT T.BZJ,
T.SQID,
T.RYLX,
T.XM,
T.ZJLX,
T.ZJHM,
T.ZC,
T.SXZY,
T.XL,
F_GETSLBS,
SYSDATE,
'11'
FROM XZXK_YLYLQXSC_BA_RY T
WHERE T.SQID = YWID;
--插入生产范围表
--先将生产范围表清空
INSERT INTO PUB_TABLE_DATA_DELEXC
(ID,
TABLENAME,
TABLEPKNAME,
TABLEPK,
DELFLAG,
INSTNUM,
LASTDATE,
DATEXC)
SELECT SYS_GUID(),
'XZXK_YLYLQXSC_XX_SCFW',
'BZJ',
BZJ AS TABLEPK,
'N',
F_GETSLBS(),
SYSDATE,
'11'
FROM XZXK_YLYLQXSC_XX_SCFW
WHERE XXQBZJ = YWID;
DELETE FROM XZXK_YLYLQXSC_XX_SCFW T WHERE T.XXQBZJ = YWID;
--插入生产范围信息从业务表生产范围子表
INSERT INTO XZXK_YLYLQXSC_XX_SCFW
(BZJ, XXQBZJ, CPFL, CPLDH, CPLMC, INSTNUM, LASTDATE, DATEXC)
SELECT T.BZJ,
T.SQID,
T.CPFL,
T.CPLDH,
T.CPLMC,
F_GETSLBS,
SYSDATE,
'11'
FROM XZXK_YLYLQXSC_BA_SCFW T
WHERE T.SQID = YWID;
--插入生产地址信息表
--先将生产地址信息清空
INSERT INTO PUB_TABLE_DATA_DELEXC
(ID,
TABLENAME,
TABLEPKNAME,
TABLEPK,
DELFLAG,
INSTNUM,
LASTDATE,
DATEXC)
SELECT SYS_GUID(),
'XZXK_YLYLQXSC_XX_SCDZ',
'BZJ',
BZJ AS TABLEPK,
'N',
F_GETSLBS(),
SYSDATE,
'11'
FROM XZXK_YLYLQXSC_XX_SCDZ
WHERE XXQBZJ = YWID;
DELETE FROM XZXK_YLYLQXSC_XX_SCDZ T WHERE T.XXQBZJ = YWID;
--插入生产地址信息
INSERT INTO XZXK_YLYLQXSC_XX_SCDZ
(BZJ,
XXQBZJ,
JTDZ,
SZSF,
SZQX,
SZJD,
LXDH,
YB,
INSTNUM,
LASTDATE,
DATEXC)
SELECT T.BZJ,
T.SQID,
T.JTDZ,
T.SZSF,
T.SZQX,
T.SZJD,
T.LXDH,
T.YB,
F_GETSLBS,
SYSDATE,
'11'
FROM XZXK_YLYLQXSC_BA_SCDZ T
WHERE T.SQID = YWID;
--通过凭证更新信息主表
--查询信息凭证表信息根据id
SELECT T.*
INTO V_GG_XKZ_YLYLQXSC
FROM GG_XKZ_YLYLQXSC T
WHERE T.SQID = YWID;
--更新信息主表
UPDATE XZXK_YLYLQXSC_XX_QB T
SET T.BABH = V_GG_XKZ_YLYLQXSC.BAH,
T.BADW = V_GG_XKZ_YLYLQXSC.BADW,
T.BARQ = V_GG_XKZ_YLYLQXSC.BARQ,
T.BAZT = V_GG_XKZ_YLYLQXSC.BAZT,
T.QYID = V_GG_XKZ_YLYLQXSC.QYID,
T.QYMC = V_GG_XKZ_YLYLQXSC.QYMC,
T.ZCDZ = V_GG_XKZ_YLYLQXSC.QYZCDZ,
T.SCDZ = V_GG_XKZ_YLYLQXSC.QYSCDZ,
T.SCFW = V_GG_XKZ_YLYLQXSC.SCFW,
T.INSTNUM = F_GETSLBS, --实例标识
T.LASTDATE = SYSDATE, --时间戳
T.DATEXC = '11' --数据交换位
WHERE T.BZJ = YWID;
--通过凭证更新变更后的生产范围,生产信息,生产地址 表信息
--修改人员信息表的法定代表人和企业负责人
--法定代表人
UPDATE XZXK_YLYLQXSC_XX_RY T
SET T.XM = V_GG_XKZ_YLYLQXSC.FDDBR,
T.INSTNUM = F_GETSLBS, --实例标识
T.LASTDATE = SYSDATE, --时间戳
T.DATEXC = '11' --数据交换位
WHERE T.RYLX = '0'
AND T.XXQBZJ = YWID;
--企业负责人
UPDATE XZXK_YLYLQXSC_XX_RY T
SET T.XM = V_GG_XKZ_YLYLQXSC.QYFZR,
T.INSTNUM = F_GETSLBS, --实例标识
T.LASTDATE = SYSDATE, --时间戳
T.DATEXC = '11' --数据交换位
WHERE T.RYLX = '1'
AND T.XXQBZJ = YWID;
INSERT INTO PUB_TABLE_DATA_DELEXC
(ID,
TABLENAME,
TABLEPKNAME,
TABLEPK,
DELFLAG,
INSTNUM,
LASTDATE,
DATEXC)
SELECT SYS_GUID(),
'XZXK_YLYLQXSC_XX_SCCP',
'BZJ',
BZJ AS TABLEPK,
'N',
F_GETSLBS(),
SYSDATE,
'11'
FROM XZXK_YLYLQXSC_XX_SCCP
WHERE XXQBZJ = YWID;
DELETE FROM XZXK_YLYLQXSC_XX_SCCP T WHERE T.XXQBZJ = YWID; --生产产品

OPEN V_GG_SC_SCCPS;
LOOP
FETCH V_GG_SC_SCCPS
INTO V_GG_SC_SCCP;
EXIT WHEN V_GG_SC_SCCPS%NOTFOUND;
--插入生产产品
INSERT INTO XZXK_YLYLQXSC_XX_SCCP
(BZJ,
XXQBZJ,
BAH,
CPMC,
SFSTSC,
BARQ,
BZ,
INSTNUM,
LASTDATE,
DATEXC)
VALUES
(V_GG_SC_SCCP.BZJ,
YWID,
V_GG_SC_SCCP.BAH,
V_GG_SC_SCCP.CPMC,
V_GG_SC_SCCP.SFSTSC,
V_GG_SC_SCCP.BARQ,
V_GG_SC_SCCP.BZ,
F_GETSLBS,
SYSDATE,
'11');
END LOOP;
close V_GG_SC_SCCPS;
ELSIF (V_YWLX = 'G') THEN
--根据申请表 备案编号 将状态为有效地改为无效
UPDATE GG_XKZ_YLYLQXSC T
SET T.DYBS = '000', --打印标识
T.CZZT = 'I', --操作状态
T.GSBS = 'N', --公共标识
T.BAZT = 'I',
T.INSTNUM = F_GETSLBS, --实例标识
T.LASTDATE = SYSDATE, --时间戳
T.DATEXC = '11' --数据交换位
WHERE T.BAH = V_BABH
AND T.CZZT = 'V';
--将状态为临时的改为有效
UPDATE GG_XKZ_YLYLQXSC T
SET T.DYBS = '000', --打印标识
T.CZZT = 'V', --操作状态
T.GSBS = 'Y', --公共标识
T.BAZT = 'V',
T.INSTNUM = F_GETSLBS, --实例标识
T.LASTDATE = SYSDATE, --时间戳
T.DATEXC = '11' --数据交换位
WHERE T.SQID = YWID
AND T.CZZT = 'T';
--变更
--根据备案编号 查询信息表主键
SELECT BZJ
INTO V_XXQBZJ
FROM XZXK_YLYLQXSC_XX_QB T
WHERE T.BABH = V_BABH and rownum < 2;
-- 查询申请表信息
SELECT *
INTO V_XZXK_YLYLQXSC_BA_SQ
FROM XZXK_YLYLQXSC_BA_SQ
WHERE SQID = YWID and rownum < 2;
--根据备案编号查询备案凭证id
SELECT PZBID INTO V_PZBID FROM GG_XKZ_YLYLQXSC WHERE SQID = YWID and rownum < 2;
-- 查询凭证表信息
SELECT * INTO V_GG_XKZ_YLYLQXSC FROM GG_XKZ_YLYLQXSC WHERE SQID = YWID and rownum < 2;
-- 查询质量负责人
SELECT *
INTO V_XZXK_ZLFZR
FROM XZXK_YLYLQXSC_BA_RY
WHERE SQID = YWID
AND RYLX = '2' and rownum < 2;
-- 查询产品负责人
SELECT *
INTO V_XZXK_SCFZR
FROM XZXK_YLYLQXSC_BA_RY
WHERE SQID = YWID
AND RYLX = '3' and rownum < 2;
-- 查询技术负责人
SELECT *
INTO V_XZXK_JSFZR
FROM XZXK_YLYLQXSC_BA_RY
WHERE SQID = YWID
AND RYLX = '5' and rownum < 2;
--信息表
UPDATE XZXK_YLYLQXSC_XX_QB T
SET T.QYMC = V_XZXK_YLYLQXSC_BA_SQ.QYMC, --企业名称
T.YYZZZCH = V_XZXK_YLYLQXSC_BA_SQ.YYZZZCH, --营业执照注册码
T.YYZZJZRQ = V_XZXK_YLYLQXSC_BA_SQ.YYZZJZRQ, --营业执照戒指日期
T.ZZJGDM = V_XZXK_YLYLQXSC_BA_SQ.ZZJGDM, --组织机构代码
T.QYLX = V_XZXK_YLYLQXSC_BA_SQ.QYLX, --企业类型
T.CLRQ = V_XZXK_YLYLQXSC_BA_SQ.CLRQ, --成立日期
T.ZCZB = V_XZXK_YLYLQXSC_BA_SQ.ZCZB, --注册资本
T.ZCDZ = V_XZXK_YLYLQXSC_BA_SQ.ZCDZ, --注册地址
T.ZCDSZSF = V_XZXK_YLYLQXSC_BA_SQ.ZCDSZSF, --注册地所在省份
T.ZCDSZQX = V_XZXK_YLYLQXSC_BA_SQ.ZCDSZQX, --注册地所在区县
T.ZCDZYB = V_XZXK_YLYLQXSC_BA_SQ.ZCDZYB, --注册地址邮编
T.ZCDZDH = V_XZXK_YLYLQXSC_BA_SQ.ZCDZDH, --注册地址电话
T.SCFW = V_XZXK_YLYLQXSC_BA_SQ.SCFW, --生产范围
T.LXR = V_XZXK_YLYLQXSC_BA_SQ.LXR, --联系人
T.LXRSFZH = V_XZXK_YLYLQXSC_BA_SQ.LXRSFZH, --联系人身份证号
T.LXDH = V_XZXK_YLYLQXSC_BA_SQ.LXDH, --联系电话
T.CZ = V_XZXK_YLYLQXSC_BA_SQ.CZ, --传真
T.DZYX = V_XZXK_YLYLQXSC_BA_SQ.DZYX, --电子邮箱
T.ZGZS = V_XZXK_YLYLQXSC_BA_SQ.ZGZS, --职工总数
T.SCGLRYS = V_XZXK_YLYLQXSC_BA_SQ.SCGLRYS, --生产管理人员数
T.ZLGLRYS = V_XZXK_YLYLQXSC_BA_SQ.ZLGLRYS, --质量管理人员数
T.ZYJSRYS = V_XZXK_YLYLQXSC_BA_SQ.ZYJSRYS, --专业技术人员数
T.QYCSJZMJ = V_XZXK_YLYLQXSC_BA_SQ.QYCSJZMJ, --企业场所建筑面积
T.SCMJ = V_XZXK_YLYLQXSC_BA_SQ.SCMJ, --生产面积
T.JHMJ = V_XZXK_YLYLQXSC_BA_SQ.JHMJ, --净化面积
T.JYMJ = V_XZXK_YLYLQXSC_BA_SQ.JYMJ, --检验面积
T.CCMJ = V_XZXK_YLYLQXSC_BA_SQ.CCMJ, --仓储面积
T.JYJGZRS = V_XZXK_YLYLQXSC_BA_SQ.JYJGZRS, --检验机构总人数
T.JYJGJSRYS = V_XZXK_YLYLQXSC_BA_SQ.JYJGJSRYS, --检验机构技术人员数
T.BABH = V_XZXK_YLYLQXSC_BA_SQ.BABH, --备案编号
T.BADW = V_XZXK_YLYLQXSC_BA_SQ.BADW, --备案单位
T.BARQ = V_XZXK_YLYLQXSC_BA_SQ.BARQ, --备案日期
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.BZJ = V_XXQBZJ;
--做三个人员的更新
--质量负责人
UPDATE XZXK_YLYLQXSC_XX_RY T
SET T.XM = V_XZXK_ZLFZR.XM,
T.ZJLX = V_XZXK_ZLFZR.ZJLX,
T.ZJHM = V_XZXK_ZLFZR.ZJHM,
T.ZC = V_XZXK_ZLFZR.ZC,
T.SXZY = V_XZXK_ZLFZR.SXZY,
T.XL = V_XZXK_ZLFZR.XL,
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.XXQBZJ = V_XXQBZJ
AND RYLX = '2';
--产品负责人
UPDATE XZXK_YLYLQXSC_XX_RY T
SET T.XM = V_XZXK_SCFZR.XM,
T.ZJLX = V_XZXK_SCFZR.ZJLX,
T.ZJHM = V_XZXK_SCFZR.ZJHM,
T.ZC = V_XZXK_SCFZR.ZC,
T.SXZY = V_XZXK_SCFZR.SXZY,
T.XL = V_XZXK_SCFZR.XL,
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.XXQBZJ = V_XXQBZJ
AND RYLX = '3';
--技术负责人
UPDATE XZXK_YLYLQXSC_XX_RY T
SET T.XM = V_XZXK_JSFZR.XM,
T.ZJLX = V_XZXK_JSFZR.ZJLX,
T.ZJHM = V_XZXK_JSFZR.ZJHM,
T.ZC = V_XZXK_JSFZR.ZC,
T.SXZY = V_XZXK_JSFZR.SXZY,
T.XL = V_XZXK_JSFZR.XL,
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.XXQBZJ = V_XXQBZJ
AND RYLX = '5';
-- 进行遍历游标判断
OPEN BGSX_LIST;
LOOP
FETCH BGSX_LIST
INTO BGSX;
EXIT WHEN BGSX_LIST%NOTFOUND;
IF UPPER(BGSX.SQBGSXDM) = 'FDDBR' THEN
--将人员结果表的法定代表人删掉
INSERT INTO PUB_TABLE_DATA_DELEXC
(ID,
TABLENAME,
TABLEPKNAME,
TABLEPK,
DELFLAG,
INSTNUM,
LASTDATE,
DATEXC)
SELECT SYS_GUID(),
'XZXK_YLYLQXSC_XX_RY',
'BZJ',
BZJ AS TABLEPK,
'N',
F_GETSLBS(),
SYSDATE,
'11'
FROM XZXK_YLYLQXSC_XX_RY
WHERE RYLX = '0'
AND XXQBZJ = V_XXQBZJ;
DELETE FROM XZXK_YLYLQXSC_XX_RY T
WHERE T.RYLX = '0'
AND T.XXQBZJ = V_XXQBZJ;
--将修改后的法定代表人添加到人员表
INSERT INTO XZXK_YLYLQXSC_XX_RY
(BZJ,
XXQBZJ,
RYLX,
XM,
ZJLX,
ZJHM,
ZC,
SXZY,
XL,
INSTNUM,
LASTDATE,
DATEXC)
SELECT T.BZJ,
V_XXQBZJ,
T.RYLX,
T.XM,
T.ZJLX,
T.ZJHM,
T.ZC,
T.SXZY,
T.XL,
F_GETSLBS,
SYSDATE,
'11'
FROM XZXK_YLYLQXSC_BA_RY T
WHERE T.SQID = YWID
AND T.BGQHBS = '2'
AND T.RYLX = '0';

ELSIF UPPER(BGSX.SQBGSXDM) = 'QYFZR' THEN
--将人员结果表的企业负责人删掉
INSERT INTO PUB_TABLE_DATA_DELEXC
(ID,
TABLENAME,
TABLEPKNAME,
TABLEPK,
DELFLAG,
INSTNUM,
LASTDATE,
DATEXC)
SELECT SYS_GUID(),
'XZXK_YLYLQXSC_XX_RY',
'BZJ',
BZJ AS TABLEPK,
'N',
F_GETSLBS(),
SYSDATE,
'11'
FROM XZXK_YLYLQXSC_XX_RY
WHERE RYLX = '1'
AND XXQBZJ = V_XXQBZJ;
DELETE FROM XZXK_YLYLQXSC_XX_RY T
WHERE T.RYLX = '1'
AND T.XXQBZJ = V_XXQBZJ;
--将修改后的法定企业负责添加到人员表
INSERT INTO XZXK_YLYLQXSC_XX_RY
(BZJ,
XXQBZJ,
RYLX,
XM,
ZJLX,
ZJHM,
ZC,
SXZY,
XL,
INSTNUM,
LASTDATE,
DATEXC)
SELECT T.BZJ,
V_XXQBZJ,
T.RYLX,
T.XM,
T.ZJLX,
T.ZJHM,
T.ZC,
T.SXZY,
T.XL,
F_GETSLBS,
SYSDATE,
'11'
FROM XZXK_YLYLQXSC_BA_RY T
WHERE T.SQID = YWID
AND T.BGQHBS = '2'
AND T.RYLX = '1';

ELSIF UPPER(BGSX.SQBGSXDM) = 'XZXK_YLYLQXSC_BA_SCFW' THEN
--将原来的生产范围表清空
INSERT INTO PUB_TABLE_DATA_DELEXC
(ID,
TABLENAME,
TABLEPKNAME,
TABLEPK,
DELFLAG,
INSTNUM,
LASTDATE,
DATEXC)
SELECT SYS_GUID(),
'XZXK_YLYLQXSC_XX_SCFW',
'BZJ',
BZJ AS TABLEPK,
'N',
F_GETSLBS(),
SYSDATE,
'11'
FROM XZXK_YLYLQXSC_XX_SCFW
WHERE XXQBZJ = V_XXQBZJ;
DELETE FROM XZXK_YLYLQXSC_XX_SCFW T WHERE T.XXQBZJ = V_XXQBZJ;
--将变更后的生产范围更新
OPEN V_GG_SC_SCFWS;
LOOP
FETCH V_GG_SC_SCFWS
INTO V_GG_SC_SCFW;
EXIT WHEN V_GG_SC_SCFWS%NOTFOUND;
--插入生产产品
INSERT INTO XZXK_YLYLQXSC_XX_SCFW
(BZJ, XXQBZJ, CPFL, CPLDH, CPLMC, INSTNUM, LASTDATE, DATEXC)
VALUES
(V_GG_SC_SCFW.BZJ,
V_XXQBZJ,
V_GG_SC_SCFW.CPFL,
V_GG_SC_SCFW.CPLDH,
V_GG_SC_SCFW.CPLMC,
F_GETSLBS,
SYSDATE,
'11');
END LOOP;
close V_GG_SC_SCFWS;

ELSIF UPPER(BGSX.SQBGSXDM) = 'XZXK_YLYLQXSC_BA_SCDZ' THEN
-- 将原来生产地址表清空
INSERT INTO PUB_TABLE_DATA_DELEXC
(ID,
TABLENAME,
TABLEPKNAME,
TABLEPK,
DELFLAG,
INSTNUM,
LASTDATE,
DATEXC)
SELECT SYS_GUID(),
'XZXK_YLYLQXSC_XX_SCDZ',
'BZJ',
BZJ AS TABLEPK,
'N',
F_GETSLBS(),
SYSDATE,
'11'
FROM XZXK_YLYLQXSC_XX_SCDZ
WHERE XXQBZJ = V_XXQBZJ;
DELETE FROM XZXK_YLYLQXSC_XX_SCDZ T WHERE T.XXQBZJ = V_XXQBZJ;
--将变更后的生产地址更新
OPEN V_GG_SC_SCDZS;
LOOP
FETCH V_GG_SC_SCDZS
INTO V_GG_SC_SCDZ;
EXIT WHEN V_GG_SC_SCDZS%NOTFOUND;
--插入生产地址
INSERT INTO XZXK_YLYLQXSC_XX_SCDZ
(BZJ,
XXQBZJ,
JTDZ,
SZSF,
SZQX,
SZJD,
LXDH,
YB,
INSTNUM,
LASTDATE,
DATEXC)
VALUES
(V_GG_SC_SCDZ.BZJ,
V_XXQBZJ,
V_GG_SC_SCDZ.JTDZ,
V_GG_SC_SCDZ.SZSF,
V_GG_SC_SCDZ.SZQX,
V_GG_SC_SCDZ.SZJD,
V_GG_SC_SCDZ.LXDH,
V_GG_SC_SCDZ.YB,
F_GETSLBS,
SYSDATE,
'11');
END LOOP;
close V_GG_SC_SCDZS;

ELSIF UPPER(BGSX.SQBGSXDM) = 'XZXK_YLYLQXSC_BA_SCCP' THEN
--将原来生产产品表清空
INSERT INTO PUB_TABLE_DATA_DELEXC
(ID,
TABLENAME,
TABLEPKNAME,
TABLEPK,
DELFLAG,
INSTNUM,
LASTDATE,
DATEXC)
SELECT SYS_GUID(),
'XZXK_YLYLQXSC_XX_SCCP',
'BZJ',
BZJ AS TABLEPK,
'N',
F_GETSLBS(),
SYSDATE,
'11'
FROM XZXK_YLYLQXSC_XX_SCCP
WHERE XXQBZJ = V_XXQBZJ;
DELETE FROM XZXK_YLYLQXSC_XX_SCCP T WHERE T.XXQBZJ = V_XXQBZJ;
--将变更后的生产产品表更新
OPEN V_GG_SC_SCCPS;
LOOP
FETCH V_GG_SC_SCCPS
INTO V_GG_SC_SCCP;
EXIT WHEN V_GG_SC_SCCPS%NOTFOUND;
--插入生产产品
INSERT INTO XZXK_YLYLQXSC_XX_SCCP
(BZJ,
XXQBZJ,
BAH,
CPMC,
SFSTSC,
BARQ,
BZ,
INSTNUM,
LASTDATE,
DATEXC)
VALUES
(V_GG_SC_SCCP.BZJ,
V_XXQBZJ,
V_GG_SC_SCCP.BAH,
V_GG_SC_SCCP.CPMC,
V_GG_SC_SCCP.SFSTSC,
V_GG_SC_SCCP.BARQ,
V_GG_SC_SCCP.BZ,
F_GETSLBS,
SYSDATE,
'11');
END LOOP;
close V_GG_SC_SCCPS;

ELSIF UPPER(BGSX.SQBGSXDM) = 'QYMC' THEN
--将结果表企业名称做修改
UPDATE XZXK_YLYLQXSC_XX_QB T
SET T.QYMC = BGSX.BGH,
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.BZJ = V_XXQBZJ;

ELSIF UPPER(BGSX.SQBGSXDM) = 'ZCDZ' THEN
--将结果表的注册地址做修改
UPDATE XZXK_YLYLQXSC_XX_QB T
SET T.ZCDZ = BGSX.BGH,
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.BZJ = V_XXQBZJ;

END IF;
END LOOP;
CLOSE BGSX_LIST;
--通过凭证更新信息主表
--查询信息凭证表信息根据id
SELECT T.*
INTO V_GG_XKZ_YLYLQXSC
FROM GG_XKZ_YLYLQXSC T
WHERE T.SQID = YWID and rownum < 2;
--更新信息主表
UPDATE XZXK_YLYLQXSC_XX_QB T
SET T.QYMC = V_GG_XKZ_YLYLQXSC.QYMC,
T.ZCDZ = V_GG_XKZ_YLYLQXSC.QYZCDZ,
T.BAZT = V_GG_XKZ_YLYLQXSC.BAZT,
T.SCDZ = V_GG_XKZ_YLYLQXSC.QYSCDZ,
T.SCFW = V_GG_XKZ_YLYLQXSC.SCFW,
T.BABH = V_GG_XKZ_YLYLQXSC.BAH, --备案编号
T.BADW = V_GG_XKZ_YLYLQXSC.BADW, --备案单位
T.BARQ = V_GG_XKZ_YLYLQXSC.BARQ, --备案日期
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.BZJ = V_XXQBZJ;
--修改人员信息表的法定代表人和企业负责人
--法定代表人
UPDATE XZXK_YLYLQXSC_XX_RY T
SET T.XM = V_GG_XKZ_YLYLQXSC.FDDBR,
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.RYLX = '0'
AND T.XXQBZJ = V_XXQBZJ;
--企业负责人
UPDATE XZXK_YLYLQXSC_XX_RY T
SET T.XM = V_GG_XKZ_YLYLQXSC.QYFZR,
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.RYLX = '1'
AND T.XXQBZJ = V_XXQBZJ;
ELSIF (V_YWLX = 'Z') THEN
--补办
--根据申请表 备案编号 将状态为有效地改为无效
UPDATE GG_XKZ_YLYLQXSC T
SET T.DYBS = '000', --打印标识
T.CZZT = 'I', --操作状态
T.GSBS = 'N', --公共标识
T.BAZT = 'I',
T.INSTNUM = F_GETSLBS, --实例标识
T.LASTDATE = SYSDATE, --时间戳
T.DATEXC = '11' --数据交换位
WHERE T.BAH = V_BABH
AND T.CZZT = 'V';
--将状态为临时的改为有效
UPDATE GG_XKZ_YLYLQXSC T
SET T.DYBS = '000', --打印标识
T.CZZT = 'V', --操作状态
T.GSBS = 'Y', --公共标识
T.BAZT = 'V',
T.INSTNUM = F_GETSLBS, --实例标识
T.LASTDATE = SYSDATE, --时间戳
T.DATEXC = '11' --数据交换位
WHERE T.SQID = YWID
AND T.CZZT = 'T';
END IF;
FLAG := 'Y';
COMMIT;
EXCEPTION
WHEN V_RAISE THEN
FLAG := 'N';
ROLLBACK;
WHEN NO_DATA_FOUND THEN
FLAG := 'N';
ROLLBACK;
END DYLYLQX_SC_BA_1;

存储过程之rowtype 使用的更多相关文章

  1. 存储过程之ROWTYPE 使用事例

    CREATE OR REPLACE PROCEDURE "DYLTWZDSJ_CP_BA" (YWID IN VARCHAR2, XKZBH IN VARCHAR2, FLAG O ...

  2. Oracle内置存储过程之DBMS_OUTPUT

    1.DBMS_OUTPUT 1.1 作用: 调试PL/SQL程序 1.2 相关函数: 命令 作用 备注 enable 在serveroutput on的情况下,用来使dbms_output生效(默认即 ...

  3. Code First系列之视图,存储过程和异步API

    返回<8天掌握EF的Code First开发>总目录 本篇目录 视图View 存储过程 使用存储过程CRUD 异步API 本章小结 自我测试 本系列的源码本人已托管于coding上:点击查 ...

  4. MySQL 存储过程 经常使用语法

    MySQL 存储过程是从 MySQL 5.0 開始添加的新功能.存储过程的长处有一箩筐.只是最基本的还是运行效率和SQL 代码封装.特别是 SQL 代码封装功能,假设没有存储过程,在外部程序訪问数据库 ...

  5. mysql:视图,触发器,事务,存储过程,函数

    一.视图 视图是一个虚拟表并不是(正实存在的) 创建老师表 create table teacher( id int primary key auto_increment, tname varchar ...

  6. MySQL视图,触发器,事务,存储过程,函数

    create triggr triafterinsertcmdlog after insert on cmd_log FOR EACH ROW trigger_body .#NEW : 代表新的记录 ...

  7. day 7-20 视图,触发器,事务

    一.视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名称]即可获取结果集,可以将该结果集当做表来使用. 使用视图我们可以把查询过程中的 ...

  8. mysql之视图,触发器,事务等。。。

    一.视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名称]即可获取结果集,可以将该结果集当做表来使用. 使用视图我们可以把查询过程中的 ...

  9. Mysql----整理

    --------------------------------------------------数据常库常用操作总结---------------------------------------- ...

随机推荐

  1. python:如何判断字符串中的内容是否都为数字并且把字符串转换为数字

    使用str.isdigit();有两种使用方法 str.isdigit('12345') =====>True str.isdigit('aaaaa')======>False 或者 '1 ...

  2. SAS连接MYSQL的步骤及引用数据表

    1.建立逻辑库 libname  dz  ’物理路径'; 2.逻辑库做为桥梁连接SAS与MYSQL libname dz MYSQL USER=*****  PASSWORD=****  DATABA ...

  3. Siteserver平台搭建

    本作品由Man_华创作,采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可.基于http://www.cnblogs.com/manhua/上的作品创作. 一开始什么也不懂真痛 ...

  4. Runtime.getRuntime().exec()----记录日志案例

    Runtime.getRuntime().exec()方法主要用于运行外部的程序或命令. Runtime.getRuntime().exec共同拥有六个重载方法: 1.public Process e ...

  5. Spring学习十----------Bean的配置之Autowired注解实现

    © 版权声明:本文为博主原创文章,转载请注明出处 @Required -@Required注解适用于bean属性的setter方法 -这个注解仅仅表示,受影响的bean属性必须在配置时被填充,通过在b ...

  6. Android Handler 异步消息处理机制的妙用 创建强大的图片载入类

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/38476887 ,本文出自[张鸿洋的博客] 近期创建了一个群.方便大家交流,群号: ...

  7. 小程序框架MpVue踩坑日记(一)

    小程序也做了几个小功能模块了,总觉得需要总结一下,踩坑什么的还是得记录一下啊. 好吧,其实是为了方便回顾 首先,说到小程序框架,大家都知道wepy,不过,我是没用过 美团开发团队到mpvue到是个实在 ...

  8. 图像处理之canny---求梯度

    梯度求法和sobel之类的算子雷同,甚至更简单,就是一个离散差分,不清楚的童鞋可以百度,一大堆资料呢,从源码也可清晰的看出原理. // 方向导数,求梯度/* * @parameter sz: 图像大小 ...

  9. 模式识别之基础---mqdf分类器==MQDF改进的二次分类器

    QDF假设样本符合高斯分布,通过估计均值与协方差矩阵,训练分类器.但是由于特征维数较高,时空复杂度较高.(协方差矩阵的维数为 特征维数*特征维数).而且协方差矩阵往往存在不满秩无法求逆的情况(样本数& ...

  10. C#游戏开发高速新手教程Unity5.5教程

    C#游戏开发高速新手教程Unity5.5教程 试读文档下载地址:http://pan.baidu.com/s/1slwBHoD C#是微软公布的高级程序设计语言.这门语言和C语言一样,已经成为了大学计 ...