CREATE OR REPLACE PROCEDURE P_OP_INFO_AND_PAY_NEW (
-- --------------------------------------------
-- 수술정보 등록(수정), 비용정보 등록 --
-- 작성자 : 유성미 --
-- IN : 수술정보 --
-- 비용정보 --
-- OUT : 결과코드 --
-- 결과 메시지 --
-- ---------------------------------------------
-- --------------------------------------------
-- 수술정보 등록(수정), 비용정보 등록 --
-- 수술 결과 추가 보강수술 정보 추가
-- 수정인 : 한은미 --
-- IN : 수술정보 --
-- 비용정보 --
-- OUT : 결과코드 --
-- 결과 메시지 --
-- ---------------------------------------------
--수술정보
I_ID IN OP_INFO.ID%TYPE
, I_OP_INFO_SEQ IN OP_INFO.OP_INFO_SEQ%TYPE
, I_OP_APP_SEQ IN OP_INFO.OP_APP_SEQ%TYPE
, I_OP_CD IN OP_INFO.OP_CD%TYPE
, I_OP_DT IN OP_INFO.OP_DT%TYPE
, I_DIR_CD IN OP_INFO.DIR_CD%TYPE
, I_ETC IN OP_INFO.ETC%TYPE
, I_OP_CON IN OP_INFO.OP_CON%TYPE
, I_SEC_CD IN OP_INFO.SEC_CD%TYPE
, I_RESULT_CD IN OP_INFO.OP_RESULT%TYPE
--비용정보
, I_PAY_DT IN PAY.PAY_DT%TYPE
, I_PAY_COUNT IN PAY.PAY_COUNT%TYPE
, I_AMT_CASH IN PAY.AMT_CASH%TYPE
, I_AMT_CARD IN PAY.AMT_CASH%TYPE
, I_AMT_ARREAR IN PAY.AMT_ARREAR%TYPE
, I_AMT_REC IN PAY.AMT_REC%TYPE
, I_DEDUC_DT IN PAY.DEDUC_DT%TYPE
, I_DEDUC_YN IN PAY.DEDUC_YN%TYPE
, I_REC_DT IN PAY.REC_DT%TYPE
, I_REC_YN IN PAY.REC_YN%TYPE
, I_REC_NO IN PAY.REC_NO%TYPE
, I_REC_NUMBER IN PAY.REC_NUMBER%TYPE
, I_CASH_CHECK_YN IN PAY.CASH_CHECK_YN%TYPE
, I_CARD_CHECK_YN IN PAY.CARD_CHECK_YN%TYPE
, I_REC_CHECK_YN IN PAY.REC_CHECK_YN%TYPE
, I_SLOGINID IN OP_INFO.CREATE_ID%TYPE
, O_MSG_CODE OUT VARCHAR2
, O_MSG_NAME OUT VARCHAR2
-- 추가 수술
, E_ADD_OP_APP_SEQ IN ADD_OP_APP.ADD_OP_APP_SEQ%TYPE
, E_DIR_CD IN ADD_OP_APP.DIR_CD%TYPE
, E_OP_CD IN ADD_OP_APP.OP_CD%TYPE
, E_ID IN ADD_OP_APP.ID%TYPE
, E_UPDATE_ID IN ADD_OP_APP.UPDATE_ID%TYPE
) IS
L_COUNT NUMBER;
A_COUNT NUMBER;
V_OP_INFO_SEQ PAY.OP_INFO_SEQ%TYPE;
V_ADD_OP_INFO_SEQ ADD_OP_APP.ADD_OP_APP_SEQ%TYPE;
BEGIN
SELECT COUNT(*), NVL(MAX(ADD_OP_APP_SEQ),0)
INTO A_COUNT, V_ADD_OP_INFO_SEQ
FROM ADD_OP_APP
WHERE ADD_OP_APP_SEQ = E_ADD_OP_APP_SEQ
AND ID = E_ID;
SELECT COUNT(*), NVL(MAX(OP_INFO_SEQ),0)
INTO L_COUNT, V_OP_INFO_SEQ
FROM OP_INFO
WHERE OP_APP_SEQ = I_OP_APP_SEQ
AND ID = I_ID;
-- 데이터가 존재하지 않을때
IF L_COUNT = 0 THEN
SELECT OP_INFO_SEQ.NEXTVAL
INTO V_OP_INFO_SEQ
FROM DUAL ;
UPDATE OP_APP SET
ARRIVE_YN = 'Y'
,UPDATE_ID = I_SLOGINID
,UPDATE_DT = SYSDATE
WHERE OP_APP_SEQ = I_OP_APP_SEQ ;
INSERT INTO OP_INFO(
ID
, OP_INFO_SEQ
, OP_APP_SEQ
, OP_CD
, OP_DT
, DIR_CD
, ETC
, OP_CON
, CREATE_ID
, CREATE_DT
, UPDATE_ID
, UPDATE_DT
, SEC_CD
, OP_RESULT)
VALUES (
I_ID
, V_OP_INFO_SEQ
, I_OP_APP_SEQ
, I_OP_CD
, I_OP_DT
, I_DIR_CD
, I_ETC
, I_OP_CON
, I_SLOGINID
, SYSDATE
, I_SLOGINID
, SYSDATE
, I_SEC_CD
,I_RESULT_CD
);
IF I_PAY_COUNT > 0 THEN
/******************************************************
* 기존 PAY 소득공제, 현금영수증 정보 업데이트 처리
******************************************************/
UPDATE PAY SET
CASH_CHECK_YN=I_CASH_CHECK_YN
, CARD_CHECK_YN=I_CARD_CHECK_YN
, REC_CHECK_YN=I_REC_CHECK_YN
, DEDUC_YN = I_DEDUC_YN
, DEDUC_DT = I_DEDUC_DT
, REC_YN = I_REC_YN
, REC_DT = I_REC_DT
, REC_NO = I_REC_NO
, REC_NUMBER = I_REC_NUMBER
, UPDATE_ID = I_SLOGINID
, UPDATE_DT = SYSDATE
WHERE OP_INFO_SEQ = V_OP_INFO_SEQ ;
INSERT INTO PAY(
PAY_SEQ
, OP_INFO_SEQ
, ID
, PAY_DT
, AMT_CASH
, AMT_CARD
, AMT_REC
, AMT_ARREAR
, DEDUC_YN
, DEDUC_DT
, REC_YN
, REC_DT
, REC_NO
, REC_NUMBER
, CREATE_ID
, CREATE_DT
, UPDATE_ID
, UPDATE_DT
, SEC_CD
, PAY_COUNT
,CASH_CHECK_YN
,CARD_CHECK_YN
,REC_CHECK_YN
) VALUES (
PAY_SEQ.NEXTVAL
, V_OP_INFO_SEQ
, I_ID
, I_PAY_DT
, I_AMT_CASH
, I_AMT_CARD
, I_AMT_REC
, I_AMT_ARREAR
, I_DEDUC_YN
, I_DEDUC_DT
, I_REC_YN
, I_REC_DT
, I_REC_NO
, I_REC_NUMBER
, I_SLOGINID
, SYSDATE
, I_SLOGINID
, SYSDATE
, I_SEC_CD
, I_PAY_COUNT
,I_CASH_CHECK_YN
,I_CARD_CHECK_YN
,I_REC_CHECK_YN
);
END IF;
ELSE
UPDATE OP_INFO SET
OP_CD = I_OP_CD
, OP_DT = I_OP_DT
, DIR_CD = I_DIR_CD
, ETC = I_ETC
, OP_CON = I_OP_CON
, OP_RESULT = I_RESULT_CD
, SEC_CD = I_SEC_CD
WHERE ID = I_ID
AND OP_INFO_SEQ = V_OP_INFO_SEQ
AND OP_APP_SEQ = I_OP_APP_SEQ;
IF I_PAY_COUNT > 0 THEN
/******************************************************
* 기존 PAY 소득공제, 현금영수증 정보 업데이트 처리
******************************************************/
UPDATE PAY SET
DEDUC_YN = I_DEDUC_YN
, DEDUC_DT = I_DEDUC_DT
, REC_YN = I_REC_YN
, REC_DT = I_REC_DT
, REC_NO = I_REC_NO
, REC_NUMBER = I_REC_NUMBER
, UPDATE_ID = I_SLOGINID
, UPDATE_DT = SYSDATE
, CASH_CHECK_YN=I_CASH_CHECK_YN
, CARD_CHECK_YN=I_CARD_CHECK_YN
, REC_CHECK_YN=I_REC_CHECK_YN
WHERE OP_INFO_SEQ = V_OP_INFO_SEQ ;
INSERT INTO PAY(
PAY_SEQ
, OP_INFO_SEQ
, ID
, PAY_DT
, AMT_CASH
, AMT_CARD
, AMT_REC
, AMT_ARREAR
, DEDUC_YN
, DEDUC_DT
, REC_YN
, REC_DT
, REC_NO
, REC_NUMBER
, CREATE_ID
, CREATE_DT
, UPDATE_ID
, UPDATE_DT
, SEC_CD
, PAY_COUNT
,CASH_CHECK_YN
,CARD_CHECK_YN
,REC_CHECK_YN
) VALUES (
PAY_SEQ.NEXTVAL
, V_OP_INFO_SEQ
, I_ID
, I_PAY_DT
, I_AMT_CASH
, I_AMT_CARD
, I_AMT_REC
, I_AMT_ARREAR
, I_DEDUC_YN
, I_DEDUC_DT
, I_REC_YN
, I_REC_DT
, I_REC_NO
, I_REC_NUMBER
, I_SLOGINID
, SYSDATE
, I_SLOGINID
, SYSDATE
, I_SEC_CD
, I_PAY_COUNT
,I_CASH_CHECK_YN
,I_CARD_CHECK_YN
,I_REC_CHECK_YN
);
ELSE
/******************************************************
* 기존 PAY 소득공제, 현금영수증 정보 업데이트 처리
******************************************************/
UPDATE PAY SET
DEDUC_YN = I_DEDUC_YN
, DEDUC_DT = I_DEDUC_DT
, REC_YN = I_REC_YN
, REC_DT = I_REC_DT
, REC_NO = I_REC_NO
, REC_NUMBER = I_REC_NUMBER
, UPDATE_ID = I_SLOGINID
, UPDATE_DT = SYSDATE
, CASH_CHECK_YN=I_CASH_CHECK_YN
, CARD_CHECK_YN=I_CARD_CHECK_YN
, REC_CHECK_YN=I_REC_CHECK_YN
WHERE OP_INFO_SEQ = V_OP_INFO_SEQ ;
/*IF L_COUNT = 0 THEN
INSERT INTO ADD_OP_APP (
ADD_OP_APP_SEQ
,ID
,ADD_OP_APP_DT
,ADD_OP_APP_TM
,ETC
,ARRIVE_YN
,OP_CD
,SEC_CD
,CREATE_ID
,CREATE_DT
,UPDATE_ID
,UPDATE_DT
,DIR_CD)
VALUES (
ADD_OP_APP_SEQ.NEXTVAL
,E_ID
,E_ADD_OP_DT
,E_ADD_OP_APP_TM
,E_ETC
,E_ARRIVE_YN
,E_OP_CD
,E_SEC_CD
,E_CREATE_ID
,SYSDATE
,E_UPDATE_ID
,SYSDATE
,E_DIR_CD);
END IF;*/
IF A_COUNT > 0 THEN
UPDATE ADD_OP_APP SET
OP_CD = E_OP_CD
,DIR_CD = E_DIR_CD
,UPDATE_ID = E_UPDATE_ID
,UPDATE_DT = SYSDATE
WHERE ADD_OP_APP_SEQ = E_ADD_OP_APP_SEQ;
END IF;
END IF;
END IF;
--결과 처리
COMMIT ;
O_MSG_CODE := 'OK' ;
O_MSG_NAME := '저장되었습니다.' ;
RETURN ;
-- 예외 처리
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
O_MSG_CODE := 'ERR' ;
O_MSG_NAME := ' 저장시 에러가 발생되었습니다.'||'SQLCODE:'||SQLCODE ;
END ;
값은 정상적으로 들어가긴 하는데요. 예외처리을 제가 잘못 한건가요. 자꾸 값은 들어 가는데. 에러가 난다고 나오네요. 좀도와주세요.