Here is some useful information from the IAOUG Roundtable. I got this brilliant idea last fall when several wanted to share ideas/issues/etc after I gave my OOW update ppt. I’ve had problems getting headcount up on this group…so…the brilliant idea is to name the event (the Iowa Oracle Roundtable)…and it is an online forum. Troy did a great job finding the site and setting it all up. He uses ‘Campfire’ software. He loads the email addresses in…part of my brilliant idea is you have to attend a meeting to participate in the online forum! New email address for Dan: DanHotka@GMail.com . Thank you for keeping in touch… From the forum: This is more of a development question than a DBA question. Do any of you parse xml docs using SQL or PL/SQL? I have a developer who's trying to read in an xml doc from a vendor and we're getting hung up on the xmlns parameter. We're attempting to use the xmltype function, but the root xml tag has this xmlns parameter attatched to it. It looks something like this: If you delete out that xmlns part and just have , we can get our insert to work just fine. With it in, no rows inserted. Any ideas? Not sure how much it'll help, but here's an example of our insert statement: INSERT INTO test_xml(invoice_num) WITH t AS (SELECT xmltype(bfilename('EXPORT_DIR','test_file.xml'), nls_charset_id('WE8ISO8859P1')) xmlcol FROM dual) SELECT extractValue(value(x),'/invoice/invoice_number') invoice_num FROM t, TABLE(XMLSequence(extract(t.xmlcol,'/invoice'))) x; First Response: Is it possible to attach a sample file so we know the exact format of the file? That would at least give something to work with and test against. Here's a simplified example: PO-1 Rod Library Here's the query I came up with. You have to call out that namespace from what I found, otherwise it won't work. With some of the XML stuff you are using, it has been deprecated so I moved on to the xmltable. Hopefully this works for you. I tested in my environment on 12c and it did. INSERT INTO test_xml(invoice_num) WITH t AS (SELECT xmltype(bfilename('EXPORT_DIR','test_file.xml'), nls_charset_id('WE8ISO8859P1')) xmlcol FROM dual) select x.* from t, xmltable(xmlnamespaces(default ' http://com/exlibris/repository/acq/invoice/xmlbeans '), '//invoice' passing t.xmlcol columns invoice_num varchar2(30) path 'invoice_number') x / Thank you from the originator: Awesome! Thanks! Now I haven't been able to find anything on this, but I've heard there is a way to upload your xml file's "definition file", or whatever it's called....and upload that into the database somewhere. Then you don't have to explicitly set your columns like we're doing in this example, you just reference the "definition file" and the database does it automatically. Additional Reading: Here is some documentation that talks about it: http://docs.oracle.com/cd/B28359_01/appdev.111/b28369/xdb05sto.htm Thank you Brian and Nevin. Dan Hotka Oracle ACE Director Author/Instructor/CEO
↧