Oracle 10g: Extract data (select) from XML (CLOB Type)

前端 未结 7 915
悲哀的现实
悲哀的现实 2021-02-07 20:05

I\'m new in Oracle and I\'ve - maybe trivial - a problem in a select. (I\'m using Oracle 10g Express Edition).

I\'ve a DB with a field CLOB: mytab.xml This column have a

7条回答
  •  猫巷女王i
    2021-02-07 20:09

    Try using xmltype.createxml(xml).

    As in,

    select extract(xmltype.createxml(xml), '//fax').getStringVal() from mytab;
    

    It worked for me.

    If you want to improve or manipulate even further.

    Try something like this.

    Select *
    from xmltable(xmlnamespaces('some-name-space' as "ns", 
                                      'another-name-space' as "ns1",
                               ), 
                        '/ns/ns1/foo/bar'
                        passing xmltype.createxml(xml) 
                        columns id varchar2(10) path '//ns//ns1/id',
                                idboss varchar2(500) path '//ns0//ns1/idboss',
                                etc....
    
                        ) nice_xml_table
    

    Hope it helps someone.

提交回复
热议问题