Thursday, 3 April 2014

Reading XML from database

Can use sqlloader
or
/*
<?xml version="1.0" encoding="UTF-8"?>
<INCOME_ACCESS_ROOT_SALES>
        <INCOME_ACCESS_CHILD_SALES>
                <TRANSACTION_DATE>20140401</TRANSACTION_DATE>
                <BTAG>a_9947b_5033c_GALA_UK_BINGO_B10G50_2565_LLK_GALBLLKBOTH_iPhone_Female_LinkP_BingoFlo40Free_CPC</BTAG>
        </INCOME_ACCESS_CHILD_SALES>
</INCOME_ACCESS_ROOT_SALES>

*/


select
    extractvalue(column_value,'/INCOME_ACCESS_ROOT_SALES/INCOME_ACCESS_CHILD_SALES/TRANSACTION_DATE'),
    extractvalue(column_value,'/INCOME_ACCESS_ROOT_SALES/INCOME_ACCESS_CHILD_SALES/BTAG')
  from
    table(xmlsequence(xmltype(bfilename('JDE','IGB_SALES_TEST.xml'),
      nls_charset_id('WE8ISO8859P1'))));



No comments: