Skip to Main Content

SQL Developer

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Extract from comma separated string

55913Apr 26 2011 — edited Apr 27 2011
Hi,

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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 25 2011
Added on Apr 26 2011
1 comment
269 views