Note that there are some explanatory texts on larger screens.

plurals
  1. POReplacing Text which does not match a pattern in Oracle
    primarykey
    data
    text
    <p>I have below text in a CLOB in a table <br> <br> Table Name: tbl1<br> Columns<br> col1 - number (Primary Key)<br> col2 - clob (as below)<br> <br> Row#1<br> -----<br> Col1 = 1<br> Col2 =<br> 1331882981,ab123456,Some text here<br> which can run multiple lines and have a lot of text...<br> ~1331890329,pqr123223,Some more text...<br> <br> Row#2<br> -----<br> Col1 = 2<br> Col2 =<br> 1331882981,abc333,Some text here<br> which can run multiple lines and have a lot of text...<br> ~1331890329,pqrs23,Some more text...<br> <br> <br> Now I need to know how we can get below output<br> <br> Col1 Value<br> ---- ---------------------<br> 1 1331882981,ab123456<br> 1 1331890329,pqr123223<br> 2 1331882981,abc333<br> 2 1331890329,pqrs23<br></p> <p><br> ([0-9]{10},[a-z 0-9]+.), ==> This is the regular expression to match "1331890329,pqrs23" and I need to know how can replace which are not matching this regex and then split them into multiple rows <br><br></p> <p><strong>EDIT#1</strong><br> I am on Oracle 10.2.0.5.0 and hence cannot use REGEXP_COUNT function :-( Also, the col2 is a CLOB which is massive <br><br></p> <p><strong>EDIT#2</strong><br> I've tried below query and it works fine for some records (i.e. if I add a "where" clause). But when I remove the "where", it never returns any result. I've tried to put this into a view and insert into a table and left it run overnight but still it had not completed :( <br><br></p> <pre><code>with t as (select col1, col2 from temp_table) select col1, cast(substr(regexp_substr(col2, '[^~]+', 1, level), 1, 50) as varchar2(50)) data from t connect by level &lt;= length(col2) - length(replace(col2, '~')) + 1 </code></pre> <p><br><br> <strong>EDIT#3</strong><br></p> <pre> # of Chars in Clob Total ----------- ----- 0 - 1k 3196 1k - 5k 2865 5k - 25k 661 25k - 100k 36 > 100k 2 ----------- ----- Grand Total 6760 </pre> <p>I have ~7k rows of clobs which have the distribution as shown above...</p>
    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