Run following query to split values seperated by comma(,)
SELECT TRIM( SUBSTR ( txt
, INSTR (txt, ',', 1, level ) + 1
, INSTR (txt, ',', 1, level+1) - INSTR (txt, ',', 1, level) -1
)
)
AS token
FROM ( SELECT ','||:in_string||',' AS txt FROM dual )
CONNECT BY level <= LENGTH(txt)-LENGTH(REPLACE(txt,',',''))-1
Example
-------
If value of in_string is entered as 1234,2,3,45,6,7,7,88,9,346
Output is
TOKEN
-----
1234
2
3
45
6
7
7
88
9
346
Reference:
Tom Kyte's Blog
10 Comments:
Thank u Suresh for posting this query.Its vey usefull.
Lakki, Thanks for your feedback.
Great query!!!
Few other good SQL queries can be found at:
http://infiniteandmore.blogspot.com/
Wonderf..
thank you so much...
Thank you very much for posting this script!
It's quite simple but not the obvious one!
Thank you very much Suresh ! Your blog is very useful, especially for a beginner like me :)
Thank u Suresh for posting this query for Splitting String using Oracle SQL 9i.Your blog is very useful, especially for a beginner like me :)
sap pp
Great query!
Dear suresh, thanks for this query very usefull for splitting the text
It's very useful, Thanks :)
Post a Comment