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?
 
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
 
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
DBAnewbie77Author Commented:
Does any expert have a recommendation on how I can do this?
0
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.