CREATE OR REPLACE TYPE EUS3_TYP_TO_ROW AS OBJECT
(
IDX NUMBER
, VAL VARCHAR2(4000)
);
CREATE OR REPLACE TYPE EUS3_TYP_TO_ROW_TBL AS TABLE OF EUS3_TYP_TO_ROW
;
CREATE OR REPLACE FUNCTION EUS3_FUNC_TO_ROW(IN_STR IN CLOB, IN_DELI IN VARCHAR2 DEFAULT ',')
RETURN EUS3_TYP_TO_ROW_TBL PIPELINED AS
V_DELI VARCHAR2(10) := IN_DELI;
V_DELI_LEN INT := LENGTH(V_DELI);
V_STR CLOB := IN_STR||V_DELI;
V_NUM NUMBER;
V_IDX NUMBER := 0;
V_TYPE EUS3_TYP_TO_ROW;
BEGIN
LOOP
EXIT WHEN IN_STR IS NULL;
V_NUM := INSTR(V_STR, V_DELI);
EXIT WHEN (NVL(V_NUM,0) = 0);
V_IDX := V_IDX + 1;
V_TYPE := EUS3_TYP_TO_ROW( V_IDX, SUBSTR(V_STR, 1, V_NUM-1) );
PIPE ROW (V_TYPE);
V_STR := SUBSTR(V_STR, V_NUM+V_DELI_LEN);
END LOOP;
RETURN;
END EUS3_FUNC_TO_ROW;
SELECT *
FROM TABLE(EUS3_FUNC_TO_ROW(
TO_CLOB('AA001,AA002')
))
;
'전산Tip > Oracle' 카테고리의 다른 글
ORACLE TABLE PRIVILEGE (0) | 2019.04.12 |
---|---|
[빈도추출] 오라클로 범주형, 연속형 빈도 추출 view 만들기 (3) | 2013.03.12 |
[ORACLE] 테이블 레이아웃 추출 수정.... (2) | 2012.03.29 |