概述
--存储过程
--POL_REG_LCPOLTRANSACTION分别与POL_REG_LCCONT,POL_REG_LCPRODINSURELA,POL_REG_LCPRODUCT,POL_REG_LCBNF比较
CREATE OR REPLACE PROCEDURE prc_liuhaijun01 AS
cnt_a NUMBER;
cnt_b NUMBER;
cnt_c number;
cnt_d number;
TYPE ab IS RECORD(
a_transactionno POL_REG_LCPOLTRANSACTION.transactionno%TYPE,
b_transactionno POL_REG_LCBNF.transactionno%TYPE,
c_transactionno POL_REG_LCCONT.TRANSACTIONNO%TYPE,
d_transactionno POL_REG_LCPRODINSURELA.TRANSACTIONNO%TYPE,
e_transactionno POL_REG_LCPRODUCT.TRANSACTIONNO%TYPE);
rs ab;
CURSOR cur IS
SELECT *
FROM (SELECT a.transactionno AS a_transactionno,
b.transactionno AS b_transactionno,
c.transactionno AS c_transactionno,
d.transactionno AS d_transactionno,
e.transactionno AS e_transactionno
FROM (SELECT transactionno FROM POL_REG_LCPOLTRANSACTION) a
full join (SELECT transactionno FROM POL_REG_LCBNF) b
ON a.transactionno = b.transactionno
full join (SELECT transactionno FROM POL_REG_LCCONT) c
ON a.transactionno = c.transactionno
full join (SELECT transactionno FROM POL_REG_LCPRODINSURELA) d
ON a.transactionno = d.transactionno
full join (SELECT transactionno FROM POL_REG_LCPRODUCT) e
ON a.transactionno = e.transactionno)
WHERE a_transactionno IS NULL
OR b_transactionno IS NULL
OR c_transactionno IS NULL
OR d_transactionno IS NULL
OR e_transactionno IS NULL;
BEGIN
OPEN cur;
LOOP
FETCH cur
INTO rs;
EXIT WHEN cur%NOTFOUND;
IF rs.a_transactionno IS NOT NULL AND rs.b_transactionno IS NULL THEN
BEGIN
SELECT Count(1)
INTO cnt_b
FROM POL_REG_LCBNF
WHERE transactionno = rs.a_transactionno;
EXCEPTION
WHEN OTHERS THEN
cnt_b := 0;
END;
IF cnt_b = 0 THEN
INSERT INTO temp_liuhaijun
VALUES
(rs.a_transactionno, 'POL_REG_LCBNF', 22, '');
END IF;
END IF;
IF rs.a_transactionno IS NOT NULL AND rs.c_transactionno IS NULL THEN
BEGIN
SELECT Count(1)
INTO cnt_a
FROM POL_REG_LCCONT
WHERE transactionno = rs.a_transactionno;
EXCEPTION
WHEN OTHERS THEN
cnt_a := 0;
END;
IF cnt_a = 0 THEN
INSERT INTO temp_liuhaijun
VALUES
(rs.a_transactionno, 'POL_REG_LCCONT', 22, '');
END IF;
END IF;
IF rs.a_transactionno IS NOT NULL AND rs.d_transactionno IS NULL THEN
BEGIN
SELECT Count(1)
INTO cnt_c
FROM POL_REG_LCPRODINSURELA
WHERE transactionno = rs.a_transactionno;
EXCEPTION
WHEN OTHERS THEN
cnt_c := 0;
END;
IF cnt_c = 0 THEN
INSERT INTO temp_liuhaijun
VALUES
(rs.a_transactionno, 'POL_REG_LCPRODINSURELA', 22, '');
END IF;
END IF;
IF rs.a_transactionno IS NOT NULL AND rs.e_transactionno IS NULL THEN
BEGIN
SELECT Count(1)
INTO cnt_d
FROM POL_REG_LCPRODUCT
WHERE transactionno = rs.e_transactionno;
EXCEPTION
WHEN OTHERS THEN
cnt_d := 0;
END;
IF cnt_d = 0 THEN
INSERT INTO temp_liuhaijun
VALUES
(rs.a_transactionno, 'POL_REG_LCPRODUCT', 22, '');
END IF;
END IF;
END LOOP;
commit;
CLOSE cur;
END;
最后
以上就是年轻含羞草为你收集整理的存储过程,比较两个表的数据的全部内容,希望文章能够帮你解决存储过程,比较两个表的数据所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复