create or replace TYPE "T_IN_LIST_TAB_CLOB" AS TABLE OF CLOB -- 선언
create or replace PROCEDURE PR_SPLIT(P_IN_LIST IN CLOB, P_IN_DELIMITER IN VARCHAR2, O_CUR OUT SYS_REFCURSOR)
IS
V_TAB T_IN_LIST_TAB_CLOB := T_IN_LIST_TAB_CLOB();
V_IDX NUMBER;
V_TEXT CLOB;
V_SPLIT VARCHAR2(4000);
BEGIN
V_TEXT := P_IN_LIST || P_IN_DELIMITER;
LOOP
EXIT WHEN V_TEXT IS NULL;
V_SPLIT := SUBSTR(V_TEXT,1,4000);
V_IDX := INSTR(V_SPLIT, P_IN_DELIMITER, -1); -- 뒤에서 구분자로 특정값을 찾음
V_SPLIT := SUBSTR(V_TEXT,1,V_IDX); -- 1에서 가장뒤에 구분자값까지 짜름
LOOP
V_IDX := INSTR(V_SPLIT, P_IN_DELIMITER);
EXIT WHEN NVL(V_IDX, 0) = 0;
V_TAB.EXTEND;
V_TAB(V_TAB.LAST) := TRIM(SUBSTR(V_SPLIT, 1, V_IDX - 1));
V_SPLIT := SUBSTR(V_SPLIT, V_IDX + 1);
END LOOP;
V_TEXT := SUBSTR( V_TEXT, V_IDX+1 );
END LOOP;
OPEN O_CUR FOR
SELECT * FROM TABLE(V_TAB);
END;