Xmldom.writeToClob error. [URGENT]
Any idea why I get the following error when I call:
xmldom.writeToClob(root, xml_out);
ORA-20000: An internal error has occurred: CLOB to write to can not be null ORA-06512: at "XML.XMLDOM", line 37 ORA-06512: at "XML.XMLDOM", line 358 ORA-06512: at line 131
'xml_out' is initialised with null, but 'root' have some nodes and elements, but no text nodes. I do not get this error if I use
xmldom.writeToBuffer(root, v_xml);
Thanks
null
Thx for your response
the program looks like this:
I executed it from a Form;
PROCEDURE PRUEBA IS
xml clob;
vxml varchar2(100);
len integer := 1;
pos integer := 1;
f utl_file.file_type;
doc xmldom.DOMDocument;
ppal_node xmldom.DOMNode;
main_node xmldom.DOMNode;
root_node xmldom.DOMNode;
user_node xmldom.DOMNode;
tercer_node xmldom.DOMNode;
item_node xmldom.DOMNode;
ppal_elmt xmldom.DOMElement;
root_elmt xmldom.DOMElement;
item_elmt xmldom.DOMElement;
item_text xmldom.DOMText;
--Elementos de la cabecera
header_pi xmldom.DOMProcessingInstruction;
header_node xmldom.DOMNode;
CURSOR MODULOS IS
SELECT T_COAPI AS COAPI,
T_DNAPI AS DNAPI
FROM T
WHERE T_COAPI = 'PES';
BEGIN
--Creamos un nuevo DOM document
doc := xmldom.newDOMDocument();
ppal_node := xmldom.makeNode(doc);
FOR Modulo IN Modulos LOOP
-- El nodo es cada modulo
root_elmt := xmldom.createElement(doc, 'Modulo');
root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
--COAPI
item_elmt := xmldom.createElement(doc, lit_COAPI);
item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_elmt));
item_text := xmldom.createTextNode(doc, Modulo.COAPI);
item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
--DNAPI
item_elmt := xmldom.createElement(doc, lit_DNAPI);
item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_elmt));
item_text := xmldom.createTextNode(doc, Modulo.DNAPI);
item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
END LOOP
f := utl_file.fopen('TEMP_DIR','PRUEBA.xml','w');
--Obtenemos la longitud del xml lob
len := dbms_lob.getlength(xml);
DBMS_LOB.CreateTemporary(xml,TRUE);
xmldom.writeToClob(doc,xml); -- HERE I GET THE ERROR
dbms_xmldom.WriteToFile(f,xml);
WHILE (pos < len) LOOP
vxml := dbms_lob.substr(xml,100,pos);
utl_file.put(f,vxml);
pos := pos+100;
END LOOP;
utl_file.fclose(f);
END;
Similar Messages
-
Error While Writing DOM to a CLOB i.e. xmldom.writeToClob
I am running into error while writng and reading from a clob. The Sample Code is as follows :
declare
p xmlparser.Parser;
doc xmldom.DOMDocument;
i_tmp CLOB;
i_tmp1 CLOB;
i_buffer varchar2(32767);
i_amount pls_integer;
begin
p := xmlParser.NewParser;
xmlparser.setbaseDir(p,'/sqlcom/inbound');
xmlparser.setValidationMode(p, TRUE);
xmlparser.showwarnings(p, TRUE);
xmlparser.seterrorlog(p, '/sqlcom/inbound/veshaal.err');
xmlparser.parse(p,'/sqlcom/inbound/mpoi.xml');
doc := xmlparser.getDocument(p);
dbms_lob.createtemporary(i_tmp1,true,dbms_lob.session);
xmldom.writeToClob(doc,i_tmp1);
xmldom.writeToFile(doc,'/sqlcom/inbound/veshaal_out.xml');
dbms_lob.createtemporary(i_tmp,true,dbms_lob.session);
xmldom.writeTobuffer(doc,i_buffer);
dbms_lob.write(i_tmp,length(i_buffer),1,i_buffer);
i_amount := dbms_lob.getLength(i_tmp);
dbms_lob.read(i_tmp,i_amount,1,i_buffer);
dbms_lob.freetemporary(i_tmp1);
commit;
exception
when others then
dbms_lob.freetemporary(i_tmp1);
dbms_output.put_line(SQLERRM);
end;
The oracle Error is as follows:
declare
ERROR at line 1:
ORA-03113: end-of-file on communication channel
ORA-24323: value not allowed
Error accessing package DBMS_APPLICATION_INFO
ERROR:
ORA-03114: not connected to ORACLE
The above code works while I try to write to a buffer or a file using xmldom.writeToFile or xmldom.writeToBuffer.
The xmlparser v2 is running inside the 8i ( 8.1.5.0. ) database.
The alert file has the following entry :
Errors in file /home/applrt/db/superbwl/log/superbwl_ora_2371.trc:
ORA-07445: exception encountered: core dump [EE1F05DC] [SIGSEGV] [Address not mapped to object] [0] [] []
Any help will be appreciated.
Thanks
nullUTL_FILE comes as part of the database, you shouldn't have to install it, and you most certainly shouldn't install it as SCOTT. System packages should be installed using a system user such as sys.
Firstly, I would suggest dropping the UTL_FILE package from your scott schema and then logging on as sys and granting execute permission on UTL_FILE to the scott user.
Secondly...
The UTL_FILE_DIR parameter has been deprecated by oracle in favour of direcory objects because of it's security problems.
The correct thing to do is to create a directory object e.g.:
CREATE OR REPLACE DIRECTORY mydir AS 'c:\myfiles';Note: This does not create the directory on the file system. You have to do that yourself and ensure that oracle has permission to read/write to that file system directory.
Then, grant permission to the users who require access e.g....
GRANT READ,WRITE ON DIRECTORY mydir TO myuser;Then use that directory object inside your FOPEN statement e.g.
fh := UTL_FILE.FOPEN('MYDIR', 'myfile.txt', 'r');Note: You MUST specify the directory object name in quotes and in UPPER case for this to work as it is a string that is referring to a database object name which will have been stored in uppercase by default. -
ERROR WITH XMLDOM.WRITETOCLOB
Hi,
I have written the following procedure...............
procedure Prc_UpdateNodes(clString in out clob, nodename varchar2, nodeValue varchar2) is
l_doc_node xmldom.DOMNode;
l_xml_out varchar2(2000);
begin
domDocument := Fn_GetXmlDocument(clString);
nodeList := xmldom.getElementsByTagName(domDocument, nodename);
intNoOfNode := xmldom.getLength(nodeList);
l_doc_node := xmldom.item(nodeList, 0);
for loopCount_int in 0.. intNoOfNode - 1 loop
node := XmlDom.item(nodeList, loopCount_int);
valueNode := XmlDom.getFirstChild(node);
XmlDom.setNodeValue(valueNode,nodeValue);
end loop;
XmlDom.writeToClob(domDocument,clString);
end;
This below XML Is passed as the first parameter
The output after this operation for an xml should be..
<ROWSET>
<ROW>
<SITE_NO Key="Yes">1</SITE_NO>
<PARAMETER_VALUE_NO Key="Yes">0</PARAMETER_VALUE_NO>
<PARENT_PARAMETER_SPEC_NO>0</PARENT_PARAMETER_SPEC_NO>
<PARAMETER_SPEC_NO>1</PARAMETER_SPEC_NO>
<REF_TABLE_KEY_NO>0</REF_TABLE_KEY_NO>
<REF_TABLE_KEY_TYPE>S</REF_TABLE_KEY_TYPE>
<SEQ_NO>1</SEQ_NO>
<SUB_SEQN_NO>0</SUB_SEQN_NO>
<DATA_TYPE_NO>1</DATA_TYPE_NO>
<INTEGER_VALUE>0</INTEGER_VALUE>
<STRING_VALUE>00039</STRING_VALUE>
<NUMERIC_VALUE>0</NUMERIC_VALUE>
<DATE_VALUE>01/01/1600</DATE_VALUE>
<CREATED_ON>0</CREATED_ON>
<MODIFIED_ON>0</MODIFIED_ON></ROW>
<ROW>
<SITE_NO Key="Yes">1</SITE_NO>
<PARAMETER_VALUE_NO Key="Yes">0</PARAMETER_VALUE_NO>
<PARENT_PARAMETER_SPEC_NO>0</PARENT_PARAMETER_SPEC_NO>
<PARAMETER_SPEC_NO>2</PARAMETER_SPEC_NO>
<REF_TABLE_KEY_NO>0</REF_TABLE_KEY_NO>
<REF_TABLE_KEY_TYPE>S</REF_TABLE_KEY_TYPE>
<SEQ_NO>2</SEQ_NO><SUB_SEQN_NO>0</SUB_SEQN_NO>
<DATA_TYPE_NO>2</DATA_TYPE_NO>
<INTEGER_VALUE>0</INTEGER_VALUE>
<STRING_VALUE/>
<NUMERIC_VALUE>0</NUMERIC_VALUE>
<DATE_VALUE/>
<CREATED_ON>0</CREATED_ON>
<MODIFIED_ON>0</MODIFIED_ON>
</ROW>
</ROWSET>
But the output I get is ……….
<ROWSET>
<ROW>
<SITE_NO Key="Yes">1</SITE_NO>
<PARAMETER_VALUE_NO Key="Yes">0</PARAMETER_VALUE_NO>
<PARENT_PARAMETER_SPEC_NO>0</PARENT_PARAMETER_SPEC_NO>
<PARAMETER_SPEC_NO>1</PARAMETER_SPEC_NO>
<REF_TABLE_KEY_NO>0</REF_TABLE_KEY_NO>
<REF_TABLE_KEY_TYPE>S</REF_TABLE_KEY_TYPE>
<SEQ_NO>1</SEQ_NO>
<SUB_SEQN_NO>0</SUB_SEQN_NO>
<DATA_TYPE_NO>1</DATA_TYPE_NO>
<INTEGER_VALUE>0</INTEGER_VALUE>
<STRING_VALUE>00039</STRING_VALUE>
<NUMERIC_VALUE>0</NUMERIC_VALUE>
<DATE_VALUE>01/01/1600</DATE_VALUE>
<CREATED_ON>0</CREATED_ON>
<MODIFIED_ON>0</MODIFIED_ON></ROW>
<ROW>
<SITE_NO Key="Yes">1</SITE_NO>
<PARAMETER_VALUE_NO Key="Yes">0</PARAMETER_VALUE_NO>
<PARENT_PARAMETER_SPEC_NO>0</PARENT_PARAMETER_SPEC_NO>
<PARAMETER_SPEC_NO>2</PARAMETER_SPEC_NO>
<REF_TABLE_KEY_NO>0</REF_TABLE_KEY_NO>
<REF_TABLE_KEY_TYPE>S</REF_TABLE_KEY_TYPE>
<SEQ_NO>2</SEQ_NO><SUB_SEQN_NO>0</SUB_SEQN_NO>
<DATA_TYPE_NO>2</DATA_TYPE_NO>
<INTEGER_VALUE>0</INTEGER_VALUE>
<STRING_VALUE/>
<NUMERIC_VALUE>0</NUMERIC_VALUE>
<DATE_VALUE/>
<CREATED_ON>0</CREATED_ON>
<MODIFIED_ON>0</MODIFIED_ON>
</ROW>
</ROWSET>
0</MODIFIED_ON>
</ROW>
</ROWSET>
The letter in bold above are the newly introduced junk letters
I think this problem is due to the buffer isssues………….
Do we have any solution for clearing the buffer….
Also this error doesnt occur all the time.........
Sometimes it comes, Sometimes it works fine
The error is introduced during execution of the statement
XmlDom.writeToClob(domDocument,clString);
Can anyone help me on this front?????
Thanks
Message was edited by:
user609257Thx for your response
the program looks like this:
I executed it from a Form;
PROCEDURE PRUEBA IS
xml clob;
vxml varchar2(100);
len integer := 1;
pos integer := 1;
f utl_file.file_type;
doc xmldom.DOMDocument;
ppal_node xmldom.DOMNode;
main_node xmldom.DOMNode;
root_node xmldom.DOMNode;
user_node xmldom.DOMNode;
tercer_node xmldom.DOMNode;
item_node xmldom.DOMNode;
ppal_elmt xmldom.DOMElement;
root_elmt xmldom.DOMElement;
item_elmt xmldom.DOMElement;
item_text xmldom.DOMText;
--Elementos de la cabecera
header_pi xmldom.DOMProcessingInstruction;
header_node xmldom.DOMNode;
CURSOR MODULOS IS
SELECT T_COAPI AS COAPI,
T_DNAPI AS DNAPI
FROM T
WHERE T_COAPI = 'PES';
BEGIN
--Creamos un nuevo DOM document
doc := xmldom.newDOMDocument();
ppal_node := xmldom.makeNode(doc);
FOR Modulo IN Modulos LOOP
-- El nodo es cada modulo
root_elmt := xmldom.createElement(doc, 'Modulo');
root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
--COAPI
item_elmt := xmldom.createElement(doc, lit_COAPI);
item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_elmt));
item_text := xmldom.createTextNode(doc, Modulo.COAPI);
item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
--DNAPI
item_elmt := xmldom.createElement(doc, lit_DNAPI);
item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_elmt));
item_text := xmldom.createTextNode(doc, Modulo.DNAPI);
item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
END LOOP
f := utl_file.fopen('TEMP_DIR','PRUEBA.xml','w');
--Obtenemos la longitud del xml lob
len := dbms_lob.getlength(xml);
DBMS_LOB.CreateTemporary(xml,TRUE);
xmldom.writeToClob(doc,xml); -- HERE I GET THE ERROR
dbms_xmldom.WriteToFile(f,xml);
WHILE (pos < len) LOOP
vxml := dbms_lob.substr(xml,100,pos);
utl_file.put(f,vxml);
pos := pos+100;
END LOOP;
utl_file.fclose(f);
END; -
Xmldom.writetoclob hanging forever when writing a domnode to a temp clob
Hi
Wondering has anyone come across anything similar (or know a work around)
1. Basically the the procedure below loads an XML file. (OK)
2. Removes reference to external dtd, ref was causing and error (OK)
3. Parses the XML (OK)
4. Gets a list of the "item" tags (OK) - should be up to 500 item elements in XML
5. Loops on all elements
a. writes node to temp clob *(PROBLEM HERE)*
b. Creates xmltype from clob (OK)
c. transforms xmltype and assigns to another xmltype (OK)
d. inserts new xmltype (OK)
This procedure is used by a threaded os java app to load thousands of files to db.
It works fine 99% of the time but for some files the procedure is hanging at (5.a : write domnode to clob using xmldom.writetoclob)
I am absolutely sure the problem is due to the characters in the domnode as all files that have hung on processing contain these bizarre characters,
the db character set is Unicode AL32UTF8 so it should be able to handle almost anything, saying that, if the it is a prob with the characters then why does
the loadclobfromfile procedure succeed.
Developed on Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit
I have no prob rejecting node and continue processing but procedure just hangs and i have to kill the thread on the os.
Is there a way to
1. Test for invalid AL32UTF8 chars and skip on error.
or
2. Get around the xmldom.writetoclob procedure and create an xmltype from the xmldom.domnode (i tried to convert domnode -> domdocument -> xmltype, no joy)
or
Open to suggestions
PROCEDURE
PROCEDURE process_blog_xml_file (
p_file_name IN VARCHAR2,
p_insert_date IN VARCHAR2,
p_dir IN VARCHAR2 DEFAULT NULL
IS
newsurl VARCHAR2 (80);
parser xmlparser.parser;
newsxml xmldom.domdocument;
titles xmldom.domnodelist;
titles_found NUMBER;
curnode xmldom.domnode;
textchild xmldom.domnode;
dest_clob CLOB;
l_temp_clob CLOB;
src_clob BFILE := BFILENAME (g_zip_file_dir, p_file_name);
dst_offset NUMBER := 1;
src_offset NUMBER := 1;
lang_ctx NUMBER := DBMS_LOB.default_lang_ctx;
warning NUMBER;
l_xml XMLTYPE;
xsldata XMLTYPE;
xmldata XMLTYPE;
l_dir VARCHAR2 (1000);
BEGIN
LOG ( 'Start Processing file '
|| p_file_name
|| ' from zip '
|| p_insert_date
IF p_dir IS NULL
THEN
SELECT directory_path
INTO l_dir
FROM all_directories
WHERE directory_name = g_zip_file_dir;
ELSE
l_dir := p_dir;
END IF;
IF g_xsl_clob IS NULL
THEN
init_xsl_clob;
END IF;
com_polecat_xmldb_utils.set_load_date
(TO_DATE (REPLACE (REPLACE (p_insert_date,
'.zip',
'DD-MM-YYYY'
LOG ('ITEM.Loaddate set : ' || com_polecat_xmldb_utils.get_load_date);
xsldata := XMLTYPE.createxml (g_xsl_clob);
LOG ('Read xsl file to clob');
DBMS_LOB.OPEN (src_clob, DBMS_LOB.lob_readonly);
DBMS_LOB.createtemporary (dest_clob, TRUE);
DBMS_LOB.loadclobfromfile (dest_lob => dest_clob,
src_bfile => src_clob,
amount => DBMS_LOB.getlength
(src_clob),
dest_offset => dst_offset,
src_offset => src_offset,
bfile_csid => NLS_CHARSET_ID
('AL32UTF8'),
lang_context => lang_ctx,
warning => warning
LOG ('Read xml file to clob');
DBMS_LOB.CLOSE (src_clob);
parser := xmlparser.newparser;
dest_clob := REPLACE (dest_clob, g_blog_dtd_remove, '');
LOG ('Parse xml ');
xmlparser.parseclob (parser, dest_clob);
DBMS_LOB.freetemporary (dest_clob);
newsxml := xmlparser.getdocument (parser);
xmlparser.freeparser (parser);
titles := xmldom.getelementsbytagname (newsxml, 'item');
LOG ('Load blogs items to ITEM table. ');
FOR j IN 1 .. xmldom.getlength (titles)
LOOP
curnode := xmldom.item (titles, j - 1);
DBMS_LOB.freetemporary (l_temp_clob);
DBMS_LOB.createtemporary (l_temp_clob, TRUE);
LOG ('write node to temp clob ' || j);
xmldom.writetoclob (curnode, l_temp_clob); <-- Hanging Here
LOG ('create xml type from clob ' || j);
l_xml := XMLTYPE.createxml (l_temp_clob);
LOG ('apply xsl transform to xml ' || j);
xmldata := l_xml.transform (xsldata);
LOG ('Insert to item table ' || j);
BEGIN
INSERT INTO item
VALUES (xmldata);
EXCEPTION
WHEN OTHERS
THEN
LOG ('Error:: ' || SQLERRM);
END;
END LOOP;
xmldom.freedocument (newsxml);
LOG ( 'Finished Processing file '
|| p_file_name
|| ' from zip '
|| p_insert_date
EXCEPTION
WHEN OTHERS
THEN
LOG (SQLERRM);
END;note variables starting with g_ are defined in package spec
Cheers
Ian
Edited by: user3604054 on 01-Apr-2010 06:52
Edited by: user3604054 on 01-Apr-2010 14:57
Edited by: user3604054 on 01-Apr-2010 15:00
Edited by: user3604054 on 01-Apr-2010 15:00
Edited by: user3604054 on 01-Apr-2010 15:05
Edited by: user3604054 on 01-Apr-2010 15:062. Get around the xmldom.writetoclob procedure and create an xmltype from the xmldom.domnode (i tried to convert domnode -> domdocument -> xmltype, no joy) Which version of Oracle (4 digits)?
Also look in the FAQ in the upper right for how to use the tag to wrap PL/SQL to retain formatting to make it easier for all to read. -
Problem with special characters and xmldom.writetoclob
Hi!
I have a problem with oracle parser in pl/sql.
My situation:
i have a clob with valid xml with for example decoded characters:
(spaces between & and # are for good representing characters by browser - in really there is no spaces)
<xml>
<any><![CDATA[ & #187; ]]> text <![CDATA[ & #187; ]]></any>
</xml>
i read this xml from clob, parse it and put into another clob by using
xmldom.writetoclob procedure.
And in second clob i have"
<xml>
<any>& #38;#187; text & #38;#187; </any>
</xml>
(ampersand is representing as & #38; !) Why there is not the cdata sections ?
Why the value of these sections changed?
Any ideas? I'm using newset xdk (9202) in 8.1.7.3 database.
Please help!Hi John,
According to your description, my understanding is that the Author showed incorrect character in SharePoint 2013 search result page.
I tested the same scenario per your post in my environment, and the Müller showed correctly in SharePoint search result page.
I recommend to reset the index in Search Service Application and run a full crawl to see if the issue still occurs.
Best regards.
Thanks
Victoria Xia
TechNet Community Support -
Potential problem with XMLDOM.writeToClob()
I'm really hoping that someone can help me with this. Last fall, wrote some code that used XMLDOM to build a document and send it to a web service. I remember having problems with WriteToBuffer and WriteToClob during my development efforts, which I thought were successfully resolved. Now it looks like the problem may be occurring at a client who recently upgraded to use this code. I can't get this to fail in-house, so I can't do much debugging on it. So I'm hoping that someone else has come across a problem like this and remembers what they did to fix it.
Basically, what happened was, WriteToClob (or sometimes WriteTuBuffer) didn't return anything, even though the DOM document was not empty. I remember going back and forth between WriteToBuffer and WriteToClob, trying to get it resolved. But I don't remember specifically finding any "magic bullet". Here's what I currently have in the code:
DBMS_LOB.createtemporary (v_source_data, TRUE);
DBMS_LOB.OPEN (v_source_data, DBMS_LOB.lob_readwrite);
xmldom.writetoclob (v_main_doc, v_source_data);
DBMS_LOB.CLOSE (v_source_data);
Has anyone had a similar problem, and remember what the fix was? I'm also not sure that the Open/Close calls are necessary. Or what TRUE means on CreateTemporary (aside from some generic comment about "buffer cache" without telling me what a buffer cache is).I'm really hoping that someone can help me with this. Last fall, wrote some code that used XMLDOM to build a document and send it to a web service. I remember having problems with WriteToBuffer and WriteToClob during my development efforts, which I thought were successfully resolved. Now it looks like the problem may be occurring at a client who recently upgraded to use this code. I can't get this to fail in-house, so I can't do much debugging on it. So I'm hoping that someone else has come across a problem like this and remembers what they did to fix it.
Basically, what happened was, WriteToClob (or sometimes WriteTuBuffer) didn't return anything, even though the DOM document was not empty. I remember going back and forth between WriteToBuffer and WriteToClob, trying to get it resolved. But I don't remember specifically finding any "magic bullet". Here's what I currently have in the code:
DBMS_LOB.createtemporary (v_source_data, TRUE);
DBMS_LOB.OPEN (v_source_data, DBMS_LOB.lob_readwrite);
xmldom.writetoclob (v_main_doc, v_source_data);
DBMS_LOB.CLOSE (v_source_data);
Has anyone had a similar problem, and remember what the fix was? I'm also not sure that the Open/Close calls are necessary. Or what TRUE means on CreateTemporary (aside from some generic comment about "buffer cache" without telling me what a buffer cache is). -
To : Oracle Team.. xmldom.writetoclob is too slow
HI;
I had Oracle 8.1.6, Used the xmldom package a lot to manipulate and create xml documents ( all sizes ). then I used xmldom.writetoclob which it was giving a GREAT performance.
I UPGRADED ti Oracle 8.1.7 and xmldom.writetoclob is TOO SLOW now, I have the same settings ( java_pool_size, share_pool, etc)
What changed from 8.1.6 to 8.1.7 ??
Why xmldom.writetoclob is so much slower in 8.1.7 ??
when tranfering a 300 KB document with 8.1.6 it used to take 30 seconds, no with 8.1.7 IT TAKES 2-1/2 minutes ?????
WHY ? ? ? ? ?
Tahnks for any information..My guess is that you are creating a clob with cached set to false
e.g
dbms_lob.createtemporary(v_myclob,false);
When set to false any time the clob is written to the characters are written to the disk. causing it to be slow.
try
dbms_lob.createtemporary(v_myclob,true);
I had the same problem. This speeds it up significantly
Rick Laird -
Using xmldom.writeToClob to update xml clob corrupts clob
We are storing an xml document in a clob field in the db. As part of a data check we need to parse the xml and possibly remove a node. I can do that, and check the results using 'xmldom.writeToBuffer'.
When I try to write the data back to the db using 'xmldom.writeToClob' I get strange results. Data seems to be appended to the end of the clob and contains chr(13) characters at the end of each line.
Also does anyone know if the existence of whitespace in the xml clob would cause a parse/search to be slower?
I am new to xml and might be missing something fairly basic in the following code. Thanks in advance for any help.
Here is some of the code:
doc xmldom.DOMDocument;
curNode xmldom.DOMNode;
parentNode xmldom.DOMNode;
theNodeList xmldom.DOMNodeList;
str varchar2(4000);
begin
-- open xml_rec cursor (xml is the clob field opened for update)
-- Loop through all item elements
theNodeList := xmldom.getElementsByTagName(doc, 'item');
for m in 0..xmldom.getLength(theNodeList)-1 loop
curNode := xmldom.item(theNodeList,m);
--perform a check and possibly delete the current node
parentNode := xmldom.getParentNode(curNode);
parentNode := xmldom.removechild(parentNode, curNode);
xmldom.writeToBuffer(doc, str);
--I check the results here and everything looks good
xmldom.writeToClob(doc, xml_rec.xml);
--When I check the clob the data is incorrect.
nullThe next cod is a sample of the implementation xmldom.writeToClob used xmldom.DOMNode in the parameter of input.
DECLARE
XMLOut CLOB := EMPTY_CLOB();
XMLIn Varchar2(2000);
XSLPath Varchar2(2000);
BEGIN
DBMS_LOB.CREATETEMPORARY(XMLOut,TRUE); -- Give permit
DBMS_LOB.OPEN (XMLOut, DBMS_LOB.LOB_READWRITE); --open the file of read and write
XSLPath := '/users/gcardona/plantillas/report.xsl';
GE_BSXMLCONVERT.createElementName('COLUMN');
GE_BSXMLCONVERT.createElementAttribute('name', 'OUTXML');
GE_BSXMLCONVERT.addElement();
GE_BSXMLCONVERT.createElementName('table');
GE_BSXMLCONVERT.createElementAttribute('name', 'X1');
GE_BSXMLCONVERT.createElementAttribute('width', '100');
GE_BSXMLCONVERT.addElement();
XMLIn := GE_BSXMLCONVERT.toXML();
XSLTranform(XMLIn, XSLPath, XMLOut);--XMLOut is a variable in out in the procedure,
--here is where is return the file XML Process
insert into in_prueba (ID,XML_CLOB) values (200, XMLOut);
DBMS_LOB.CLOSE (XMLOut); -- Close File
DBMS_LOB.FREETEMPORARY(XMLOut); --free memory
GE_BSXMLCONVERT.clearMemory();
commit;
END;
null -
Xmldom.writetoclob give wrong character set
I use xmldom to create a xml clob. I create document for xml as follow:
doc := xmldom.NewDomDocument;
xmldom.setVersion(doc, '1.0');
xmldom.setStandalone(doc, 'no');
xmldom.setCharSet(doc, 'ISO-8859-1'); -- Should be character set for danish.
Create xml clob as follow:
xmldom.writeToClob(root, out_xml);
Problem: Now is danish 'x, f, e' replace with ??.
When a use 'xmldom.WriteToFile(root, 'd:\test_document');' I get correctly danish 'x, f, e'!
I have seen you can use procedure/function 'SetEncoding', but I can not find this function in my Oracle installation (8.1.7.1.1).The character set you specify via setCharset() procedure is ignored unless you use writeToFile() later.
http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_xmldom.htm#CHDCGDDB
Usage Notes
This is used for WRITETOFILE Procedures if not explicitly specified at that time.You can also use something like this :
SQL> set serveroutput on
SQL>
SQL> declare
2
3 export_file clob;
4 prolog clob := '<?xml version="1.0" encoding="UTF-8"?>';
5
6 begin
7
8 select prolog || chr(10) ||
9 xmlserialize(document
10 xmlelement("TextTranslation"
11 , xmlattributes(
12 '1.0' as "version"
13 , 'ja' as "language"
14 , 'DEMOAND' as "module"
15 , 'VC' as "type"
16 )
17 )
18 indent
19 )
20 into export_file
21 from dual ;
22
23 dbms_output.put_line ( export_file );
24
25 end;
26 /
<?xml version="1.0" encoding="UTF-8"?>
<TextTranslation version="1.0" language="ja" module="DEMOAND" type="VC"/>
PL/SQL procedure successfully completed -
Steve, why is xmldom.writetoclob so slow ??
I am using xmldom.writetoclob, which is OK when transfering small ( < 1MG ) documents to a CLOB, but as the documetns get bigger it is very slow..
It takes 15 minutes to transfer a 5MB document to a clob using xmldom.writetoclob.
Anything I should be doing to see better results ?
Thanks.
I am using the PL/SQL parserwhat is your java_pool_size?
-
Development backup error (urgent)
Dear All,
I m having problem while taking development backup.log file is attached.plz advice me hoe to resolve this issue.
Detail log: bdxxiprp.ant
BR0051I BRBACKUP 7.00 (13)
BR0189W Expiration period equal 0 - backup volumes could be immediately overwritten
BR0055I Start of database backup: bdxxiprp.ant 2008-05-13 17.40.29
BR0477I Oracle pfile E:\oracle\MRD\102\database\initMRD.ora created from spfile E:\oracle\MRD\102\database\spfileMRD.ora
BR0280I BRBACKUP time stamp: 2008-05-13 17.40.32
BR0319I Control file copy created: G:\oracle\MRD\sapbackup\CNTRLMRD.DBF 24461312
BR0328E Database file Q:\SAPDATA1\SR3_1\SR3.DATA1 of tablespace PSAPSR3 is already in backup status
BR0328E Database file Q:\SAPDATA1\SR3_2\SR3.DATA2 of tablespace PSAPSR3 is already in backup status
BR0328E Database file Q:\SAPDATA1\SR3_3\SR3.DATA3 of tablespace PSAPSR3 is already in backup status
BR0328E Database file Q:\SAPDATA1\SR3_4\SR3.DATA4 of tablespace PSAPSR3 is already in backup status
BR0328E Database file G:\ORACLE\MRD\SAPDATA1\SR3_5\SR3.DATA5 of tablespace PSAPSR3 is already in backup status
BR0328E Database file H:\ORACLE\MRD\SAPDATA2\SR3_6\SR3.DATA6 of tablespace PSAPSR3 is already in backup status
BR0328E Database file H:\ORACLE\MRD\SAPDATA2\SR3_7\SR3.DATA7 of tablespace PSAPSR3 is already in backup status
BR0328E Database file H:\ORACLE\MRD\SAPDATA2\SR3_8\SR3.DATA8 of tablespace PSAPSR3 is already in backup status
BR0328E Database file H:\ORACLE\MRD\SAPDATA2\SR3_9\SR3.DATA9 of tablespace PSAPSR3 is already in backup status
BR0328E Database file H:\ORACLE\MRD\SAPDATA2\SR3_10\SR3.DATA10 of tablespace PSAPSR3 is already in backup status
BR0328E Database file I:\ORACLE\MRD\SAPDATA3\SR3_11\SR3.DATA11 of tablespace PSAPSR3 is already in backup status
BR0328E Database file I:\ORACLE\MRD\SAPDATA3\SR3_12\SR3.DATA12 of tablespace PSAPSR3 is already in backup status
BR0328E Database file I:\ORACLE\MRD\SAPDATA3\SR3_13\SR3.DATA13 of tablespace PSAPSR3 is already in backup status
BR0328E Database file I:\ORACLE\MRD\SAPDATA3\SR3_14\SR3.DATA14 of tablespace PSAPSR3 is already in backup status
BR0328E Database file I:\ORACLE\MRD\SAPDATA3\SR3_15\SR3.DATA15 of tablespace PSAPSR3 is already in backup status
BR0328E Database file J:\ORACLE\MRD\SAPDATA4\SR3_16\SR3.DATA16 of tablespace PSAPSR3 is already in backup status
BR0328E Database file J:\ORACLE\MRD\SAPDATA4\SR3_17\SR3.DATA17 of tablespace PSAPSR3 is already in backup status
BR0328E Database file J:\ORACLE\MRD\SAPDATA4\SR3_18\SR3.DATA18 of tablespace PSAPSR3 is already in backup status
BR0328E Database file J:\ORACLE\MRD\SAPDATA4\SR3_19\SR3.DATA19 of tablespace PSAPSR3 is already in backup status
BR0328E Database file J:\ORACLE\MRD\SAPDATA4\SR3_20\SR3.DATA20 of tablespace PSAPSR3 is already in backup status
BR0056I End of database backup: bdxxiprp.ant 2008-05-13 17.40.35
BR0280I BRBACKUP time stamp: 2008-05-13 17.40.35
BR0054I BRBACKUP terminated with errors
(URGENT.......) .
Note : If i restart my server will it kill the process and then i again can take the backup...Plz advice
Regard'sBasically for some reason your DB is in backup state.
You need to find which tablespaces are in status backup and then execute command:
alter tablespace <tablespace_name> end backup;
That should fix the problem
Regards
Juan -
Using xmldom.writetoclob
I am using the procedure xmldom.writetoclob with the PL/SQL
XDK.
I am running into speed concerns.
Below are some results of tests I have done.
As you can see the time taken to write the contents of the
DOM out to a clob can quickly become problem for a user waiting
for a reponse.
Can any one tell me of a way to speed up this process or a
work around?
Thanks very much
Rick Laird
clob size= 2913
start xmldom.writetoclob= 01:57:53
end xmldom.writetoclob= 01:57:54
clob size= 8909
start xmldom.writetoclob= 01:58:06
end xmldom.writetoclob= 01:58:12
clob size= 14905
start xmldom.writetoclob= 01:58:45
end xmldom.writetoclob= 01:58:55
clob size= 22400
start xmldom.writetoclob= 01:59:44
end xmldom.writetoclob= 01:59:59
clob size= 29895
start xmldom.writetoclob= 02:01:09
end xmldom.writetoclob= 02:01:29
clob size= 172300
start xmldom.writetoclob= 02:05:59
end xmldom.writetoclob= 02:07:54
clob size= 286224
start xmldom.writetoclob= 02:15:34
end xmldom.writetoclob= 02:18:42what version of XDK are you using ?
How much memory do you have ?
I am getting this results :
Writting to clob 01/09/2002 9:51:07 AM
Done writting to clob 01/09/2002 9:51:13 AM
Size of clob : 370433 01/09/2002 9:51:13 AM -
Xmldom.writetoClob()
Hi ,
I've some problem saving back my xml document in Clob:
If I performe the procedure
xmldom.writetobuffer(DomDocument,variable_of_output);
the variable_of_output in varchar2 is well valorized.
Instead
If I performe the procedure
xmldom.writetoClob(DomDocument,variable_of_output);
where the variable_of_output is Clob
THE CODE STOP. The problem is present Even if i inizialize variable_of_output:=empty_clob();
Answer my question,Please.
Thanks youHi,
It probably depends on your database version. If your using 9i, you should use dbms_xmldom instead of xmldom. Furthermore, you might consider to use the following code (instead of the empty clob code):
DECLARE
t_doc DBMS_XMLDOM.DOMDocument;
t_clob CLOB;
BEGIN
... do stuff to fill t_doc
DBMS_LOB.createTemporary(t_clob, FALSE);
DBMS_XMLDOM.writeToClob(t_doc, t_clob);
DBMS_XMLDOM.freeDocument(t_doc);
... do stuff with t_clob
DBMS_LOB.freeTemporary(t_clob);
END;
I'm certain that dbms_xmldom replaces xmldom (v9.2+), I only can't remember the URL which says so...
Kind regards,
Michiel -
WriteToFile(doc DOMDocument,File varchar2) error-Urgent reply needed
The problem description in our environment:-
A xmldom package in the oracle 8.1.7 is trying to create an xml file from a DOMdocument. We are creating this DOMdocument by using an xmlparser. The input to the xmlparser is a file on the unix space.We are able to read the values ,display them. The error happens when the writeToFile method is used to update the xml file after changing the node values in the dom document. The environment seems to be okay or is there any problem with it.
To check our logic, a sample code from the web page http://www.akadia.com/services/ora_gen_xml.html was run.It gave the same error description(ORA-20000).It had also used the same function and the error occured at the same line number.The code from the web page reads as:-
DECLARE
doc sys.xmldom.DOMDocument;
main_node sys.xmldom.DOMNode;
root_node sys.xmldom.DOMNode;
user_node sys.xmldom.DOMNode;
item_node sys.xmldom.DOMNode;
root_elmt sys.xmldom.DOMElement;
item_elmt sys.xmldom.DOMElement;
item_text sys.xmldom.DOMText;
CURSOR get_users(p_deptno NUMBER) IS
SELECT empno
, ename
, deptno
, rownum
FROM emp
WHERE deptno = p_deptno;
BEGIN
doc := sys.xmldom.newDOMDocument;
main_node := sys.xmldom.makeNode(doc);
root_elmt := sys.xmldom.createElement(
doc
, 'EMPSET'
root_node := sys.xmldom.appendChild(
main_node
, sys.xmldom.makeNode(root_elmt)
FOR get_users_rec IN get_users(10) LOOP
item_elmt := sys.xmldom.createElement(
doc
, 'EMP'
sys.xmldom.setAttribute(
item_elmt
, 'num'
, get_users_rec.rownum
user_node := sys.xmldom.appendChild(
root_node
, sys.xmldom.makeNode(item_elmt)
item_elmt := sys.xmldom.createElement(
doc
, 'EMP_NO'
item_node := sys.xmldom.appendChild(
user_node
, sys.xmldom.makeNode(item_elmt)
item_text := sys.xmldom.createTextNode(
doc
, get_users_rec.empno
item_node := sys.xmldom.appendChild(
item_node
, sys.xmldom.makeNode(item_text)
END LOOP;
sys.xmldom.writeToFile(doc , '/user/sb8066\docSample.xml');
sys.xmldom.freeDocument(doc);
END;
The table emp was created with values in it.
Oracle error code:-
ORA-20000: An internal error has occurred: Permission denied
ORA-06512: at "SYS.XMLDOM", line 37
ORA-06512: at "SYS.XMLDOM", line 1784
ORA-06512: at line 61
The priveleges that were required for the above code were:-
GRANT javauserpriv to scott;
GRANT javasyspriv to scott;
GRANT EXECUTE ON xmldom TO scott;
These were also existing for our code and database user.NO clue is there about any possible environmental setting errors.
This code was trying to do the same job that we did but created a document object and not used an existing document object(from a parsing operation).Please advice about possible solutions.It is urgent.
with Regards
gopalHai kevin
I tried both of what you have said .I had also some suggestions from an oracle dba.Can you please help me any idea you have about it.It's regarding the encoding of the xml file.The suggestion was:-I have enclosed the my try for the first solution he suggested.
"ora-2000 is a very generic error ( mostly with intermedia/text/context/apps)
but may occur in regular stuff tooo..
in MOST OF CASES, it does not have any INDIVIDUAL IMPORTANCE at all.
its is resultant of ANOTHER ERROR.
in your case it is
ORA-06512 which is numeric or value error.
somedata is not GOOOD or unwanted character in unwanted place.
so these would be my LOOKOUTS (though, it may not relevent, as my knowledge on XML is very less.
I DONT DO ANY DEVELOPMENT at all. But just support lots n lots n lotsa developers).
1. as per your posting,
> > > sys.xmldom.writeToFile(doc ,
--->-- > > > '/user/temp\docSample.xml');
> > > sys.xmldom.freeDocument(doc);
in general terms, this would be wierd naming(line 2).
for unix '/user/temp/docsample' should do
(beware of file system permissions and case sensitivity in UNIX)
for windows '\usr\temp\docsample' should be used.
except IF U ARE USING UNC / MAPPED DRIVES ( THERE IS A SPECIAL CONSIDERATION
TO USE directory/direcotry\filname..THAT IS DIFFERENT CASE).
check this ( this may lead to error PERMISSION DENIED ( the clasical words from UNIX)
2. to deal with ora-6512, this may posssibly be th reason.
The default character set for XML is UTF8 - special characters indicated would
have an ASCII value > 127. Any character with an ASCII value > 128 is
interpreted as being the leading byte of a multi-byte character in UTF8.
To get around this you need to explicitly specify the character set you are
using. For example:
<?xml version="1.0" encoding="ISO-8859-1" ?>
This tells the XML parser to read the file as ISO-8859-1. If you are using
another character set, substitute the ISO name of the character set in this
line."
Kamal , i tried giving the '/' slash instead of '\' .The oracle reported a error,description as follows.
63 sys.xmldom.writeToFile(doc , '/user/temp/docSample.xml',sys.xmldom.getCharset(doc));
64 sys.xmldom.freeDocument(doc);
65 END;
66 /
UTF8
DECLARE
ERROR at line 1:
ORA-20000: An internal error has occurred: No such file or directory
ORA-06512: at "SYS.XMLDOM", line 37
ORA-06512: at "SYS.XMLDOM", line 1826
ORA-06512: at line 63
It reported error and when i revert back to the previously used slash,it had the old error.You must have read the dba's suggestions.Do you know about how to go about this.Anyway thaks for the help.Will be waiting for your advice.
The UTF8 ouput you must be seeing is the document's charset after me setting it,previously i tried to get the default value after parsing ,it had the same report.
regards
gopal -
Iam getting the error is PERIOD 012/2007 IS NOT OPEND FOR ACCOUNT TYPE S AND G/L 799999.
Please solve me problem urgent.hi
FOR THIS ERROR GOTO OB52 SELECT UR VARIENT WITH A/C TYPE S AND CHANGE THE PERIOD AS PER AS UR REQUIREMENT.
FIRST GOTO OMSY CHECK UR PERIODS ASSIGNED TO UR COMPANY CODE.THEN GOTO OB52 AND CHANGE THE PERIOD AS PER AS UR REQUIREMENT.
REWARD POINTS IF IT HELPS
Maybe you are looking for
-
Stuttering Motion Effects on NTSC monitor
I'm doing a couple of DV-NTSC projects where I'm making some graphics with Motion. And while everything else looks good played back on my external monitor (FireWire route thru DSR11), any Motion clips I make with the 3D Camera Swerve effect stutters
-
Pros and Cons not determining / having a Delivery Plant in Sales Order?
Hi Mates Here I have come-up with one more (weired?) requirement from my client. We have two plants manufacturing same product and supplying to all customers (some time in same sales order with two different line items). At the timeof creating a sale
-
I tried updating my iPhone3g through itunes. Now i'm stuck in recovery mode and i've EVERYTHING even websites and such but nothing worked out! I've also tried restarting and fiddling with the home button but nothing still worked. Please help! What sh
-
How to manipulate authorization at runtime?
Dear JDeveloper's gurus :D I want to implement an authorization system in my application...for example a certain user (the security administrator) can do the following: 1- Grant access to a certain page. 2- Grant Insert, Update, Delete on a certain A
-
Selection screen to appear when user clicks on radio button
hi i have severla radio buttor in a radio button group i want that whne user clicks on first radio butter selection scren 1 eg as below to apper when use clicks on radio buton2 selection scree2 will appear please suggest SELECTION-SCREEN BEGIN OF BLO