Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Inconsistent ORA-22881: dangling REF

cburnettMay 29 2012 — edited May 29 2012
I have a single schema registered with annotations to cleanly store it into tables and object types of my choosing. I am using this schema to parse XML and store it into my relational tables. All is well except with respect to a single object type that is theoretically self-referencing. Oracle implements this using an XDB$XMLTYPE_REF_LIST_T. Database version is 11.2.0.2.0.
In my PL/SQL code that parses the XML, I am seeing inconsistent behavior when I step through the list, dereference the XML, and convert the XML to my object type. For the same input data, I get two different results.
If I do this:

v_xml XMLTYPE;
inNode CONTAINER_T; -- my object type
containerNode CONTAINER_T; -- my object type
cur_svc INTEGER;

SELECT DEREF (inNode."container" (cur_svc)) INTO v_xml FROM DUAL;
v_xml.toObject (containerNode);

I get ORA-22881: dangling REF

However, if I add a DBMS_OUTPUT statement between the two, it executes without error, and shows me the expected XML string.

SELECT DEREF (inNode."container" (cur_svc)) INTO v_xml FROM DUAL;
DBMS_OUTPUT.put_line (SUBSTR (v_xml.getStringval (), 1, 80));
v_xml.toObject (containerNode);

It appears as if the DBMS_OUTPUT call is somehow stabilizing the XMLTYPE (?!?) to allow the toObject method to operate successfully. This seems a pretty hoaky thing to leave in my code. Is there something else more to the point that I can do to achieve that same stabilization?

Earlier in my procedures, I am using the toObject method with schema name and root element specified. That section of code is very stable, but does not involve a DEREF either. This element is farther down the tree, and the element tag "container" is not unique in the schema, so I have not found a way to further qualify that call successfully.

As an aside, if I substitute this statement
UTL_REF.SELECT_OBJECT (inNode."container" (cur_svc), v_xml);
for the
SELECT DEREF() FROM DUAL;
I get ORA-03113: end-of-file on cummunication channel. Another puzzler.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 26 2012
Added on May 29 2012
3 comments
631 views