1.5 KiB
저장용 데이터 자르기 PL/SQL
WITH TMP AS (SELECT :ar_data AS STR FROM DUAL) SELECT REGEXP_SUBSTR(TMP.STR, '[^|]+', 1, LEVEL) CODE FROM DUAL, TMP CONNECT BY REGEXP_SUBSTR(TMP.STR, '[|]+', 1, LEVEL) IS NOT NULL;
-- 데이터 1개 select substr(:ar_data, 1, instr(:ar_data, '|', 1) - 1) from dual
-- 나머지 데이터 select substr(:ar_data, instr(:ar_data, '|', 1) +1) from dual
행으로 분리
WITH TT AS
(
SELECT 'AAA,BBB,CCC,DDD.EEE' TXT FROM DUAL
)
SELECT TRIM(REGEXP_SUBSTR(TXT, '[^,]+', 1, LEVEL)) AS TXT
FROM TT
CONNECT BY INSTR(TXT, ',', 1, LEVEL - 1) > 0
열로 분리
SELECT A.TEXT_DATA ,TRIM(REGEXP_SUBSTR(REPLACE(TEXT_DATA, '|', '| '), '[^|]+', 1, 1, 'i')) AS DATA_01 ,TRIM(REGEXP_SUBSTR(REPLACE(TEXT_DATA, '|', '| '), '[^|]+', 1, 2, 'i')) AS DATA_02 ,TRIM(REGEXP_SUBSTR(REPLACE(TEXT_DATA, '|', '| '), '[^|]+', 1, 3, 'i')) AS DATA_03 ,TRIM(REGEXP_SUBSTR(REPLACE(TEXT_DATA, '|', '| '), '[^|]+', 1, 4, 'i')) AS DATA_04 ,TRIM(REGEXP_SUBSTR(REPLACE(TEXT_DATA, '|', '| '), '[^|]+', 1, 5, 'i')) AS DATA_05 ,TRIM(REGEXP_SUBSTR(REPLACE(TEXT_DATA, '|', '| '), '[^|]+', 1, 6, 'i')) AS DATA_06 ,TRIM(REGEXP_SUBSTR(REPLACE(TEXT_DATA, '|', '| '), '[^|]+', 1, 7, 'i')) AS DATA_07 ,TRIM(REGEXP_SUBSTR(REPLACE(TEXT_DATA, '|', '| '), '[^|]+', 1, 8, 'i')) AS DATA_08 FROM (SELECT :IN_DATA AS TEXT_DATA, REGEXP_COUNT(:IN_DATA, '|') AS C1_1 FROM DUAL) A