Where The Streets Have No Name

sql에서 split기능 구현 본문

Developement/DataBase

sql에서 split기능 구현

highheat 2008. 1. 13. 09:47

a,b,c,d 이런 형식으로 들어온 값을 테이블형태로 출력

SELECT SUBSTR (txt, 
               INSTR(txt,',',1,LEVEL) + 1, 
               INSTR(txt,',',1,LEVEL + 1) - INSTR(txt,',',1,LEVEL) - 1)
FROM (SELECT ',' || :input || ',' txt
           FROM dual )
CONNECT BY LEVEL <= LENGTH(txt)- LENGTH(REPLACE(txt,',','')) - 1;