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!

Parsing Data

925509Mar 21 2012 — edited Mar 21 2012
Hello all ...

here is an example of some data I need to parse.

IN: CS, Test 2A-1, CBL, PHL, South Penn I/L, Loc P10, 49C-Loc P11B, AP 1.5

That code that I have so far:

select t.description,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 1) col_1,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 2) col_2,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 3) col_3,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 4) col_4,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 5) col_5,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 6) col_6,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 7) Col_7,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,-]+', 1, 9) Col_8,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 8) col_9,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 9) col_10,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 10) col_11
FROM JOBPLAN t

I have 2 problems:

1st problem is that for COL 7, all i want in there is the "49C", I'm currently getting " 49C-Loc P11B".
My ultimate goal is to get any number that is before the C and the C itself. The number before the C could be 1 to 3 digits.

2nd problem
Column 9. That snipit of data will always start with an "A", have another alpha, then a space, then a number. I'm trying to just get the number.

Any help would be greatly appricatiated.
This post has been answered by sKr on Mar 21 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 18 2012
Added on Mar 21 2012
4 comments
50 views