CREATE OR REPLACE PROCEDURE IF_PROC
IS
O_CODE VARCHAR2(1);
O_MSG VARCHAR2(100 CHAR);
O_CNT NUMBER := 0;
BEGIN
FOR C_ROW IN (SELECT ...
FROM ...)
LOOP
BEGIN
INSERT INTO ....
O_CNT := O_CNT + 1;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
O_CODE := 'E';
O_MSG := 'I/F Fail';
DBMS_OUTPUT.PUT_LINE(O_CODE || ' : ' || SQLERRM);
INSERT INTO ERRORLOG (...)
VALUES (...);
COMMIT;
END;
END LOOP;
O_CODE := 'S';
O_MSG := 'I/F Success';
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
O_CODE := 'E';
O_MSG := 'I/F Fail';
DBMS_OUTPUT.PUT_LINE(O_CODE || ' : ' || SQLERRM);
INSERT INTO ERRORLOG (...)
VALUES (...);
COMMIT;
END;
/
예외처리 참조 :
https://blog.daonelab.com/post/24/394/