Parsing data within CLOB

Background and Original Question: http://www.experts-exchange.com/Database/Oracle/Q_28648525.html#a40713069

I need to parse through a Clob and grab out the any information associated with a Source of an arrest.  Below is the table with sample data,

drop table tab1 purge;
create table tab1(row_id (varchar2(4),col1 clob);

insert into tab1 values('1111',--------------------------------------------------------------[ Notes Type:  created by: Johnny American on 1/8/2015 17:15:21]--------------------------------------------------------------' || chr(13)||chr(10) ||
'' || chr(13)||chr(10) ||
'What problem are you experiencing?' || chr(13)||chr(10) ||
'' || chr(13)||chr(10) ||
Source: LA Records created by: Kim Kardashian on 9/26/2014 7:0:50
' || chr(13)||chr(10) ||
'' || chr(13)||chr(10) ||
 'Arrests:' || chr(13)||chr(10) ||
'' || chr(13)||chr(10) ||
 'Being vapid in California, on or about January ' || chr(13)||chr(10) ||
'' || chr(13)||chr(10) ||
 'Source: Calabasas Records created by: JOSHUA.MARTIN on 9/26/2014 6:59:34' || chr(13)||chr(10) ||
'' || chr(13)||chr(10) ||
 'Riverside County Court ' || chr(13)||chr(10)
);
commit;
*/

Open in new window

My intended result would be for it to return two rows

1111, Source: LA Records created by: Kim Kardashian on 9/26/2014 7:0:50
 'Arrests:'
 'Being vapid in California, on or about January '

1111, Source: Calabasas Records created by: JOSHUA.MARTIN on 9/26/2014 6:59:34'
 'Riverside County Court '
DBAnewbie77Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
So this is one row in the returned results?

1111, Source: LA Records created by: Kim Kardashian on 9/26/2014 7:0:50
'Arrests:'
'Being vapid in California, on or about January ' 

Open in new window


The carriage returns and single quotes are part of it?

So anything AFTER "Source"?  You stated in the other question you did not want to do that...

Your expected results from that data don't really make sense.
0
DBAnewbie77Author Commented:
The carriage returns and single quotes are part of it?

The carriage returns are, but not the single quotes. That was a copy and paste error.

So anything AFTER "Source"?  You stated in the other question you did not want to do that...

Majority of the records fall under the  set of data that I posted in the first question, so the original script works for them, but there are a few records that are like the data in this question I need to parse again on the word "Source"
0
DBAnewbie77Author Commented:
Does any expert have a recommendation on how I can do this?
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

slightwv (䄆 Netminder) Commented:
Sorry.  I've been tied up at work.
0
sdstuberCommented:
can you try posting your insert again to make sure we have sample data that reflects what you really want?
0
sdstuberCommented:
I can't completely verify this query since the input is in question, but you can try this and see how it works for you

SELECT row_id, TO_CHAR(SUBSTR(col1, startpos, endpos - startpos))
  FROM (SELECT row_id,
               col1,
               startpos,
               NVL(LEAD(startpos) OVER (ORDER BY n), LENGTH(col1)) endpos
          FROM (SELECT COLUMN_VALUE n,
                       col1,
                       row_id,
                       REGEXP_INSTR(
                           col1,
                           '^Source:',
                           1,
                           COLUMN_VALUE,
                           0,
                           'm'
                       )
                           startpos
                  FROM tab1,
                       TABLE(
                               SELECT COLLECT(LEVEL)
                                 FROM DUAL
                           CONNECT BY LEVEL <= REGEXP_COUNT(
                                                   col1,
                                                   '^Source:',
                                                   1,
                                                   'm'
                                               )
                       )))

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.