The TOOBJECT member procedure maps the XML content in an XMLType instance to a PL/SQL object instance, that is, it deserializes the XML into a PL/SQL object according to its object type structure. It can be used together with DBMS_XMLDOM.GETXMLTYPE: first construct or parse the XML using DOM, then convert it to an XMLType, and finally map it to a PL/SQL object.
Applicability
This content applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL-compatible mode.
Note
For V4.4.2, this subprogram is available starting with OceanBase Database V4.4.2 BP3.
Syntax
MEMBER PROCEDURE toObject(
SELF IN XMLTYPE,
object OUT NOCOPY <object_type>);
Parameters
Parameters |
Explanation |
|---|---|
| SELF | CurrentXMLTypeInstance. |
| object | Instance of the user-defined object type that receives the mapping result.OUT). |
Return value
No return value; the result is written to object.
Usage instructions
- The object type structure of
objectmust match the XML content. If the types do not match or the XML is invalid, an error will be reported at runtime. - Ensure the target object type has been created in the current schema before calling.
Examples
The following example maps an XML snippet corresponding to an object type structure into a PL/SQL object instance. Replace SOME_OBJECT_TYPE with the actual object type name.
DECLARE
x XMLTYPE;
target_obj SOME_OBJECT_TYPE;
BEGIN
x := XMLTYPE('<SOME_OBJECT_TYPE><FIELD1>hello</FIELD1></SOME_OBJECT_TYPE>');
x.toObject(target_obj);
END;
/
