存储过程之ROWTYPE 使用事例
CREATE OR REPLACE PROCEDURE "DYLTWZDSJ_CP_BA" (YWID IN VARCHAR2,
XKZBH IN VARCHAR2,
FLAG OUT VARCHAR2) IS
V_RAISE EXCEPTION;
V_YWLX CHAR(2); --业务类型
V_BAH VARCHAR2(50);
V_XXBID VARCHAR2(32);
V_GG_XKZ_YLYLQXPZ GG_XKZ_YLYLQXPZ%ROWTYPE;
V_BA_SQS XZXK_YLYLQX_BA_SQS%ROWTYPE;
BEGIN
SELECT T.YWLX INTO V_YWLX FROM XZXK_YLYLQX_BA_SQS T WHERE T.SQID = YWID;
--根据不同的业务类型做相应处理
IF (V_YWLX = 'A') THEN
--备案-----------------------------------------------
UPDATE GG_XKZ_YLYLQXPZ T
SET T.CZZT = 'V', T.GSBS = 'Y', T.PZZT = 'Y'
WHERE T.SQID = YWID;
--插入主表信息
INSERT INTO XZXK_YLYLQX_XX_QB
(XXBID,
CPLX,
CPID,
CPMC,
CPYWMC,
CPLDH,
CPLMC,
YJCPLB,
CPLXH,
EJCPLB,
JGTZ,
XHGG,
CPMS,
YQYT,
CPYXQ,
QYID,
QYMC,
QYYWMC,
ZCDZ,
ZCDSZSF,
ZCDSZQX,
ZCDYWMC,
SCDZ,
BARSZD,
ZZJGDM,
LXR,
LXDH,
CZ,
YB,
DZXX,
QTXYSMDWT,
INSTNUM,
LASTDATE,
DATEXC)
SELECT T.SQID,
T.CPLX,
T.CPID,
T.CPMC,
T.CPYWMC,
T.CPLDH,
T.CPLMC,
T.YJCPLB,
T.CPLXH,
T.EJCPLB,
T.JGTZ,
T.XHGG,
T.CPMS,
T.YQYT,
T.CPYXQ,
T.QYID,
T.QYMC,
T.QYYWMC,
T.ZCDZ,
T.ZCDSZSF,
T.ZCDSZQX,
T.ZCDYWMC,
T.SCDZ,
T.BARSZD,
T.ZZJGDM,
T.LXR,
T.LXDH,
T.CZ,
T.YB,
T.DZXX,
T.QTXYSMDWT,
F_GETSLBS AS INSTNUM,
SYSDATE AS LASTDATE,
'11' AS DATEXC
FROM XZXK_YLYLQX_BA_SQS T
WHERE T.SQID = YWID;
--插入规格/型号表信息
INSERT INTO XZXK_YLYLQX_XX_GGXH
(BZJ, XXBID, CPID, CPMC, CPXH, INSTNUM, LASTDATE, DATEXC)
SELECT T .BZJ,
T .SQID AS XXBID,
T .CPID,
T .CPMC,
T .CPXH,
F_GETSLBS AS INSTNUM,
SYSDATE AS LASTDATE,
'11' AS DATEXC
FROM XZXK_YLYLQX_BA_GGXH T
WHERE T.SQID = YWID;
--插入生产地址
INSERT INTO XZXK_YLYLQX_XX_SCDZ
(BZJ,
XXBID,
JTDZ,
SZSF,
SZQX,
SZJD,
LXDH,
YB,
INSTNUM,
LASTDATE,
DATEXC)
SELECT T .BZJ,
T .SQID AS XXBID,
T .JTDZ,
T .SZSF,
T .SZQX,
T .SZJD,
T .LXDH,
T .YB,
F_GETSLBS AS INSTNUM,
SYSDATE AS LASTDATE,
'11' AS DATEXC
FROM XZXK_YLYLQX_BA_SCDZ T
WHERE T.SQID = YWID;
--通过凭证表更新信息全表
SELECT T.*
INTO V_GG_XKZ_YLYLQXPZ
FROM GG_XKZ_YLYLQXPZ T
WHERE T.SQID = YWID;
UPDATE XZXK_YLYLQX_XX_QB T
SET T .BAH = V_GG_XKZ_YLYLQXPZ.BAH,
T .QYID = V_GG_XKZ_YLYLQXPZ.BARID,
T .QYMC = V_GG_XKZ_YLYLQXPZ.BARMC,
T .ZZJGDM = V_GG_XKZ_YLYLQXPZ.ZZJGDM,
T .ZCDZ = V_GG_XKZ_YLYLQXPZ.ZCDZ,
T .SCDZ = V_GG_XKZ_YLYLQXPZ.SCDZ,
T .CPMC = V_GG_XKZ_YLYLQXPZ.CPMC,
T .XHGG = V_GG_XKZ_YLYLQXPZ.BZGG,
T .CPMS = V_GG_XKZ_YLYLQXPZ.CPMS,
T .YQYT = V_GG_XKZ_YLYLQXPZ.YQYT,
T .CPYXQ = V_GG_XKZ_YLYLQXPZ.CPYXQ,
T .BZ = V_GG_XKZ_YLYLQXPZ.BZ,
T .BADWBH = V_GG_XKZ_YLYLQXPZ.BADWBH,
T .BADW = V_GG_XKZ_YLYLQXPZ.BADW,
T .BARQ = V_GG_XKZ_YLYLQXPZ.BARQ,
T.PZZT = V_GG_XKZ_YLYLQXPZ.PZZT,
T .INSTNUM = F_GETSLBS,
T .LASTDATE = SYSDATE,
T .DATEXC = '11'
WHERE T.XXBID = YWID;
ELSIF (V_YWLX = 'G') THEN
--变更-----------------------------------------------
SELECT BAH INTO V_BAH FROM XZXK_YLYLQX_BA_SQS WHERE SQID = YWID;
SELECT XXBID INTO V_XXBID FROM XZXK_YLYLQX_XX_QB WHERE BAH = V_BAH;
SELECT * INTO V_BA_SQS FROM XZXK_YLYLQX_BA_SQS WHERE SQID = YWID;
SELECT * INTO V_GG_XKZ_YLYLQXPZ FROM GG_XKZ_YLYLQXPZ WHERE SQID = YWID;
--有效一条状态设置为无效
UPDATE GG_XKZ_YLYLQXPZ T
SET T.CZZT = 'I',
T.PZZT = 'N',
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.CZZT = 'V'
AND T.PZZT = 'Y'
AND T.BAH = V_BAH;
--最新一条设置为有效
UPDATE GG_XKZ_YLYLQXPZ T
SET T.PZZT = 'Y',
T.CZZT = 'V',
T.DYBS = '000',
T.GSBS = 'Y',
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.BAH = V_BAH
AND T.SQID = YWID
AND T.CZZT = 'T';
--
UPDATE XZXK_YLYLQX_XX_QB
SET CPLX = V_BA_SQS.CPLX,
CPID = V_BA_SQS.CPID,
CPMC = V_BA_SQS.CPMC,
CPYWMC = V_BA_SQS.CPYWMC,
CPLDH = V_BA_SQS.CPLDH,
CPLMC = V_BA_SQS.CPLMC,
YJCPLB = V_BA_SQS.YJCPLB,
CPLXH = V_BA_SQS.CPLXH,
EJCPLB = V_BA_SQS.EJCPLB,
JGTZ = V_BA_SQS.JGTZ,
XHGG = V_BA_SQS.XHGG,
CPMS = V_BA_SQS.CPMS,
YQYT = V_BA_SQS.YQYT,
CPYXQ = V_BA_SQS.CPYXQ,
QYID = V_BA_SQS.QYID,
QYMC = V_BA_SQS.QYMC,
QYYWMC = V_BA_SQS.QYYWMC,
ZCDZ = V_BA_SQS.ZCDZ,
ZCDSZSF = V_BA_SQS.ZCDSZSF,
ZCDSZQX = V_BA_SQS.ZCDSZQX,
ZCDYWMC = V_BA_SQS.ZCDYWMC,
SCDZ = V_BA_SQS.SCDZ,
BARSZD = V_BA_SQS.BARSZD,
ZZJGDM = V_BA_SQS.ZZJGDM,
LXR = V_BA_SQS.LXR,
LXDH = V_BA_SQS.LXDH,
CZ = V_BA_SQS.CZ,
YB = V_BA_SQS.YB,
DZXX = V_BA_SQS.DZXX,
QTXYSMDWT = V_BA_SQS.QTXYSMDWT,
BAH = V_BA_SQS.BAH,
BZ = V_BA_SQS.BZ,
BADWBH = V_BA_SQS.BADWBH,
BADW = V_BA_SQS.BADW,
BARQ = V_BA_SQS.BARQ,
JDJC = '',
BJRY = '',
BJRQ = '',
INSTNUM = F_GETSLBS,
LASTDATE = SYSDATE,
DATEXC = '11'
WHERE XXBID = V_XXBID;
INSERT INTO PUB_TABLE_DATA_DELEXC
(ID,
TABLENAME,
TABLEPKNAME,
TABLEPK,
DELFLAG,
INSTNUM,
LASTDATE,
DATEXC)
SELECT SYS_GUID(),
'XZXK_YLYLQX_XX_GGXH',
'BZJ',
BZJ AS TABLEPK,
'N',
F_GETSLBS(),
SYSDATE,
'11'
FROM XZXK_YLYLQX_XX_GGXH
WHERE XXBID = V_XXBID;
DELETE FROM XZXK_YLYLQX_XX_GGXH WHERE XXBID = V_XXBID;
INSERT INTO PUB_TABLE_DATA_DELEXC
(ID,
TABLENAME,
TABLEPKNAME,
TABLEPK,
DELFLAG,
INSTNUM,
LASTDATE,
DATEXC)
SELECT SYS_GUID(),
'XZXK_YLYLQX_XX_BGQK',
'BZJ',
BZJ AS TABLEPK,
'N',
F_GETSLBS(),
SYSDATE,
'11'
FROM XZXK_YLYLQX_XX_BGQK
WHERE XXBID = V_XXBID;
DELETE FROM XZXK_YLYLQX_XX_BGQK WHERE XXBID = V_XXBID;
INSERT INTO PUB_TABLE_DATA_DELEXC
(ID,
TABLENAME,
TABLEPKNAME,
TABLEPK,
DELFLAG,
INSTNUM,
LASTDATE,
DATEXC)
SELECT SYS_GUID(),
'XZXK_YLYLQX_XX_SCDZ',
'BZJ',
BZJ AS TABLEPK,
'N',
F_GETSLBS(),
SYSDATE,
'11'
FROM XZXK_YLYLQX_XX_SCDZ
WHERE XXBID = V_XXBID;
DELETE FROM XZXK_YLYLQX_XX_SCDZ WHERE XXBID = V_XXBID;
--插入规格/型号表信息
INSERT INTO XZXK_YLYLQX_XX_GGXH
(BZJ, XXBID, CPID, CPMC, CPXH, INSTNUM, LASTDATE, DATEXC)
SELECT T .BZJ,
V_XXBID,
T .CPID,
T .CPMC,
T .CPXH,
F_GETSLBS AS INSTNUM,
SYSDATE AS LASTDATE,
'11' AS DATEXC
FROM XZXK_YLYLQX_BA_GGXH T
WHERE T.SQID = YWID;
--插入生产地址
INSERT INTO XZXK_YLYLQX_XX_SCDZ
(BZJ,
XXBID,
JTDZ,
SZSF,
SZQX,
SZJD,
LXDH,
YB,
INSTNUM,
LASTDATE,
DATEXC)
SELECT T .BZJ,
V_XXBID,
T .JTDZ,
T .SZSF,
T .SZQX,
T .SZJD,
T .LXDH,
T .YB,
F_GETSLBS AS INSTNUM,
SYSDATE AS LASTDATE,
'11' AS DATEXC
FROM XZXK_YLYLQX_BA_SCDZ T
WHERE T.SQID = YWID;
--变更情况
INSERT INTO XZXK_YLYLQX_XX_BGQK
(BZJ, XXBID, SXH, BAH, BGNR, INSTNUM, LASTDATE, DATEXC)
SELECT BZJ, V_XXBID, SXH, BAH, BGNR, F_GETSLBS, SYSDATE, '11'
FROM GG_XKZ_YLYLQXPZ_BGQK
WHERE BAH = V_BAH
AND PZZJ = V_GG_XKZ_YLYLQXPZ.PZZJ;
--凭证更新到信息表
UPDATE XZXK_YLYLQX_XX_QB
SET BAH = V_GG_XKZ_YLYLQXPZ.BAH,
ZZJGDM = V_GG_XKZ_YLYLQXPZ.ZZJGDM,
ZCDZ = V_GG_XKZ_YLYLQXPZ.ZCDZ,
SCDZ = V_GG_XKZ_YLYLQXPZ.SCDZ,
CPMC = V_GG_XKZ_YLYLQXPZ.CPMC,
CPMS = V_GG_XKZ_YLYLQXPZ.CPMS,
YQYT = V_GG_XKZ_YLYLQXPZ.YQYT,
CPYXQ = V_GG_XKZ_YLYLQXPZ.CPYXQ,
BZ = V_GG_XKZ_YLYLQXPZ.BZ,
BADWBH = V_GG_XKZ_YLYLQXPZ.BADWBH,
BADW = V_GG_XKZ_YLYLQXPZ.BADW,
BARQ = V_GG_XKZ_YLYLQXPZ.BARQ,
ZXRQ = V_GG_XKZ_YLYLQXPZ.ZXRQ,
ZXDWBH = V_GG_XKZ_YLYLQXPZ.ZXDWBH,
ZXDW = V_GG_XKZ_YLYLQXPZ.ZXDW,
JDJC = V_GG_XKZ_YLYLQXPZ.JDJC,
BJRY = V_GG_XKZ_YLYLQXPZ.BJRY,
BJRQ = V_GG_XKZ_YLYLQXPZ.BJRQ,
INSTNUM = F_GETSLBS,
LASTDATE = SYSDATE,
DATEXC = '11'
WHERE XXBID = V_XXBID;
ELSIF (V_YWLX = 'Z') THEN
--补证-----------------------------------------------
SELECT T.BAH INTO V_BAH FROM XZXK_YLYLQX_BA_SQS T WHERE T.SQID = YWID;
--有效一条状态设置为无效
UPDATE GG_XKZ_YLYLQXPZ T
SET T.CZZT = 'I',
T.PZZT = 'N',
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.CZZT = 'V'
AND T.PZZT = 'Y'
AND T.BAH = V_BAH;
--最新一条设置为有效
UPDATE GG_XKZ_YLYLQXPZ T
SET T.PZZT = 'Y',
T.CZZT = 'V',
T.DYBS = '000',
T.GSBS = 'Y',
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.BAH = V_BAH
AND T.SQID = YWID
AND T.CZZT = 'T';
--更新信息全表
SELECT T.*
INTO V_GG_XKZ_YLYLQXPZ
FROM GG_XKZ_YLYLQXPZ T
WHERE T.SQID = YWID;
UPDATE XZXK_YLYLQX_XX_QB T
SET T.BZ = V_GG_XKZ_YLYLQXPZ.BZ,
T.JDJC = V_GG_XKZ_YLYLQXPZ.JDJC,
T.BJRY = V_GG_XKZ_YLYLQXPZ.BJRY,
T.BJRQ = V_GG_XKZ_YLYLQXPZ.BJRQ,
T.PZZT = V_GG_XKZ_YLYLQXPZ.PZZT,
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.BAH = V_BAH;
ELSIF (V_YWLX = 'X') THEN
--注销-----------------------------------------------
SELECT T.BAH INTO V_BAH FROM XZXK_YLYLQX_BA_SQS T WHERE T.SQID = YWID;
--有效一条状态设置为无效
UPDATE GG_XKZ_YLYLQXPZ T
SET T.CZZT = 'I',
T.PZZT = 'N',
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.CZZT = 'V'
AND T.BAH = V_BAH;
--最新一条设置为有效
UPDATE GG_XKZ_YLYLQXPZ T
SET T.CZZT = 'V',
T.DYBS = '000',
T.GSBS = 'Y',
T.PZZT = 'N',
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.BAH = V_BAH
AND T.SQID = YWID
AND T.CZZT = 'T';
--更新信息全表
SELECT T.*
INTO V_GG_XKZ_YLYLQXPZ
FROM GG_XKZ_YLYLQXPZ T
WHERE T.SQID = YWID;
UPDATE XZXK_YLYLQX_XX_QB T
SET T.BZ = V_GG_XKZ_YLYLQXPZ.BZ,
T.ZXDWBH = V_GG_XKZ_YLYLQXPZ.ZXDWBH,
T.ZXDW = V_GG_XKZ_YLYLQXPZ.ZXDW,
T.ZXRQ = V_GG_XKZ_YLYLQXPZ.ZXRQ,
T.JDJC = V_GG_XKZ_YLYLQXPZ.JDJC,
T.BJRY = V_GG_XKZ_YLYLQXPZ.BJRY,
T.BJRQ = V_GG_XKZ_YLYLQXPZ.BJRQ,
T.PZZT = V_GG_XKZ_YLYLQXPZ.PZZT,
T.INSTNUM = F_GETSLBS,
T.LASTDATE = SYSDATE,
T.DATEXC = '11'
WHERE T.BAH = V_BAH;
END IF;
FLAG := 'Y';
COMMIT;
EXCEPTION
WHEN V_RAISE THEN
FLAG := 'N';
ROLLBACK;
WHEN NO_DATA_FOUND THEN
FLAG := 'N';
ROLLBACK;
END DYLTWZDSJ_CP_BA;
存储过程之ROWTYPE 使用事例的更多相关文章
- 存储过程之rowtype 使用
CREATE OR REPLACE PROCEDURE "DYLYLQX_SC_BA_1" (YWID IN VARCHAR2, FLAG OUT VARCHAR2) IS V_R ...
- Oracle内置存储过程之DBMS_OUTPUT
1.DBMS_OUTPUT 1.1 作用: 调试PL/SQL程序 1.2 相关函数: 命令 作用 备注 enable 在serveroutput on的情况下,用来使dbms_output生效(默认即 ...
- Code First系列之视图,存储过程和异步API
返回<8天掌握EF的Code First开发>总目录 本篇目录 视图View 存储过程 使用存储过程CRUD 异步API 本章小结 自我测试 本系列的源码本人已托管于coding上:点击查 ...
- MySQL 存储过程 经常使用语法
MySQL 存储过程是从 MySQL 5.0 開始添加的新功能.存储过程的长处有一箩筐.只是最基本的还是运行效率和SQL 代码封装.特别是 SQL 代码封装功能,假设没有存储过程,在外部程序訪问数据库 ...
- mysql:视图,触发器,事务,存储过程,函数
一.视图 视图是一个虚拟表并不是(正实存在的) 创建老师表 create table teacher( id int primary key auto_increment, tname varchar ...
- MySQL视图,触发器,事务,存储过程,函数
create triggr triafterinsertcmdlog after insert on cmd_log FOR EACH ROW trigger_body .#NEW : 代表新的记录 ...
- MySQL死锁[转]
案例描述 在定时脚本运行过程中,发现当备份表格的sql语句与删除该表部分数据的sql语句同时运行时,mysql会检测出死锁,并打印出日志. 两个sql语句如下: (1)inse ...
- [经验分享] MySQL Innodb表导致死锁日志情况分析与归纳【转,纯学习】
在定时脚本运行过程中,发现当备份表格的sql语句与删除该表部分数据的sql语句同时运行时,mysql会检测出死锁,并打印出日志. 两个sql语句如下: (1)insert into backup_ta ...
- day 7-20 视图,触发器,事务
一.视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名称]即可获取结果集,可以将该结果集当做表来使用. 使用视图我们可以把查询过程中的 ...
随机推荐
- mysql去掉空格换行符
http://blog.csdn.net/gt219/article/details/52038382
- 【Python】ModuleNotFoundError: No module named 'matplotlib.pyplot'
安装好matplotlib后,很激动的建立了一个文件夹matplotlib,并且在其下面建立了,mpl_squraes.py文件,代码编辑完成以后,点击运行,报错如下: 仔细分析了之后,发现是文件夹名 ...
- Leetcode Array 11 Container With Most Water
题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, a ...
- 试验笔记 - 使用7-ZIP压缩来减小APK安装包体积
7-ZIP版本:9.20 x86 And x64 Windows(2010-11-18) 1. 将APK包解压到文件夹2. 全选所有文件,右键“添加到压缩包”3.“压缩格式”必须“zip”4.“压缩等 ...
- java 中的CountDownLatch
直接使用thread可以使用thread和wait notify 实现顺序执行 线程池中可以使用CountDownLatch 进行顺序执行 package com.test; import java. ...
- apt-mirror 校验错误文件处理
apt-mirror是一个用来将Debian或Ubuntu的软件源镜像到本地的工具,这个工具工作得非常好,不过有的时候由于网络问题,会有一些文件的校验是失败的,但apt-mirror并不能发现,等到最 ...
- C#中方法中 ref 和 out的使用
案例1: static void Main() { , , , }; int numLargerThan10,numLargerThan100,numLargerThan1000 ; Proc(ary ...
- 【Python基础】之不同的文件在不同目录下导入指定模块的方法
如下图三个文件的目录路径 – project |– 1 | |– 2 | | |– 3 | | | |– owen.py ...
- 【WPF学习笔记】之如何传递第一个登录界面的值到下一个页面显示:动画系列之(三)
... ... 承接系列(二) 在之前的登录后台已设置发送到主界面: 在主界面接收传递的值: using System; using System.Collections.Generic; using ...
- 018 nginx与第三模块整合[一致性哈希模块整合]
nginx第三方模块官网:http://wiki.nginx.org/HttpUpstreamConsistentHash nginx第三方模块下载地址:https://github.com/repl ...