CURSORTYPE으로 리턴을 하면 좋겠지만 그게 안되면 배열형식으로라도 리턴하려고 합니다.
이곳저곳에서 검색하면서 찾아보면서 작업하고 있는데 리턴타입을 어떤식으로 사용해야 할지 모르겠네요.
========================================================
CREATE OR REPLACE PROCEDURE ARR_TEST (
I_ORD_NO IN VARCHAR2
, O_RESULT OUT TYPES.CURSORTYPE
, O_RTNCD OUT VARCHAR2
, O_RTNMSG OUT VARCHAR2
, O_ARR_ORD_NO OUT ??
, O_ARR_S_SEQ OUT ??
)
IS
TYPE TBL_ORD_NO IS TABLE OF TBL_ORD_DELI.ORD_NO%TYPE
INDEX BY BINARY_INTEGER;
TYPE TBL_SEND_DT IS TABLE OF TBL_ORD_DELI.SEND_DT%TYPE
INDEX BY BINARY_INTEGER;
TYPE TBL_SEND_TM IS TABLE OF TBL_ORD_DELI.SEND_TM%TYPE
INDEX BY BINARY_INTEGER;
TYPE TBL_SEND_SEQ IS TABLE OF TBL_ORD_DELI.SEND_SEQ%TYPE
INDEX BY BINARY_INTEGER;
V_CNT BINARY_INTEGER := 0;
V_ORD_NO TBL_ORD_NO;
V_SEND_DT TBL_SEND_DT;
V_SEND_TM TBL_SEND_TM;
V_SEND_SEQ TBL_SEND_SEQ;
BEGIN
O_RTNCD := '0';
FOR SEND_ERR_LIST IN
(
SELECT ORD_NO, SEND_DT, SEND_TM, SEND_SEQ FROM TBL_ORD_DELI WHERE ORD_NO = I_ORD_NO AND S_TYPE = 'R'
MINUS
SELECT ORD_NO, SEND_DT, SEND_TM, SEND_SEQ FROM TBL_ORD_DELI WHERE ORD_NO = I_ORD_NO AND S_TYPE = 'S' AND RESP_CD = '0'
)
LOOP
V_CNT := V_CNT + 1;
V_ORD_NO(V_CNT) := SEND_ERR_LIST.ORD_NO;
V_SEND_DT(V_CNT) := SEND_ERR_LIST.SEND_DT;
V_SEND_TM(V_CNT) := SEND_ERR_LIST.SEND_TM;
V_SEND_SEQ(V_CNT) := SEND_ERR_LIST.SEND_SEQ;
END LOOP;
FOR CNT IN 1..V_CNT LOOP
SELECT
ORD_NO
,S_SEQ
INTO O_ARR_ORD_NO, O_ARR_S_SEQ
FROM TBL_ORD_DELI
WHERE ORD_NO = I_ORD_NO
AND SEND_DT = V_SEND_DT(CNT)
AND SEND_TM = V_SEND_TM(CNT)
AND SEND_SEQ = V_SEND_SEQ(CNT);
END LOOP;
O_RTNCD := '0';
O_RTNMSG := '';
EXCEPTION
WHEN OTHERS THEN
O_RTNCD := '1';
O_RTNMSG := TO_CHAR(SQLCODE) || ' ['||SQLERRM ||'] ';
END;
/