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!

divide the PIPE separated string into columns

3377748Feb 6 2017 — edited Feb 13 2017

Hi, I know this question has been answered to an extent previously, but some one could provide the answer.

I've the following string:

str =  ' 000241137|00148-940-06237-001|C|Supply|10,427.20| '

The above string has to be divided into 4 different columns:

I am trying to use REGEXP_SUBSTR.

SELECT  REGEXP_SUBSTR ('000241137|00148-940-06237-001|C|Supply|10,427.20|', '[^|]*', 1,2   )    AS part_1 from dual;  --RES: NULL

SELECT  REGEXP_SUBSTR ('000241137|00148-940-06237-001|C|Supply|10,427.20|', '[^|]*', 1,3   )    AS part_1 from dual; -- RES: 00148-940-06237-001

Occurring similarly from next element also ( Null,res,null,res).

I also tried using :

SELECT  RTRIM (REGEXP_SUBSTR ('000241137|00148-940-06237-001|C|Supply|10,427.20|', '[^|]*', 1,2   ), '|')    AS part_1 from dual;

the result is same.

Could some one help me with this.

--Much Appreciated.

Thanks.

This post has been answered by Srinivas Vanahalli on Feb 7 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 13 2017
Added on Feb 6 2017
21 comments
6,367 views