Saturday, October 10, 2020

 

Connect your Oracle database with GitLab

You can connect database with your GITLAB using https://bit.ly/plsql2git

To connect PL/SQL with GITLAB you must use Access Token created in GIT.

 

ORA-31186: Document contains too many nodes

 If you have in XML LIST more than 300.000 items you will get error "ORA-31186: Document contains too many nodes"


select
      extractvalue(value(x), '//LIST/ITEM') ITEM,
from  table_with_xml t
   ,  table(xmlsequence(extract(t.xml_col,'//LIST'))) x  


If you have like 450.000 items, you can split XML like ... in two parts and combine them with union all


select
      extractvalue(value(x), '//LIST/ITEM') ITEM,
from  (select 
          substr(xml_col, 1 , instr(xml_col, '</ITEM>',1 , 
          250000  -- first 250.000 items
          ))||'/ITEM></LIST>' xml_col
       from table_with_xml
       ) t
   ,  table(xmlsequence(extract(t.xml_col,'//LIST'))) x  
union all
select
      extractvalue(value(x), '//LIST/ITEM') ITEM,
from  (select
          '<LIST><ITEM>'||  
          substr(xml_col, instr(xml_col, '</ITEM>',1 ,
          200000  -- last 200.000 items
          )+length('</ITEM>') ) xml_col
       from table_with_xml
       ) t
   ,  table(xmlsequence(extract(t.xml_col,'//LIST'))) x
;




 

Count number of X strings in text - using length and replace

 You have often to count number of occurrences of one string X in text.

You can use only two methods to do that.

Here is example for PL/SQL, you can use this trick in all languages just use right length and replace function. X is 'T' and the text is 'TEXT'

count  := (length('TEXT')-length( replace('TEXT','T','' ))) / length('T')

result is 2





This page is powered by Blogger. Isn't yours?