Extract from comma separated string
55913Apr 26 2011 — edited Apr 27 2011Hi,
I have a comma separated value coming in a column. I am able to extract the values separately using combination of substr, instr function.
However I am not able to control the end point of the concatenated value.
Any inputs would be appreciated.
Here is my Eg:
select table_name,
table_column_names,
substr(table_column_names, 1, instr(table_column_names,',',1,1)-1), -- first col
substr(table_column_names, instr(table_column_names,',',1,1)+1,
instr(table_column_names, ',', 1,2)
- instr(table_column_names, ',', 1,1)-1), -- second col
substr(table_column_names, instr(table_column_names,',',1,2)+1,
instr(table_column_names, ',', 1,3)
- instr(table_column_names, ',', 1,2)-1), -- third col
from test_tab
As you can see I can get the 1st, 2nd, 3rd column etc. How do i get the end point .
Thanks,
Premjit