Skip to Main Content

Oracle Database Discussions

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!

Extracting values from a pipe separated string

mradul goyalMay 16 2016 — edited May 17 2016

Hi,

I have a string which looks like --

12361_BBMS_GTECHL|12362_BBMS_PRIM|12363_BBMS_SEC|....and so on

So i need to fetch

12361 and BBMS_GTECHL

12362 and BBMS_PRIM

  12363 and BBMS_SEC


i used --

       select *

  FROM

  TABLE(XMLSEQUENCE(

            EXTRACT(

                XMLTYPE('<rowset><row><Code>'||

                    replace(replace('12361=BBMS_GTECHL|12362=BBMS_PRIM','|','</Value></row><row><Code>'),'=','</Code><Value>')||'</Value>'||'</row></rowset>'),'/rowset/row')));

declare

  l_val varchar2(1000);

begin

select substr('12361_BBMS_GTECHL|12362_BBMS_PRIM', instr('|')+1)  into l_val from dual;

dbms_output.put_line(l_val);

end; 

But getting problem in getting desired result !

I have need to write this logic in a package that i will do if i got some hint here.

My DB version is --

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

This post has been answered by Pini Dibask on May 16 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 14 2016
Added on May 16 2016
5 comments
2,587 views