Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, you could try something like:</p> <pre><code>with v as ( select 1 col1, '1331882981,ab123456,Some text here which can run multiple lines and have a lot of text... ~1331890329,pqr123223,Some more text...' col2 from dual union all select 2 col1, '133188298777,abc333,Some text here which can run multiple lines and have a lot of text... ~1331890329,pqrs23,Some more text...' col2 from dual ) select distinct col1, regexp_substr(col2, '([0-9]{10},[a-z 0-9]+)', 1, level) split from v connect by level &lt;= REGEXP_COUNT(col2, '([0-9]{10},[a-z0-9]+)') order by col1 ; </code></pre> <p>This gives:</p> <pre><code>1 1331882981,ab123456 1 1331890329,pqr123223 2 1331890329,pqrs23 2 3188298777,abc333 </code></pre> <p><strong>EDIT :</strong> for 10g, <code>REGEXP_COUNT</code> does not exist but you have <a href="http://www.sqlsnippets.com/en/topic-12818.html" rel="nofollow">workarounds</a>. Here I replace the pattern found by something I hope I won't find in the text (here, <code>XYZXYZ</code> but you can choose something much more complex to be confident), do a diff with the same matching but replaced by the empty string, then divide by my pattern length (here, <code>6</code>):</p> <pre><code>with v as ( select 1 col1, '1331882981,ab123456,Some text here which can run multiple lines and have a lot of text... ~1331890329,pqr123223,Some more text...' col2 from dual union all select 2 col1, '133188298777,abc333,Some text here which can run multiple lines and have a lot of text... ~1331890329,pqrs23,Some more text...' col2 from dual ) select distinct col1, regexp_substr(col2, '([0-9]{10},[a-z 0-9]+)', 1, level) split from v connect by level &lt;= (length(REGEXP_REPLACE(col2, '([0-9]{10},[a-z 0-9]+)', 'XYZXYZ')) - length(REGEXP_REPLACE(col2, '([0-9]{10},[a-z 0-9]+)', ''))) / 6 order by col1 ; </code></pre> <p><strong>EDIT 2 :</strong> CLOBs (and LOBs in general) and regexp don't seem to fit well together:</p> <pre><code>ORA-00932: inconsistent datatypes: expected - got CLOB </code></pre> <p>Converting the CLOG to a string (<code>regexp_substr(to_char(col2), ...</code>) seems to fix the issue.</p> <p><strong>EDIT 3 :</strong> CLOBs don't like <code>distinct</code> either, so converting split result to char in an embedded request and then using the <code>distinct</code> on the upper request succeeds ! </p> <pre><code>select distinct col1, split from ( select col1, to_char(regexp_substr(col2, '([0-9]{10},[a-z 0-9]+)', 1, level)) split from temp_epn connect by level &lt;= (length(REGEXP_REPLACE(col2, '([0-9]{10},[a-z 0-9]+)', 'XYZXYZ')) - length(REGEXP_REPLACE(col2, '([0-9]{10},[a-z 0-9]+)', ''))) / 6 order by col1 ); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload