How to Split a comma separated string in Oracle using SUBSTR
and INSTR
.
String '20.4,12.5,3.5,0.2,0.2'.
I tried using the below code, but I'm unable get the value after the 2nd comma.
SELECT substr('20.4,12.5,3.5,0.2,0.2',0,instr('20.4,12.5,3.5,0.2,0.2',',')-1)
value FROM dual -- 1. 20.4
for second value i'm getting the entire string after 2nd comma.
SELECT substr('20.4,12.5,3.5,0.2,0.2',instr('20.4,12.5,3.5,0.2,0.2',',')+1,instr('20.4,
12.5,3.5,0.2,0.2',',',2,2)-1) st FROM dual -- result : 12.5,3.5,
I want the value after each comma, like
20.4
12.5
3.5 and so on.