Skip to Main Content

SQL & PL/SQL

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!

Conversion of multi-valued string in to columns and rows

Pavankumar Sudabattula-OracleMay 25 2021 — edited May 25 2021

Am using Oracle 19c database
Below is my string value
variable B1 varchar2(60)
exec :B1:='(199,''TEST121''),(156,''TEST''),(1561,''TEST99'')';
I want the output as
image.png select regexp_substr(regexp_substr(:b1,'[^A-Z+0-9][0-9]+', 1,level),'[0-9]+') as id , regexp_substr(:b1,'[A-Z]+[0-9]', 1,level) as name from dual connect by regexp_substr(:b1,'[0-9]', 1,level) is not null;
this query is only giving o/p for string values ending with digits.

This post has been answered by Alex Nuijten on May 25 2021
Jump to Answer
Comments
Post Details
Added on May 25 2021
13 comments
569 views