Wednesday, April 29, 2009

ORA-31181: PL/SQL DOM handle accesses node that is no longer available

Always check out the original article at http://www.oraclequirks.com for latest comments, fixes and updates.

This morning I'm going for an easy one.

...
l_doc := DBMS_XMLDOM.newDomDocument(cl => l_clob);
l_rootElem := DBMS_XMLDOM.getDocumentElement(doc => l_doc);
DBMS_XMLDOM.freeDocument(l_doc);
l_rootNode := DBMS_XMLDOM.makeNode(elem => l_rootElem); -- this is line 436


DBMS_XMLDOM.freeNode(l_rootNode);
...
end;
/
ORA-31181: PL/SQL DOM handle accesses node that is no longer available
ORA-06512: at "XDB.DBMS_XMLDOM", line 2554
ORA-06512: at "XDB.DBMS_XMLDOM", line 2572
ORA-06512: at "TAMEME.TAMEME", line 436
ORA-06512: at line 6

This error is easily explained: you cannot free the object containing the DOM document until you have finished processing all the objects derived from it.
In the code snippet above, procedure DBMS_XMLDOM.freeDocument must be moved after DBMS_XMLDOM.freeNode.
In other words, the call to DBMS_XMLDOM.makeNode is out of scope.

See message translations for ORA-31181 and search additional resources.

No comments:

yes you can!

Two great ways to help us out with a minimal effort. Click on the Google Plus +1 button above or...
We appreciate your support!

latest articles