我的退休程序修正过程
1 CREATE OR REPLACE PROCEDURE WYL_ZZZTXXZ(PI_AAC002 VARCHAR2, 2 BAE001 VARCHAR2, 3 PO_FHZ OUT VARCHAR2, 4 PO_MSG OUT VARCHAR2) 5 --在职转退休有问题人员的数据修正,卫永乐,20150120 6 IS 7 V_AAC001 NUMBER(20); 8 V_AC20_ZXND NUMBER(4); --ac20的最小年度 9 V_SIC86_ZXND NUMBER(4); 10 V_AAB001 NUMBER(20); 11 V_SAC11_COUNT NUMBER(2); --转移的总数 12 V_GRBH NUMBER(20); 13 V_BAE001 AC01.BAE001%TYPE; 14 BEGIN 15 SELECT LENGTH(PI_AAC002) INTO V_GRBH FROM DUAL; 16 IF V_GRBH >= 15 THEN 17 /* 18 如果入参长度大于15位,那么就是身份证,如果小于15为,那么就认为是aac001 19 */ 20 BEGIN 21 SELECT AAC001 INTO V_AAC001 FROM AC01 WHERE AAC002 = PI_AAC002; 22 EXCEPTION 23 WHEN NO_DATA_FOUND THEN 24 PO_FHZ := '-1'; 25 PO_MSG := '没有找到对应的AAC001,请确认是否有问题,你的查询语句:' || 26 'select aac001 into v_aac001 from ac01 where aac002 = ' || 27 PI_AAC002; 28 RETURN; 29 END; 30 ELSE 31 V_AAC001 := PI_AAC002; 32 END IF; 33 SELECT AAB001 INTO V_AAB001 FROM AC01 WHERE AAC002 = PI_AAC002; 34 SELECT BAE001 INTO V_BAE001 FROM AC01 WHERE AAC002 = PI_AAC002; 35 /* 36 sac11数量,如果大于0,也要修正sic86 37 */ 38 SELECT COUNT(1) INTO V_SAC11_COUNT FROM SAC11 WHERE AAC001 = V_AAC001; 39 SELECT MIN(SUBSTR(AAE041, 1, 4)) 40 INTO V_AC20_ZXND 41 FROM AC20 42 WHERE AAC001 = V_AAC001; 43 SELECT MIN(AAE001) INTO V_SIC86_ZXND FROM SIC86 WHERE AAC001 = V_AAC001; 44 IF V_AC20_ZXND < V_SIC86_ZXND THEN 45 INSERT INTO T_TEMP_SXDY_I_19 AAC001 (AAC001) VALUES (V_AAC001); 46 --v_sic86_zxnd := v_sic86_zxnd-1 原因:下面循环补入sic86的时候要用 47 V_SIC86_ZXND := V_SIC86_ZXND - 1; 48 FOR ITEM IN V_AC20_ZXND .. V_SIC86_ZXND LOOP 49 INSERT INTO SIC86 50 (BAE001, 51 AAB001, 52 AAC001, 53 AAE001, 54 AAE140, 55 AAE013, 56 AIC040, 57 AIC041, 58 AIC042, 59 AIC058, 60 AIC072, 61 AIC074, 62 AIC075, 63 AIC076, 64 AIC077, 65 AIC078, 66 AIC079, 67 AAE087, 68 AIC081, 69 AAE035, 70 CIC818, 71 CIC819) 72 VALUES 73 (V_BAE001, 74 V_AAB001, 75 V_AAC001, 76 ITEM, 77 '110', 78 NULL, 79 0.00, 80 0.00, 81 0, 82 0.00, 83 0.00, 84 0.00, 85 0.00, 86 0.00, 87 0.00, 88 0.00, 89 0.00, 90 '0', 91 0, 92 0, 93 0, 94 0.00); 95 END LOOP; 96 PKG_SXDY_I_DYHD.REBIULD_SIC86(V_AAC001, '110', PO_FHZ, PO_MSG); 97 IF PO_FHZ != 1 THEN 98 RETURN; 99 ELSE 100 PO_MSG := 'ac20的最小参保年度小雨sic86的最小参保年度,不合理,系统尝试进行修复数据,且已经成功'; 101 RETURN; 102 END IF; 103 /* 如果存在转移,那么也进行修正*/ 104 ELSIF V_SAC11_COUNT > 0 THEN 105 PKG_SXDY_I_DYHD.REBIULD_SIC86(V_AAC001, '110', PO_FHZ, PO_MSG); 106 IF PO_FHZ = 1 THEN 107 RETURN; 108 ELSE 109 PO_MSG := V_AAC001 || ',该人员存在转移,已经进行了数据修复,且已经成功'; 110 RETURN; 111 END IF; 112 113 ELSE 114 PO_FHZ := -1; 115 PO_MSG := '系统没有进行修复,请检查,SELECT * FROM AC01 WHERE AAC001 = ' || V_AAC001; 116 RETURN; 117 END IF; 118 END;