Import XML file into XMLType Column [message #675554] |
Fri, 05 April 2019 10:26  |
ator
Messages: 43 Registered: March 2009
|
Member |
|
|
Hello,
i looked for the solution everywhere but i could not find anything.
We received from different source file xml and we load the file in a XMLType column as follow.
UPDATE TAB_X
SET XMLTYPE_COLUMN = XMLType(bfilename('DIRECTORY', 'FILE.XML'),
nls_charset_id('AL32UTF8'));
The procedure works fine until there are empty tags (<tag />) in the file and it throw ORA-30625: method dispatch on NULL SELF argument is disallowed.
Right now i delete the empty tags and read the file but there is a way to avoid having the oracle error and load the file?.
Thank you for your help and i apologize if somebody else has already asked but i did not found it.
Ator
|
|
|
|
|
|
|
|
Re: Import XML file into XMLType Column [message #675601 is a reply to message #675597] |
Mon, 08 April 2019 11:14   |
_jum
Messages: 577 Registered: February 2008
|
Senior Member |
|
|
Can confirm @Michel with 12.1.0.2 SE:
CREATE TABLE tab_x (XMLTYPE_COLUMN xmltype);
INSERT INTO tab_x VALUES (XMLTYPE('<tag/>'));
UPDATE TAB_X
SET XMLTYPE_COLUMN = XMLType(bfilename('EXPORT_DIR', 'example.txt'), nls_charset_id('AL32UTF8'));
SELECT XMLQuery('$X//document/envelope/transactionInfo/version/text()' PASSING XMLTYPE_COLUMN AS x RETURNING CONTENT).getstringval() xv
FROM TAB_X;
XV
--------------------------------------------------------------------------------
2.1.01
1 row selected.
[Updated on: Mon, 08 April 2019 11:16] Report message to a moderator
|
|
|
Re: Import XML file into XMLType Column [message #675606 is a reply to message #675554] |
Tue, 09 April 2019 08:28   |
ator
Messages: 43 Registered: March 2009
|
Member |
|
|
Hello,
thank you again for your help. I apologize but i found the cause of my error.
On the table I have a trigger that look for data inside the xml file and retrive the information and that was the cause of the error ORA-30625.
I didn't found earlier because, as always, oracle works in misterious way and i supposed that
select Extract(XMLType(bfilename(gen_pak.FUN_Oracle_Dir('INBOX'), '4-479496-0_SC_4efafea4-7f85-4e71-94ac-eff88c34aca5.xml'),
nls_charset_id('AL32UTF8'))
,'/document[1]/SC[1]/creditor[1]/representative[1]/particular[1]/company[1]/contactPerson'||'/text()','xmlns="http://www.eschkg.ch/schema/2.1"').GetStringVal()
from dual;
behaved in the same way as this
declare
appo_file xmltype;
val varchar2(1000);
begin
appo_file := XMLType(bfilename(gen_pak.FUN_Oracle_Dir('INBOX'), '4-479496-0_SC_4efafea4-7f85-4e71-94ac-eff88c34aca5.xml'),
nls_charset_id('AL32UTF8'));
val := Appo_File.Extract('/document[1]/SC[1]/creditor[1]/representative[1]/particular[1]/company[1]/contactPerson'||'/text()','xmlns="http://www.eschkg.ch/schema/2.1"').GetStringVal();
end;
Unfortunatly the first return null and the second the exception.
I thank everyone again for your help.
Ator
|
|
|
|
|