XMLType.ToObject()

Hi there,
I am running into a problem when (in Oracle9i Enterprise Edition Release 9.2.0.6.0) trying to map an XML document contained in an XMLType variable to a corresponding object-type variable using the XMLType.ToObject() function.
The problem occurs when the XML contains "repeating" fragments.
I do not know how to define the corresponding object-type in such a way that XMLType.ToObject() does not run into error "ORA-19031: XML element or attribute ... does not match any in type ...".
For example the following XML:
====================
<MyObject>
<ELEMENT01>VALUE01</ELEMENT01>
<ELEMENT02>VALUE02</ELEMENT02>
<MYGROUP>
<GROUPELEMENT01>VALUEG01E01</GROUPELEMENT01>
<GROUPELEMENT02>VALUEG01E02</GROUPELEMENT02>
</MYGROUP>
<MYGROUP>
<GROUPELEMENT01>VALUEG02E01</GROUPELEMENT01>
<GROUPELEMENT02>VALUEG02E02</GROUPELEMENT02>
</MYGROUP>
</MyObject>
====================
The corresponding object-type that I defined is as follows:
====================
create or replace type TP_MYGROUP_REC as object
(GROUPELEMENT01 varchar2(50)
,GROUPELEMENT02 varchar2(50)
create or replace type TP_MYGROUP_TAB as table of TP_MYGROUP_REC;
create or replace type TP_MYOBJECT as object
(ELEMENT01 varchar2(50)
,ELEMENT02 varchar2(50)
,MYGROUP TP_MYGROUP_TAB
====================
I tested with the following script:
====================
declare
l_xmltype xmltype;
l_myobject TP_MYOBJECT;
begin
l_xmltype := XMLTYPE
('<MyObject>
<ELEMENT01>VALUE01</ELEMENT01>
<ELEMENT02>VALUE02</ELEMENT02>
<MYGROUP>
<GROUPELEMENT01>VALUEG01E01</GROUPELEMENT01>
<GROUPELEMENT02>VALUEG01E02</GROUPELEMENT02>
</MYGROUP>
<MYGROUP>
<GROUPELEMENT01>VALUEG02E01</GROUPELEMENT01>
<GROUPELEMENT02>VALUEG02E02</GROUPELEMENT02>
</MYGROUP>
</MyObject>');
l_xmltype.ToObject(l_myobject);
end;
====================
This results in: ORA-19031: XML element or attribute GROUPELEMENT01 does not match any in type TP_MYGROUP_REC.
Does anyone out there know how to define the object-type(s) in such a way that I can cast this type of XML to an object using XMLType.ToObject() ?
Thanks a lot for your reaction,
Jaap Kool

In absence of an XML schema, Oracle uses a canonical mapping between SQL objects and XML.
For instance, the XML structure corresponding to the object hierarchy defined in the first post is :
<TP_MYOBJECT>
  <ELEMENT01>VALUE01</ELEMENT01>
  <ELEMENT02>VALUE02</ELEMENT02>
  <MYGROUP>
    <TP_MYGROUP_REC>
      <GROUPELEMENT01>VALUEG01E01</GROUPELEMENT01>
      <GROUPELEMENT02>VALUEG01E02</GROUPELEMENT02>
    </TP_MYGROUP_REC>
    <TP_MYGROUP_REC>
      <GROUPELEMENT01>VALUEG02E01</GROUPELEMENT01>
      <GROUPELEMENT02>VALUEG02E02</GROUPELEMENT02>
    </TP_MYGROUP_REC>
  </MYGROUP>
</TP_MYOBJECT>Note the additional "TP_MYGROUP_REC" element that encloses the two leaf values.
With that input, this works :
SQL> declare
  2    l_xmltype  xmltype;
  3    l_myobject TP_MYOBJECT;
  4  begin
  5    l_xmltype := XMLTYPE(
  6  '<TP_MYOBJECT>
  7    <ELEMENT01>VALUE01</ELEMENT01>
  8    <ELEMENT02>VALUE02</ELEMENT02>
  9    <MYGROUP>
10      <TP_MYGROUP_REC>
11        <GROUPELEMENT01>VALUEG01E01</GROUPELEMENT01>
12        <GROUPELEMENT02>VALUEG01E02</GROUPELEMENT02>
13      </TP_MYGROUP_REC>
14      <TP_MYGROUP_REC>
15        <GROUPELEMENT01>VALUEG02E01</GROUPELEMENT01>
16        <GROUPELEMENT02>VALUEG02E02</GROUPELEMENT02>
17      </TP_MYGROUP_REC>
18    </MYGROUP>
19  </TP_MYOBJECT>');
20 
21    l_xmltype.ToObject(l_myobject);
22 
23    dbms_output.put_line(l_myobject.mygroup(1).groupelement01);
24 
25  end;
26  /
VALUEG01E01
PL/SQL procedure successfully completed
Here's the approach you can follow to achieve a "custom" mapping :
{thread:id=2475819}
and,
{message:id=10712117}
Edited by: odie_63 on 20 déc. 2012 09:54

Similar Messages

  • Alternative to XMLTYPE.TOOBJECT to populate a UDT

    Is there any alternative option that can be utilized other than the XMLTYPE.TOOBJECT to populate an oracle object via a clob or raw or XML string?

    Maybe something like this?:
    SQL> DECLARE
       l_xml   XMLTYPE
          := XMLTYPE
               ('<?xml version="1.0"?><root><itm>A</itm><itm>B</itm><itm>C</itm><itm>D</itm></root>'
       TYPE t_num IS TABLE OF VARCHAR2 (50)
          INDEX BY BINARY_INTEGER;
       v_val   t_num;
    BEGIN
       FOR c IN (SELECT ROWNUM, EXTRACTVALUE (COLUMN_VALUE, 'itm/text()') itm
                   FROM TABLE (XMLSEQUENCE (EXTRACT (l_xml, '/root/itm'))))
       LOOP
          v_val (c.ROWNUM) := c.itm;
       END LOOP;
       FOR i IN 1 .. v_val.COUNT
       LOOP
          DBMS_OUTPUT.put_line ('Item ' || i || ': ' || v_val (i));
       END LOOP;
    END;
    Item 1: A
    Item 2: B
    Item 3: C
    Item 4: D
    PL/SQL procedure successfully completed.

  • Xmltype.toObject() creates partly empty object

    xmltype.toObject() creates an object of the type created when registering the XML schema but in this object all text-elements are empty.
    I registered an XML Schema in XDB 9i release 2.
    When I create an instance of xmltype using CreateSchemabasedXML, toObjects creates an object in which all varchar "members" are empty. members which consist of furter object-types are not null, but within these objects the varchar members again are empty.
    Is toObject() only partially implemented?

    Seems you encountered the bug described in
    Bug 3578226 - ORA-22814 when using XMLtype.toObject with empty XML elements.
    The workaround mentioned there states to »store empty elements like <TEST/>«. Try if that helps.

  • Seems taht XMLType.toObject() doesn't work well ...

    Hello,
    We are trying to convert XML file into XMLType object and then to our custom object type using registered XSD definition. So we doing this : clob with xml -> XMLObject -> our MMS_T object.
    The problem we experienced with transfering values of "type" and "status" attributes to object values MMS_T.TYPE and MMS_T.STATUS. Note that types MMS_T and ERROR_T are automatically created during schema
    (XSD) registration. See and try Listing 1.
    The second Listing contains anonymous pl/sql block with our testcase, please run it after registering schema. The output You will get should look like this one :
    Schema based
    Well-formed
    <?xml version="1.0" encoding="UTF-8"?>
    <mms-provisioning xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xdb="http://xmlns.oracle.com/xdb"
    type="subscription"
    status="error">
    <error code="1">Some error</error>
    <serviceID>iDnes</ser
    Type:,Status:,Error:1-Some error,ServiceID:iDnes,Method:SMS,MSISDN:+420602609903
    The problem is visible on the last line, where "Type" and "Status" object attributes should have its values that should come from XML, but they haven't. Where we were wrong ?
    Please help,
    Thanks & Regards,
    Radim.
    Note
    ====
    When we are trying to do xml.schemaValidate() in our example, it raises folowong errors :
    ORA-31154: invalid XML document
    ORA-19202: Error occurred in XML processing
    LSX-00310: local element or attribute should be namespace qualified
    ORA-06512: at "SYS.XMLTYPE", line 0
    ORA-06512: at line 27
    Listing 1
    =========
    declare
    xsd clob:=
    '<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xdb="http://xmlns.oracle.com/xdb"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified"
    xdb:mapStringToNCHAR="false"
    xdb:mapUnboundedStringToLob="false"
    xdb:storeVarrayAsTable="false"
    >
         <xs:element name="mms-provisioning" xdb:SQLType="MMS_T">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="error" minOccurs="0" xdb:SQLName="ERROR" xdb:SQLType="ERROR_T">
                             <xs:complexType>
                                  <xs:simpleContent>
                                       <xs:extension base="xs:string">
                                            <xs:attribute name="code" type="xs:decimal" use="required" xdb:SQLName="CODE" xdb:SQLType="NUMBER"/>
                                       </xs:extension>
                                  </xs:simpleContent>
                             </xs:complexType>
                        </xs:element>
                        <xs:element name="serviceID" type="xs:string" xdb:SQLName="SERVICEID" xdb:SQLType="VARCHAR2"/>
                        <xs:element name="method" type="xs:string" xdb:SQLName="METHOD" xdb:SQLType="VARCHAR2"/>
                        <xs:element name="msisdn" type="xs:string" xdb:SQLName="MSISDN" xdb:SQLType="VARCHAR2"/>
                   </xs:sequence>
                   <xs:attribute name="type" type="type_t" use="required" xdb:SQLName="TYP" xdb:SQLType="VARCHAR2"/>
                   <xs:attribute name="status" type="status_t" use="required" xdb:SQLName="STATUS" xdb:SQLType="VARCHAR2"/>
              </xs:complexType>
         </xs:element>
         <xs:simpleType name="status_t">
              <xs:restriction base="xs:string">
                   <xs:maxLength value="30"/>
                   <xs:enumeration value="new"/>
                   <xs:enumeration value="pending"/>
                   <xs:enumeration value="subscribed"/>
                   <xs:enumeration value="error"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="type_t">
              <xs:restriction base="xs:string">
              <xs:maxLength value="30"/>
              <xs:enumeration value="subscription"/>
              <xs:enumeration value="unsubscription"/>
              </xs:restriction>
         </xs:simpleType>
    </xs:schema>';
    begin
    dbms_XMLSchema.RegisterSchema (
    SchemaURL => 'http://www.eurotel.cz/xsd/mms-provisioning.xsd',
    SchemaDoc => xsd
    end;
    Listing 2
    =========
    declare
    o mms_t;
    doc clob :=
    '<?xml version="1.0" encoding="UTF-8"?>
    <mms-provisioning type="subscription" status="error">
         <error code="1">Some error</error>
         <serviceID>iDnes</serviceID>
         <method>SMS</method>
         <msisdn>+420602608696</msisdn>
    </mms-provisioning>';
    xml XMLType;
    begin
    xml := XMLType.createXML(XMLData => doc,schema => 'http://www.eurotel.cz/xsd/mms-provisioning.xsd');
    if xml.isSchemaBased() = 1 then
    dbms_output.put_line('Schema based');
    else
    dbms_output.put_line('Non-Schema based');
    end if;
    if xml.isFragment() = 1 then
    dbms_output.put_line('Fragment');
    else
    dbms_output.put_line('Well-formed');
    end if;
    --Crashes with errors
    --xml.schemaValidate();
    dbms_output.put_line(substr(xml.getstringval(),1,255));
    xml.toObject(o,schema => 'http://www.eurotel.cz/xsd/mms-provisioning.xsd', element => 'mms-provisioning');
    dbms_output.put_line(
    'Type:'||o.typ||
    ',Status:'||o.status||
    ',Error:'||o.error.code||'-'||o.error.sys_xdbbody$||
    ',ServiceID:'||o.serviceid||
    ',Method:'||o.method||
    ',MSISDN:'||o.msisdn);
    end;
    /

    Hello,
    We are trying to convert XML file into XMLType object and then to our custom object type using registered XSD definition. So we doing this : clob with xml -> XMLObject -> our MMS_T object.
    The problem we experienced with transfering values of "type" and "status" attributes to object values MMS_T.TYPE and MMS_T.STATUS. Note that types MMS_T and ERROR_T are automatically created during schema
    (XSD) registration. See and try Listing 1.
    The second Listing contains anonymous pl/sql block with our testcase, please run it after registering schema. The output You will get should look like this one :
    Schema based
    Well-formed
    <?xml version="1.0" encoding="UTF-8"?>
    <mms-provisioning xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xdb="http://xmlns.oracle.com/xdb"
    type="subscription"
    status="error">
    <error code="1">Some error</error>
    <serviceID>iDnes</ser
    Type:,Status:,Error:1-Some error,ServiceID:iDnes,Method:SMS,MSISDN:+420602609903
    The problem is visible on the last line, where "Type" and "Status" object attributes should have its values that should come from XML, but they haven't. Where we were wrong ?
    Please help,
    Thanks & Regards,
    Radim.
    Note
    ====
    When we are trying to do xml.schemaValidate() in our example, it raises folowong errors :
    ORA-31154: invalid XML document
    ORA-19202: Error occurred in XML processing
    LSX-00310: local element or attribute should be namespace qualified
    ORA-06512: at "SYS.XMLTYPE", line 0
    ORA-06512: at line 27
    Listing 1
    =========
    declare
    xsd clob:=
    '<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xdb="http://xmlns.oracle.com/xdb"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified"
    xdb:mapStringToNCHAR="false"
    xdb:mapUnboundedStringToLob="false"
    xdb:storeVarrayAsTable="false"
    >
         <xs:element name="mms-provisioning" xdb:SQLType="MMS_T">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="error" minOccurs="0" xdb:SQLName="ERROR" xdb:SQLType="ERROR_T">
                             <xs:complexType>
                                  <xs:simpleContent>
                                       <xs:extension base="xs:string">
                                            <xs:attribute name="code" type="xs:decimal" use="required" xdb:SQLName="CODE" xdb:SQLType="NUMBER"/>
                                       </xs:extension>
                                  </xs:simpleContent>
                             </xs:complexType>
                        </xs:element>
                        <xs:element name="serviceID" type="xs:string" xdb:SQLName="SERVICEID" xdb:SQLType="VARCHAR2"/>
                        <xs:element name="method" type="xs:string" xdb:SQLName="METHOD" xdb:SQLType="VARCHAR2"/>
                        <xs:element name="msisdn" type="xs:string" xdb:SQLName="MSISDN" xdb:SQLType="VARCHAR2"/>
                   </xs:sequence>
                   <xs:attribute name="type" type="type_t" use="required" xdb:SQLName="TYP" xdb:SQLType="VARCHAR2"/>
                   <xs:attribute name="status" type="status_t" use="required" xdb:SQLName="STATUS" xdb:SQLType="VARCHAR2"/>
              </xs:complexType>
         </xs:element>
         <xs:simpleType name="status_t">
              <xs:restriction base="xs:string">
                   <xs:maxLength value="30"/>
                   <xs:enumeration value="new"/>
                   <xs:enumeration value="pending"/>
                   <xs:enumeration value="subscribed"/>
                   <xs:enumeration value="error"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="type_t">
              <xs:restriction base="xs:string">
              <xs:maxLength value="30"/>
              <xs:enumeration value="subscription"/>
              <xs:enumeration value="unsubscription"/>
              </xs:restriction>
         </xs:simpleType>
    </xs:schema>';
    begin
    dbms_XMLSchema.RegisterSchema (
    SchemaURL => 'http://www.eurotel.cz/xsd/mms-provisioning.xsd',
    SchemaDoc => xsd
    end;
    Listing 2
    =========
    declare
    o mms_t;
    doc clob :=
    '<?xml version="1.0" encoding="UTF-8"?>
    <mms-provisioning type="subscription" status="error">
         <error code="1">Some error</error>
         <serviceID>iDnes</serviceID>
         <method>SMS</method>
         <msisdn>+420602608696</msisdn>
    </mms-provisioning>';
    xml XMLType;
    begin
    xml := XMLType.createXML(XMLData => doc,schema => 'http://www.eurotel.cz/xsd/mms-provisioning.xsd');
    if xml.isSchemaBased() = 1 then
    dbms_output.put_line('Schema based');
    else
    dbms_output.put_line('Non-Schema based');
    end if;
    if xml.isFragment() = 1 then
    dbms_output.put_line('Fragment');
    else
    dbms_output.put_line('Well-formed');
    end if;
    --Crashes with errors
    --xml.schemaValidate();
    dbms_output.put_line(substr(xml.getstringval(),1,255));
    xml.toObject(o,schema => 'http://www.eurotel.cz/xsd/mms-provisioning.xsd', element => 'mms-provisioning');
    dbms_output.put_line(
    'Type:'||o.typ||
    ',Status:'||o.status||
    ',Error:'||o.error.code||'-'||o.error.sys_xdbbody$||
    ',ServiceID:'||o.serviceid||
    ',Method:'||o.method||
    ',MSISDN:'||o.msisdn);
    end;
    /

  • Rumours about xmltype toobject becoming depricated

    We have been using the toobject functionality of the xmltype within
    the 10 database. A few posts on these forums suggest that in the
    future this functionality will become depricated. This worries me.
    I would like to know what the plans are for this functionality.
    Thanks for the reply in advance.

  • Partial XMLType toObject

    Hi,
    I have an XML schema registered with Oracle. The schema is annotated and during registration the PL/SQL types are created. I can validate an XMLType with this schema, as well as use toObject to populate an object with data from the XMLType. The XML looks like this:
    <root>
    <complexObject>...... very complex object with many elements, sub-elements and sequences .......</complexObject>
    <complexObject>...... very complex object with many elements, sub-elements and sequences .......</complexObject>
    <complexObject>...... very complex object with many elements, sub-elements and sequences .......</complexObject>
    <complexObject>...... very complex object with many elements, sub-elements and sequences .......</complexObject>
    <complexObject>...... very complex object with many elements, sub-elements and sequences .......</complexObject>
    </root>
    There can be a lot of "complexObject" elements in the sequence and the XML can be huge.
    The <root> element has the corresponding T_ROOT type, the <complexObject> elements had the corresponding T_COMPLEXOBJECT type. T_ROOT has a VARRAY of T_COMPLEXOBJECT.
    So, like I said before, I can populate an object of type T_ROOT from the XML without an issue using toObject on the XMLType. However, due to the complexity and size of the XML, I want to split the big XML into multiple T_COMPLEXOBJECT objects. I can do this using XPath extract in a query, returning me one XMLType row per "complexObject". Here is where I'm stuck: I want to use a cursor on the above query and process each "complexObject" one by one. For this, I need to somehow be able to do something similar with toObject, but on the "complexObject" XMLType fragment only to populate an object of type T_COMPLEXOBJECT, not on the whole T_ROOT.
    If I do:
    l_xml.toObject(l_obj, 'myschema.xsd', 'complexObject');
    instead of
    l_xml.toObject(l_obj_root, 'myschema.xsd', 'root');
    I get:
    ORA-31043: Element 'complexObject' not globally defined in schema 'myschema.xsd'
    ORA-06512: at "SYS.XMLTYPE", line 196
    ORA-06512: at line 38
    Thanks!
    Edited by: 1005635 on May 13, 2013 10:40 AM

    Here's an example
    SQL> --
    SQL> -- def XMLDIR = &1
    SQL> --
    SQL> def USER_TABLESPACE = USERS
    SQL> --
    SQL> def TEMP_TABLESPACE = TEMP
    SQL> --
    SQL> drop user &USERNAME cascade
      2  /
    old   1: drop user &USERNAME cascade
    new   1: drop user XDBTEST cascade
    User dropped.
    Elapsed: 00:00:01.31
    SQL> grant unlimited tablespace, create any directory, drop any directory, connect, resource, alter session, create view to &USERNAME identified by &PASSWORD
      2  /
    old   1: grant unlimited tablespace, create any directory, drop any directory, connect, resource, alter session, create view to &USERNAME identified by &PASSWOR
    D
    new   1: grant unlimited tablespace, create any directory, drop any directory, connect, resource, alter session, create view to XDBTEST identified by XDBTEST
    Grant succeeded.
    Elapsed: 00:00:00.03
    SQL> alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
      2  /
    old   1: alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
    new   1: alter user XDBTEST default tablespace USERS temporary tablespace TEMP
    User altered.
    Elapsed: 00:00:00.00
    SQL> connect &USERNAME/&PASSWORD
    Connected.
    SQL> --
    SQL> -- create or replace directory XMLDIR as '&XMLDIR'
    SQL> -- /
    SQL> var SCHEMAURL       varchar2(256)
    SQL> var XMLSCHEMA       CLOB
    SQL> var INSTANCE        CLOB;
    SQL> --
    SQL> set define off
    SQL> --
    SQL> alter session set events='31098 trace name context forever'
      2  /
    Session altered.
    Elapsed: 00:00:00.00
    SQL>
    SQL> begin
      2    :XMLSCHEMA :=
      3  '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
      4          <xs:element name="PurchaseOrder" type="PurchaseOrderType"/>
      5          <xs:complexType name="PurchaseOrderType">
      6                  <xs:sequence>
      7                          <xs:element name="Reference" type="ReferenceType"/>
      8                          <xs:element name="Actions" type="ActionsType"/>
      9                          <xs:element name="Rejection" type="RejectionType" minOccurs="0"/>
    10                          <xs:element name="Requestor" type="RequestorType"/>
    11                          <xs:element name="User" type="UserType"/>
    12                          <xs:element name="CostCenter" type="CostCenterType"/>
    13                          <xs:element name="ShippingInstructions" type="ShippingInstructionsType"/>
    14                          <xs:element name="SpecialInstructions" type="SpecialInstructionsType"/>
    15                          <xs:element name="LineItems" type="LineItemsType"/>
    16                  </xs:sequence>
    17                  <xs:attribute name="DateCreated" type="xs:dateTime" use="required"/>
    18          </xs:complexType>
    19          <xs:complexType name="LineItemsType">
    20                  <xs:sequence>
    21                          <xs:element name="LineItem" type="LineItemType" maxOccurs="unbounded"/>
    22                  </xs:sequence>
    23          </xs:complexType>
    24          <xs:complexType name="LineItemType">
    25                  <xs:sequence>
    26                          <xs:element name="Part" type="PartType"/>
    27                          <xs:element name="Quantity" type="QuantityType"/>
    28                  </xs:sequence>
    29                  <xs:attribute name="ItemNumber" type="xs:integer"/>
    30          </xs:complexType>
    31          <xs:complexType name="PartType">
    32                  <xs:simpleContent>
    33                          <xs:extension base="UPCCodeType">
    34                                  <xs:attribute name="Description" type="DescriptionType" use="required"/>
    35                                  <xs:attribute name="UnitPrice" type="MoneyType" use="required"/>
    36                          </xs:extension>
    37                  </xs:simpleContent>
    38          </xs:complexType>
    39          <xs:simpleType name="ReferenceType">
    40                  <xs:restriction base="xs:string">
    41                          <xs:minLength value="18"/>
    42                          <xs:maxLength value="30"/>
    43                  </xs:restriction>
    44          </xs:simpleType>
    45          <xs:complexType name="ActionsType">
    46                  <xs:sequence>
    47                          <xs:element name="Action" maxOccurs="4">
    48                                  <xs:complexType>
    49                                          <xs:sequence>
    50                                                  <xs:element name="User" type="UserType"/>
    51                                                  <xs:element name="Date" type="DateType" minOccurs="0"/>
    52                                          </xs:sequence>
    53                                  </xs:complexType>
    54                          </xs:element>
    55                  </xs:sequence>
    56          </xs:complexType>
    57          <xs:complexType name="RejectionType">
    58                  <xs:all>
    59                          <xs:element name="User" type="UserType" minOccurs="0"/>
    60                          <xs:element name="Date" type="DateType" minOccurs="0"/>
    61                          <xs:element name="Comments" type="CommentsType" minOccurs="0"/>
    62                  </xs:all>
    63          </xs:complexType>
    64          <xs:complexType name="ShippingInstructionsType">
    65                  <xs:sequence>
    66                          <xs:element name="name" type="NameType" minOccurs="0"/>
    67                          <xs:element name="address" type="AddressType" minOccurs="0"/>
    68                          <xs:element name="telephone" type="TelephoneType" minOccurs="0"/>
    69                  </xs:sequence>
    70          </xs:complexType>
    71          <xs:simpleType name="MoneyType">
    72                  <xs:restriction base="xs:decimal">
    73                          <xs:fractionDigits value="2"/>
    74                          <xs:totalDigits value="12"/>
    75                  </xs:restriction>
    76          </xs:simpleType>
    77          <xs:simpleType name="QuantityType">
    78                  <xs:restriction base="xs:decimal">
    79                          <xs:fractionDigits value="4"/>
    80                          <xs:totalDigits value="8"/>
    81                  </xs:restriction>
    82          </xs:simpleType>
    83          <xs:simpleType name="UserType">
    84                  <xs:restriction base="xs:string">
    85                          <xs:minLength value="1"/>
    86                          <xs:maxLength value="10"/>
    87                  </xs:restriction>
    88          </xs:simpleType>
    89          <xs:simpleType name="RequestorType">
    90                  <xs:restriction base="xs:string">
    91                          <xs:minLength value="0"/>
    92                          <xs:maxLength value="128"/>
    93                  </xs:restriction>
    94          </xs:simpleType>
    95          <xs:simpleType name="CostCenterType">
    96                  <xs:restriction base="xs:string">
    97                          <xs:minLength value="1"/>
    98                          <xs:maxLength value="4"/>
    99                          <xs:enumeration value=""/>
    100                          <xs:enumeration value="A0"/>
    101                          <xs:enumeration value="A10"/>
    102                          <xs:enumeration value="A20"/>
    103                          <xs:enumeration value="A30"/>
    104                          <xs:enumeration value="A40"/>
    105                          <xs:enumeration value="A50"/>
    106                          <xs:enumeration value="A60"/>
    107                          <xs:enumeration value="A70"/>
    108                          <xs:enumeration value="A80"/>
    109                          <xs:enumeration value="A90"/>
    110                          <xs:enumeration value="A100"/>
    111                          <xs:enumeration value="A110"/>
    112                  </xs:restriction>
    113          </xs:simpleType>
    114          <xs:simpleType name="PurchaseOrderNumberType">
    115                  <xs:restriction base="xs:integer"/>
    116          </xs:simpleType>
    117          <xs:simpleType name="SpecialInstructionsType">
    118                  <xs:restriction base="xs:string">
    119                          <xs:minLength value="0"/>
    120                          <xs:maxLength value="1000"/>
    121                  </xs:restriction>
    122          </xs:simpleType>
    123          <xs:simpleType name="NameType">
    124                  <xs:restriction base="xs:string">
    125                          <xs:minLength value="1"/>
    126                          <xs:maxLength value="20"/>
    127                  </xs:restriction>
    128          </xs:simpleType>
    129          <xs:simpleType name="AddressType">
    130                  <xs:restriction base="xs:string">
    131                          <xs:minLength value="1"/>
    132                          <xs:maxLength value="256"/>
    133                  </xs:restriction>
    134          </xs:simpleType>
    135          <xs:simpleType name="TelephoneType">
    136                  <xs:restriction base="xs:string">
    137                          <xs:minLength value="1"/>
    138                          <xs:maxLength value="24"/>
    139                  </xs:restriction>
    140          </xs:simpleType>
    141          <xs:simpleType name="DateType">
    142                  <xs:restriction base="xs:date"/>
    143          </xs:simpleType>
    144          <xs:simpleType name="CommentsType">
    145                  <xs:restriction base="xs:string">
    146                          <xs:minLength value="1"/>
    147                          <xs:maxLength value="1000"/>
    148                  </xs:restriction>
    149          </xs:simpleType>
    150          <xs:simpleType name="DescriptionType">
    151                  <xs:restriction base="xs:string">
    152                          <xs:minLength value="1"/>
    153                          <xs:maxLength value="128"/>
    154                  </xs:restriction>
    155          </xs:simpleType>
    156          <xs:simpleType name="UPCCodeType">
    157                  <xs:restriction base="xs:string">
    158                          <xs:minLength value="11"/>
    159                          <xs:maxLength value="14"/>
    160                          <xs:pattern value="\d{11}"/>
    161                          <xs:pattern value="\d{12}"/>
    162                          <xs:pattern value="\d{13}"/>
    163                          <xs:pattern value="\d{14}"/>
    164                  </xs:restriction>
    165          </xs:simpleType>
    166  </xs:schema>';
    167    :INSTANCE :=
    168  '<PurchaseOrder>
    169     <Reference>ABULL-20100809203001136PDT</Reference>
    170     <Actions>
    171        <Action>
    172           <User>ACABRIO</User>
    173        </Action>
    174     </Actions>
    175     <Rejection/>
    176     <Requestor>Alexis Bull</Requestor>
    177     <User>ABULL</User>
    178     <CostCenter>A50</CostCenter>
    179     <ShippingInstructions>
    180        <name>Alexis Bull</name>
    181        <address>2011 Interiors Blvd,
    182  South San Francisco,
    183  California 99236
    184  United States of America</address>
    185        <telephone>950-720-3387</telephone>
    186     </ShippingInstructions>
    187     <SpecialInstructions>COD</SpecialInstructions>
    188     <LineItems>
    189        <LineItem ItemNumber="1" >
    190           <Part Description="Scary Movie" UnitPrice="19.95">717951004857</Part>
    191           <Quantity>5.0</Quantity>
    192        </LineItem>
    193        <LineItem ItemNumber="2" >
    194           <Part Description="The Faculty" UnitPrice="19.95">717951002280</Part>
    195           <Quantity>2.0</Quantity>
    196        </LineItem>
    197        <LineItem ItemNumber="3">
    198           <Part Description="Phantom of the Paradise" UnitPrice="27.95">24543023777</Part>
    199           <Quantity>3.0</Quantity>
    200        </LineItem>
    201     </LineItems>
    202  </PurchaseOrder>';
    203  end;
    204  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00
    SQL> declare
      2    V_XML_SCHEMA xmlType := XMLType(:XMLSCHEMA1);end;
      3  /
    SP2-0552: Bind variable "XMLSCHEMA1" not declared.
    Elapsed: 00:00:00.00
    SQL> --
    SQL> declare
      2    V_XMLSCHEMA XMLTYPE := XMLTYPE(:XMLSCHEMA);
      3  begin
      4    DBMS_XMLSCHEMA.registerSchema(
      5      schemaURL => 'http://localhost:80/home/SCOTT/poSource/xsd/purchaseOrder.xsd',
      6      schemaDoc => V_XMLSCHEMA,
      7      local     => TRUE,
      8      genTypes  => TRUE,
      9      genTables => FALSE
    10    );
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.35
    SQL> create table PURCHASEORDER
      2         of XMLTYPE
      3         XMLSCHEMA "http://localhost:80/home/SCOTT/poSource/xsd/purchaseOrder.xsd" ELEMENT "PurchaseOrder"
      4  /
    Table created.
    Elapsed: 00:00:00.10
    SQL> call DBMS_XMLSTORAGE_MANAGE.renameCollectionTable (USER,'PURCHASEORDER',NULL,'/PurchaseOrder/LineItems/LineItem','LINEITEM_TABLE',NULL)
      2  /
    Call completed.
    Elapsed: 00:00:00.87
    SQL> call DBMS_XMLSTORAGE_MANAGE.renameCollectionTable (USER,'PURCHASEORDER',NULL,'/PurchaseOrder/Actions/Action','ACTION_TABLE',NULL)
      2  /
    Call completed.
    Elapsed: 00:00:00.09
    SQL> desc PURCHASEORDER
    Name                                      Null?    Type
    TABLE of SYS.XMLTYPE(XMLSchema "http://localhost:80/home/SCOTT/poSource/xsd/purchaseOrder.xsd" Element "PurchaseOrder") STORAGE Object-relational TYPE "Purchase
    OrderType667_T"
    SQL> --
    SQL> insert into PURCHASEORDER values (XMLTYPE(:INSTANCE))
      2  /
    1 row created.
    Elapsed: 00:00:00.44
    SQL> commit
      2  /
    Commit complete.
    Elapsed: 00:00:00.00
    SQL> create or replace type ACTION_T as object (
      2    USER_NAME                                          VARCHAR2(10 CHAR),
      3    ACTION_DATE                                        DATE
      4  )
      5  /
    Type created.
    Elapsed: 00:00:00.02
    SQL> show errors
    No errors.
    SQL> /
    Type created.
    Elapsed: 00:00:00.01
    SQL> create or replace type ACTION_V as VARRAY(32767) of ACTION_T
      2  /
    Type created.
    Elapsed: 00:00:00.01
    SQL> show errors
    No errors.
    SQL> --
    SQL> create or replace type ACTIONS_T as object (
      2    ACTION  ACTION_V
      3  )
      4  /
    Type created.
    Elapsed: 00:00:00.01
    SQL> show errors
    No errors.
    SQL> --
    SQL> create or replace type REJECTION_T as object (
      2    USER_NAME                                          VARCHAR2(10 CHAR),
      3    REJECTION_DATE                                     DATE,
      4    COMMENTS                                           VARCHAR2(1000 CHAR)
      5  )
      6  /
    Type created.
    Elapsed: 00:00:00.01
    SQL> show errors
    No errors.
    SQL> --
    SQL> create or replace type SHIPPING_INSTRUCTIONS_T as object (
      2    NAME                                               VARCHAR2(20 CHAR),
      3    ADDRESS                                            VARCHAR2(256 CHAR),
      4    TELEPHONE                                          VARCHAR2(24 CHAR)
      5  )
      6  /
    Type created.
    Elapsed: 00:00:00.01
    SQL> show errors
    No errors.
    SQL> --
    SQL> create or replace type PART_T as object (
      2   PART_TEXT                                          VARCHAR2(14 CHAR),
      3   DESCRIPTION                                        VARCHAR2(128 CHAR),
      4   UNITPRICE                                          NUMBER(14,2)
      5  )
      6  /
    Type created.
    Elapsed: 00:00:00.01
    SQL> show errors
    No errors.
    SQL> /
    Type created.
    Elapsed: 00:00:00.00
    SQL> create or replace type LINEITEM_T as object (
      2    ITEMNUMBER                                         NUMBER(38),
      3    PART                                               PART_T,
      4    QUANTITY                                           NUMBER(12,4)
      5  )
      6  /
    Type created.
    Elapsed: 00:00:00.01
    SQL> show errors
    No errors.
    SQL> /
    Type created.
    Elapsed: 00:00:00.00
    SQL> create or replace type LINEITEM_V as VARRAY(32767) of LINEITEM_T
      2  /
    Type created.
    Elapsed: 00:00:00.01
    SQL> show errors
    No errors.
    SQL> --
    SQL> create or replace type LINEITEMS_T as object (
      2    LINEITEM  LINEITEM_V
      3  )
      4  /
    Type created.
    Elapsed: 00:00:00.01
    SQL> show errors
    No errors.
    SQL> --
    SQL> create or replace type PURCHASEORDER_T as object (
      2   DATECREATED                                        TIMESTAMP(6),
      3   REFERENCE                                          VARCHAR2(30 CHAR),
      4   ACTIONS                                            ACTIONS_T,
      5   REJECTION                                          REJECTION_T,
      6   REQUESTOR                                          VARCHAR2(128 CHAR),
      7   USER_NAME                                          VARCHAR2(10 CHAR),
      8   COSTCENTER                                         VARCHAR2(4 CHAR),
      9   SHIPPINGINSTRUCTIONS                               SHIPPING_INSTRUCTIONS_T,
    10   SPECIALINSTRUCTIONS                                VARCHAR2(1000 CHAR),
    11   LINEITEMS                                          LINEITEMS_T
    12  )
    13  /
    Type created.
    Elapsed: 00:00:00.12
    SQL> show errors
    No errors.
    SQL> --
    SQL> select PURCHASEORDER_T (
      2           DATECREATED,
      3                                   REFERENCE,
      4                                   ACTIONS_T(
      5                                     CAST(
      6               MULTISET(
      7                 SELECT ACTION_T(
      8                          USER_NAME,
      9                          ACTION_DATE
    10                        )
    11                   FROM XMLTABLE(
    12                         '/Actions/Action'
    13                          passing ACTIONS
    14                          columns
    15                            USER_NAME        VARCHAR2(10 CHAR) path 'User',
    16                            ACTION_DATE      DATE              path 'Date'
    17                        )
    18               ) AS ACTION_V
    19             )
    20           ),
    21           (
    22                             select REJECTION_T (
    23                      USER_NAME,
    24                      REJECTION_DATE,
    25                      COMMENTS
    26                    )
    27               from XMLTABLE(
    28                      '/Rejection'
    29                      passing REJECTION
    30                      columns
    31                        USER_NAME         VARCHAR2(10 CHAR)     path 'User',
    32                        REJECTION_DATE    DATE                  path 'Date',
    33                        COMMENTS          VARCHAR2(1000 CHAR)   path 'Comments'
    34                    )
    35           ),
    36                                   REQUESTOR,
    37                                   USER_NAME,
    38           COSTCENTER,
    39                           (
    40                             select SHIPPING_INSTRUCTIONS_T (
    41                      USER_NAME,
    42                      ADDRESS,
    43                      TELEPHONE
    44                    )
    45               from XMLTABLE(
    46                      '/ShippingInstructions'
    47                      passing SHIPPING_INSTRUCTIONS
    48                      columns
    49                        USER_NAME       VARCHAR2(20 CHAR)    path 'name',
    50                        ADDRESS         VARCHAR2(256 CHAR)   path 'address',
    51                        TELEPHONE       VARCHAR2(24 CHAR)    path 'telephone'
    52                    )
    53           ),
    54           SPECIAL_INSTRUCTIONS,
    55                                   LINEITEMS_T(
    56                                     CAST(
    57               MULTISET(
    58                 SELECT LINEITEM_T (
    59                          ITEMNUMBER,
    60                          (
    61                            select PART_T(
    62                                     PART_TEXT,
    63                                     DESCRIPTION,
    64                                     UNITPRICE
    65                                   )
    66                              from XMLTABLE(
    67                                     '/Part'
    68                                     passing PART
    69                                     columns
    70                                       PART_TEXT          VARCHAR2(14 CHAR)  path 'text()',
    71                                       DESCRIPTION        VARCHAR2(128 CHAR) path '@Description',
    72                                       UNITPRICE          NUMBER(14,2)       path '@UnitPrice'
    73                                   )
    74                          ),
    75                          QUANTITY
    76                        )
    77                   FROM XMLTABLE(
    78                         '/LineItems/LineItem'
    79                          passing LINEITEMS
    80                          columns
    81                            ITEMNUMBER   NUMBER(38)   path '@ItemNumber',
    82                            PART         XMLTYPE      path 'Part',
    83                            QUANTITY     NUMBER(12,4) path 'Quantity'
    84                        )
    85               ) AS LINEITEM_V
    86             )
    87           )
    88         )
    89    from PURCHASEORDER,
    90         XMLTABLE(
    91           '/PurchaseOrder'
    92           passing OBJECT_VALUE
    93           columns
    94              DATECREATED               TIMESTAMP(6)        path '@DateCreated',
    95                                                  REFERENCE                 VARCHAR2(30 CHAR)   path 'Reference',
    96                                                  ACTIONS                   XMLTYPE             path 'Actions',
    97                                                  REJECTION                 XMLTYPE             path 'Rejection',
    98                                                  REQUESTOR                 VARCHAR2(128 CHAR)  path 'Requestor',
    99                                                  USER_NAME                 VARCHAR2(10 CHAR)   path 'User',
    100                                                  COSTCENTER                VARCHAR2(4 CHAR)    path 'CostCenter',
    101                                                  SHIPPING_INSTRUCTIONS     XMLTYPE             path 'ShippingInstructions',
    102                                                  SPECIAL_INSTRUCTIONS      VARCHAR2(1000 CHAR) path 'SpecialInstructions',
    103                                                  LINEITEMS                 XMLType             path 'LineItems'
    104                     )
    105  /
    PURCHASEORDER_T(DATECREATED,REFERENCE,ACTIONS_T(CAST(MULTISET(SELECTACTION_T(USE
    PURCHASEORDER_T(NULL, 'ABULL-20100809203001136PDT', ACTIONS_T(ACTION_V(ACTION_T(
    'ACABRIO', NULL))), REJECTION_T(NULL, NULL, NULL), 'Alexis Bull', 'ABULL', 'A50'
    , SHIPPING_INSTRUCTIONS_T('Alexis Bull', '2011 Interiors Blvd,
    South San Francisco,
    California 99236
    United States of America', '950-720-3387'), 'COD', LINEITEMS_T(LINEITEM_V(LINEIT
    EM_T(1, PART_T('717951004857', 'Scary Movie', 19.95), 5), LINEITEM_T(2, PART_T('
    717951002280', 'The Faculty', 19.95), 2), LINEITEM_T(3, PART_T('24543023777', 'P
    hantom of the Paradise', 27.95), 3))))
    Elapsed: 00:00:00.11
    SQL> quitEdited by: mdrake on May 13, 2013 11:33 PM

  • Xmltype.toObject() date attribute

    Hi guys,
    I use a 11g database and I am trying to convert an xml into an object
    but I am having problems at oracle date fields
    eg:<CREATED_DATE>2012-08-18T18:15:31.8673829+01:00</CREATED_DATE> cannot be inserted into CREATED_DATE DATE,
    I tried the implicit oracle format yyyy-mm-ddThh24:mi:ss but it does not work, the only things that work is NLS_DATE_FORMAT (dd-mon-yy) .
    Is there any way to do this?
    CREATE OR REPLACE TYPE GROUP_STATEMENT_REC AS OBJECT(
    GROUP_STATEMENT_ID           NUMBER(10), 
    GROUP_ID                     VARCHAR2(5),
    CUSTOMER_ID                  NUMBER(10), 
    CREATED_DATE                 DATE,       
    REPORT_GENERATED_DATE        DATE,       
    EVENT_ID                     NUMBER(10), 
    YEAR                         VARCHAR2(4),
    MONTH                        VARCHAR2(2),
    CURRENCY_CODE                VARCHAR2(3),
    OPENING_BALANCE              NUMBER(17,2),
    CLOSING_BALANCE              NUMBER(17,2),
    CUSTOMER_COLLECTION_HOLD_IND VARCHAR2(1),
    CUSTOMER_DISPUTE_IND         VARCHAR2(1)
    ) FINAL INSTANTIABLE;
    CREATE OR REPLACE TYPE GROUP_STATEMENT_COL IS TABLE OF GROUP_STATEMENT_REC;
    create or replace type gsbox is object (container GROUP_STATEMENT_COL);
    declare
        lc_gs   GROUP_STATEMENT_COL := GROUP_STATEMENT_COL(GROUP_STATEMENT_REC(1,'40666',1000,sysdate,sysdate,11,'2004','10','EUR',123.23,32.23,'Y','N'),
                                                             GROUP_STATEMENT_REC(2,'40600',1001,sysdate-1,sysdate,12,'2004','10','EUR',123.23,32.23,'Y','N'));
        xmlgs         xmltype;
        l_box         gsbox;
        newgs         GROUP_STATEMENT_COL;
      begin
    --dbms_output.put_line(lc_gs.count);
      -- select sys_xmlgen(gsbox(lc_gs)) into xmlgs from dual;
      xmlgs := new XMLType('<?xml version="1.0" encoding="utf-8"?>
    <ROW xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <CONTAINER>
        <GROUP_STATEMENT_REC>
          <GROUP_STATEMENT_ID>0</GROUP_STATEMENT_ID>
          <GROUP_ID>30888</GROUP_ID>
          <CUSTOMER_ID>39</CUSTOMER_ID>
          <CREATED_DATE>2012-08-18T18:15:31.8673829+01:00</CREATED_DATE>
          <REPORT_GENERATED_DATE xsi:nil="true" />
          <EVENT_ID>0</EVENT_ID>
          <YEAR>2012</YEAR>
          <MONTH>7</MONTH>
          <CURRENCY_CODE>GBP</CURRENCY_CODE>
          <OPENING_BALANCE>4405.08</OPENING_BALANCE>
          <CLOSING_BALANCE>4405.08</CLOSING_BALANCE>
          <CUSTOMER_COLLECTION_HOLD_IND>N</CUSTOMER_COLLECTION_HOLD_IND>
          <CUSTOMER_DISPUTE_IND>N</CUSTOMER_DISPUTE_IND>
        </GROUP_STATEMENT_REC>
      </CONTAINER>
    </ROW>');
       --dbms_output.put_line(xmlgs.getStringVal());
       xmlgs.toObject(l_box);
       newgs := l_box.container;
       for i in 1..newgs.count loop
        dbms_output.put_line(newgs(i).GROUP_STATEMENT_ID || ' : ' || newgs(i).GROUP_ID||newgs(i).REPORT_GENERATED_DATE||newgs(i).YEAR||'<<<');
       end loop;
      end;
     

    Hi,
    I am having problems at oracle date fields
    eg:<CREATED_DATE>2012-08-18T18:15:31.8673829+01:00</CREATED_DATE> cannot be inserted into CREATED_DATE DATE,This format maps to the TIMESTAMP WITH TIME ZONE datatype in Oracle.
    Change the CREATED_DATE attribute to :
    CREATED_DATE                 TIMESTAMP WITH TIME ZONE, Then you should be able to do this :
    SQL> alter session set nls_timestamp_tz_format = 'YYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM';
    Session altered
    SQL> declare
      2 
      3    xmlgs         xmltype;
      4    l_box         gsbox;
      5    newgs         GROUP_STATEMENT_COL;
      6 
      7  begin
      8 
      9    xmlgs := new XMLType('<?xml version="1.0" encoding="utf-8"?>
    10  <ROW xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    11    <CONTAINER>
    12      <GROUP_STATEMENT_REC>
    13        <GROUP_STATEMENT_ID>0</GROUP_STATEMENT_ID>
    14        <GROUP_ID>30888</GROUP_ID>
    15        <CUSTOMER_ID>39</CUSTOMER_ID>
    16        <CREATED_DATE>2012-08-18T18:15:31.8673829+01:00</CREATED_DATE>
    17        <REPORT_GENERATED_DATE xsi:nil="true" />
    18        <EVENT_ID>0</EVENT_ID>
    19        <YEAR>2012</YEAR>
    20        <MONTH>7</MONTH>
    21        <CURRENCY_CODE>GBP</CURRENCY_CODE>
    22        <OPENING_BALANCE>4405.08</OPENING_BALANCE>
    23        <CLOSING_BALANCE>4405.08</CLOSING_BALANCE>
    24        <CUSTOMER_COLLECTION_HOLD_IND>N</CUSTOMER_COLLECTION_HOLD_IND>
    25        <CUSTOMER_DISPUTE_IND>N</CUSTOMER_DISPUTE_IND>
    26 
    27      </GROUP_STATEMENT_REC>
    28    </CONTAINER>
    29  </ROW>');
    30 
    31    xmlgs.toObject(l_box);
    32    newgs := l_box.container;
    33 
    34    for i in 1..newgs.count loop
    35      dbms_output.put_line(newgs(i).CREATED_DATE);
    36    end loop;
    37 
    38  end;
    39  /
    2012-08-18T18:15:31.867383+01:00
    PL/SQL procedure successfully completed

  • XMLType toobject return garbage when open-close tag used .

    Hi,
    one of our developer send me this test case:
    CREATE OR REPLACE
    TYPE SYNC_RESULT AS OBJECT(
        RES_ID    NUMBER(12),
        CHG_ID    NUMBER(12),
        CODE      NUMBER,
        INFO      VARCHAR2(4000),
        INFO_TECH VARCHAR2(4000),
        CONSTRUCTOR FUNCTION SYNC_RESULT RETURN SELF AS RESULT,
        CONSTRUCTOR FUNCTION SYNC_RESULT(c CLOB) RETURN SELF AS RESULT,
        CONSTRUCTOR FUNCTION SYNC_RESULT(x XMLType) RETURN SELF AS RESULT
    CREATE OR REPLACE
    TYPE BODY SYNC_RESULT IS
      CONSTRUCTOR FUNCTION SYNC_RESULT RETURN SELF AS RESULT IS
      BEGIN
          return;
      END;
      CONSTRUCTOR FUNCTION SYNC_RESULT(c CLOB) RETURN SELF AS RESULT IS
      BEGIN
          XMLType(c).toObject(SELF);
          return;
      END;
      CONSTRUCTOR FUNCTION SYNC_RESULT(x XMLType) RETURN SELF AS RESULT IS
      BEGIN
          x.toObject(SELF);
          return;
      END;
    END;
    Wrote file afiedt.buf
      1  declare
      2    s varchar2(2000);
      3    lx_xml XMLType;
      4    lo_sync_result CDI.SYNC_RESULT;
      5  begin
      6    -- Test statements here
      7    s := '<SYNC_RESULT><CODE>1</CODE><INFO>test</INFO><INFO_TECH>test</INFO_TECH></SYNC_RESULT>';
      8    lx_xml := XMLType(s);
      9    lx_xml.toobject(lo_sync_result);
    10    dbms_output.put_line( 'CODE=' || lo_sync_result.CODE);
    11    dbms_output.put_line( 'length(INFO)=' || length(lo_sync_result.INFO) );
    12    dbms_output.put_line( 'INFO=' || substr(lo_sync_result.INFO, 1, 250));
    13* end;
    SQL>
    SQL> /
    CODE=1
    length(INFO)=4
    INFO=test
    PL/SQL procedure successfully completed.
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    s varchar2(2000);
      3    lx_xml XMLType;
      4    lo_sync_result SYNC_RESULT;
      5  begin
      6    -- Test statements here
      7    s := '<SYNC_RESULT><CODE>1</CODE><INFO/><INFO_TECH>test</INFO_TECH></SYNC_RESULT>';
      8    lx_xml := XMLType(s);
      9    lx_xml.toobject(lo_sync_result);
    10    dbms_output.put_line( 'CODE=' || lo_sync_result.CODE);
    11    dbms_output.put_line( 'length(INFO)=' || length(lo_sync_result.INFO) );
    12    dbms_output.put_line( 'INFO=' || substr(lo_sync_result.INFO, 1, 250));
    13* end;
    SQL> r
      1  declare
      2    s varchar2(2000);
      3    lx_xml XMLType;
      4    lo_sync_result SYNC_RESULT;
      5  begin
      6    -- Test statements here
      7    s := '<SYNC_RESULT><CODE>1</CODE><INFO/><INFO_TECH>test</INFO_TECH></SYNC_RESULT>';
      8    lx_xml := XMLType(s);
      9    lx_xml.toobject(lo_sync_result);
    10    dbms_output.put_line( 'CODE=' || lo_sync_result.CODE);
    11    dbms_output.put_line( 'length(INFO)=' || length(lo_sync_result.INFO) );
    12    dbms_output.put_line( 'INFO=' || substr(lo_sync_result.INFO, 1, 250));
    13* end;
    CODE=1
    length(INFO)=4000
    INFO=┴☻the run with open-close tag <INFO/> (which is valid from XML point of view) makes garbage out.
    Any ideas ?
    DB 9.2.0.8 EE .
    Regards.
    Greg

    Yes, works on 10.2.0.2
    SQL> declare
      2    s varchar2(2000);
      3    lx_xml XMLType;
      4    lo_sync_result SYNC_RESULT;
      5  begin
      6    -- Test statements here
      7    s := '<SYNC_RESULT><CODE>1</CODE><INFO/><INFO_TECH>test</INFO_TECH></SYNC_RESULT>';
      8    lx_xml := XMLType(s);
      9    lx_xml.toobject(lo_sync_result);
    10    dbms_output.put_line( 'CODE=' || lo_sync_result.CODE);
    11    dbms_output.put_line( 'length(INFO)=' || length(lo_sync_result.INFO) );
    12    dbms_output.put_line( 'INFO=' || substr(lo_sync_result.INFO, 1, 250));
    13  end;
    14  /
    CODE=1
    length(INFO)=
    INFO=
    PL/SQL procedure successfully completed.
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - ProdNot on 9.2.0.4
    SQL> declare
      2    s varchar2(2000);
      3    lx_xml XMLType;
      4    lo_sync_result SYNC_RESULT;
      5  begin
      6    -- Test statements here
      7    s := '<SYNC_RESULT><CODE>1</CODE><INFO/><INFO_TECH>test</INFO_TECH></SYNC_RESULT>';
      8    lx_xml := XMLType(s);
      9    lx_xml.toobject(lo_sync_result);
    10    dbms_output.put_line( 'CODE=' || lo_sync_result.CODE);
    11    dbms_output.put_line( 'length(INFO)=' || length(lo_sync_result.INFO) );
    12    dbms_output.put_line( 'INFO=' || substr(lo_sync_result.INFO, 1, 250));
    13  end;
    14  /
    CODE=1
    length(INFO)=4000
    INFO=Á
    :ý0              
    ³¿    A   :ýX   '¿p   7%Р  7Ó°³
    Procedura PL/SQL completata correttamente.
    SQL>  select * from v$version;
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit ProductionMax
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/02/07/aggiornare-una-tabella-con-listruzione-merge/]

  • XMLType toobject return invalid number while providing the XML Schema/DTD

    We are exploring an option of converting XML into an oracle object and found toobject procedure that does the job. It works fine without XML Schema and provides XML data as oracle object. But it takes more time in parsing the XML since it uses canonical mapping. I hope by providing XML Schema we can improve the performance of this procedure. However when we use toobject with XML Schema it reports error as INVALID NUMBER irrespective of the input XML changes. Could anyone help me in this regard?

    Sorry
    The option of using toObect() to get an instance of the object that was creaed by regidsteing an XML Schema with the database, or which is associated with an XML Schema that has been registered with the database is depricated and will be removed in the next release. The main reason for this is that we reserve the right to change the structure, naming conventions or any other aspects of the object model we dervie from an XML schema, even as a result of a one-off patch, and consequently any code that was written to rely on this mapping would be broken on a regular basis.
    We do gurantee that code that uses the XML abstraction (eg XPATH/XQUERY) to access the content of the XML will work unchanged...
    In you case you have 2 options...
    1. Use the canonical mapping mechansim
    2. Write code that instantiates the objects from the outpiut of an XMLTable...
    -M

  • Error in creation of Object Type from XML passed

    Hi,
    I am facing a problem creating a appropriate a object type for a XML.
    Below are the details:
    XML Passed
    <mer_offer_action_data>
    <form_id>
    134039588
    </form_id>
    <action_cd>
    OA
    </action_cd>
    <offer_decline_reason_cd>
    </offer_decline_reason_cd>
    <start_dt>
    </start_dt>
    <candidate>
    <ds_prs_id>
    109315
    </ds_prs_id>
    <ds_prs_id>
    110534
    </ds_prs_id>
    <ds_prs_id>
    110059
    </ds_prs_id>
    </candidate>
    </mer_offer_action_data>
    Types Declaration
    +CREATE OR REPLACE type MER_OFF_CANDIDATE
    AS
    OBJECT
    DS_PRS_ID NUMBER
    CREATE OR REPLACE TYPE MER_OFF_CANDIDATE_t
    AS
    TABLE OF MER_OFF_CANDIDATE;
    CREATE OR REPLACE type MER_OFFER_ACT_DATA
    AS
    OBJECT
    FORM_ID NUMBER,
    ACTION_CD VARCHAR2(6),
    OFFER_DECLINE_REASON_CD VARCHAR2(6),
    START_DT VARCHAR2(11),
    CANDIDATE MER_OFF_CANDIDATE_t
    CREATE OR REPLACE TYPE MER_OFFER_ACT_DATA_t
    AS
    TABLE OF MER_OFFER_ACT_DATA;
    CREATE OR REPLACE type MER_OFFER_ACTION_DATA
    AS
    OBJECT
    MER_OFF_ACT_DATA MER_OFFER_ACT_DATA_t
    /+
    My Declaration
    +merOffActDataXML      xmltype;
    merOffActData     MER_OFFER_ACTION_DATA := MER_OFFER_ACTION_DATA(MER_OFFER_ACT_DATA_t());+
    Inside Pl/SQL block
    +-- Converts XML data into user defined type for further processing of data
    xmltype.toobject(merOffActDataXML,merOffActData);+
    when I run the Pl/Sql block it gives me error
    ORA-19031: XML element or attribute FORM_ID does not match any in type ORADBA.MER_OFFER_ACTION_DATA
    which means the object type mapping is wrong
    I would like to know whether the object type I had created is correct or not.
    Thanks for your help
    Beda

    Bedabrata Patel wrote:
    Below are the details:The details except for a description of the problem
    I am facing a problem creating a appropriate a object type for a XML.And which error you are getting
    Error in creation of Object Type http://download.oracle.com/docs/cd/E11882_01/server.112/e10880/toc.htm
    And which version of Oracle you are getting the unknown error creating the unknown problem.

  • Error in creation of Object Type

    Hi,
    I am facing a problem creating a appropriate a object type for a XML.
    Below are the details:
    XML Passed
    <mer_offer_action_data>
         <form_id>
              134039588
         </form_id>
         <action_cd>
              OA
         </action_cd>
         <offer_decline_reason_cd>
         </offer_decline_reason_cd>
         <start_dt>
         </start_dt>
         <candidate>
              <ds_prs_id>
                   109315
              </ds_prs_id>
              <ds_prs_id>
                   110534
              </ds_prs_id>
              <ds_prs_id>
                   110059
              </ds_prs_id>
         </candidate>
    </mer_offer_action_data>
    Types Declaration
    +CREATE OR REPLACE type MER_OFF_CANDIDATE
    AS
    OBJECT
    DS_PRS_ID NUMBER
    CREATE OR REPLACE TYPE MER_OFF_CANDIDATE_t
    AS
    TABLE OF MER_OFF_CANDIDATE;
    CREATE OR REPLACE type MER_OFFER_ACT_DATA
    AS
    OBJECT
    FORM_ID NUMBER,
    ACTION_CD VARCHAR2(6),
    OFFER_DECLINE_REASON_CD VARCHAR2(6),
    START_DT VARCHAR2(11),
    CANDIDATE MER_OFF_CANDIDATE_t
    CREATE OR REPLACE TYPE MER_OFFER_ACT_DATA_t
    AS
    TABLE OF MER_OFFER_ACT_DATA;
    CREATE OR REPLACE type MER_OFFER_ACTION_DATA
    AS
    OBJECT
    MER_OFF_ACT_DATA MER_OFFER_ACT_DATA_t
    /+
    My Declaration
         +merOffActDataXML          xmltype;
         merOffActData          MER_OFFER_ACTION_DATA := MER_OFFER_ACTION_DATA(MER_OFFER_ACT_DATA_t());+
    Inside Pl/SQL block
         +-- Converts XML data into user defined type for further processing of data
         xmltype.toobject(merOffActDataXML,merOffActData);+
    Thanks for your help
    Beda
    Edited by: Bedabrata Patel on Jul 12, 2010 5:51 AM

    Bedabrata Patel wrote:
    Below are the details:The details except for a description of the problem
    I am facing a problem creating a appropriate a object type for a XML.And which error you are getting
    Error in creation of Object Type http://download.oracle.com/docs/cd/E11882_01/server.112/e10880/toc.htm
    And which version of Oracle you are getting the unknown error creating the unknown problem.

  • ORA-30936: Maximum number of XML node elements exceeded

    I get this error on XmlType.toObject applied to a valid Xml instance (verified outside XmlDb)
    When repeating the test on various documents, the error message always refers to the first child node of the root element, even an attribute, for which maxOccurs is meaningless.
    The instance is provided via HttpUriType.getBLob and UTF-8 encoding.
    Help highly appreciated !
    Robert.

    Found a workaround: insert Xml instance into XmlType table, then toObject after select is OK !
    Probably character set encoding issue.

  • Help on how to query 11g table with XMLType column

    To all,
    We have this table:
    DESC MESSAGE
    Name Null Type
    MESSAGE_ID NOT NULL NUMBER(38)
    REQUEST_UU_ID NOT NULL VARCHAR2(50)
    MESSAGE_TYPE_CD NOT NULL CHAR(3 CHAR)
    EMPLOYEE_NUM NOT NULL VARCHAR2(8)
    SEQUENCE_NUM VARCHAR2(20)
    REVERSAL_SEQUENCE_NUM VARCHAR2(20)
    TRANSACTION_TS TIMESTAMP(6)
    MESSAGE_CONTENT_TXT NOT NULL XMLTYPE()
    CREATE_BY_NM NOT NULL VARCHAR2(50 CHAR)
    CREATE_BY_TS NOT NULL TIMESTAMP(6)
    LAST_UPDATE_BY_NM NOT NULL VARCHAR2(50 CHAR)
    LAST_UPDATE_BY_TS NOT NULL TIMESTAMP(6)
    Given we have multiple columns and one is XMLType how do I query to find rows in the db that match this XPath
    Here is a fragment of XML that is held in MESSAGE_CONTENT_TXT XMLType column:
    <?xml version="1.0" encoding="UTF-8"?>
    <cfg-env:Envelope xmlns="http://www.co.com/schemas/CFX/" xmlns:cfg-env="http://www.co.com/schemas/cfg-env/" xmlns:cfg-hdr="http://www.co.com/schemas/cfg-hdr/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.co.com/schemas/cfg-env/" >
         <cfg-env:Header>
              <cfg-hdr:MessageHeader xmlns:cfg-hdr="http://www.co.com/schemas/cfg-hdr/" xmlns:cfg-env="http://www.co.com/schemas/cfg-env/" xmlns="http://www.co.com/schemas/CFX/">
                   <cfg-hdr:Service>
                        <cfg-hdr:ServiceName>process</cfg-hdr:ServiceName>
                        <cfg-hdr:MessageType>Request</cfg-hdr:MessageType>
                        <cfg-hdr:ServiceVersion>1</cfg-hdr:ServiceVersion>
                   </cfg-hdr:Service>
                   <cfg-hdr:From>
                        <cfg-hdr:PartyId>13-175-8724</cfg-hdr:PartyId>
                        <cfg-hdr:CostCenter>2009065</cfg-hdr:CostCenter>
                        <cfg-hdr:System>
                             <cfg-hdr:Application>[email protected]</cfg-hdr:Application>
                             <cfg-hdr:Version>1.0</cfg-hdr:Version>
                             <cfg-hdr:Channel>TLR</cfg-hdr:Channel>
                        </cfg-hdr:System>
                        <cfg-hdr:OrigReplyToQMgr>QMBKRD01</cfg-hdr:OrigReplyToQMgr>
                        <cfg-hdr:OrigReplyToQ>Q1</cfg-hdr:OrigReplyToQ>
                   </cfg-hdr:From>
                   <cfg-hdr:UserSession>
                        <cfg-hdr:SignonRole>User</cfg-hdr:SignonRole>
                        <cfg-hdr:LogonId>R099999</cfg-hdr:LogonId>
    I'm trying to find rows in the database that are /Envelope/Header/MessageHeader/UserSession/LogonId/R099999.
    Thanks for the assistance. I'm new to XML DB. I appreciate the help.
    Eric

    Hi Eric,
    You can use XMLExists, like this :
    select *
    from message t
    where xmlexists(
          'declare namespace env = "http://www.co.com/schemas/cfg-env/"; (: :)
           declare namespace hdr = "http://www.co.com/schemas/cfg-hdr/"; (: :)
           /env:Envelope/env:Header/hdr:MessageHeader/hdr:UserSession[hdr:LogonId=$id]'
           passing t.message_content_txt
                 , 'R099999' as "id"
    );

  • Unable to convert BLOB to XML using XMLTYPE

    Hello (XML) Experts
    I need your help with manipulating a BLOB column containing XML data - I am encountering the following error:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00200: could not convert from encoding UTF-8 to WINDOWS-1252
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 283
    I am on Windows 7 64 bit, Oracle 11.2.0.3 64 bit and database character set is WE8MSWIN1252, NLS_LANG is set to AMERICAN_AMERICA.AL32UTF8. The BLOB column contains the following XML data:
    <?xml version="1.0" encoding="utf-8"?>
    <Root CRC="-4065505">
      <Header Converted="0">
        <Version Type="String" Value="512" />
        <Revision Type="String" Value="29" />
        <SunSystemsVersion Type="String" Value="" />
        <Date Type="String" Value="20080724" />
        <Time Type="String" Value="165953" />
        <DAG Type="String" Value="" />
        <ChkID Type="String" Value="" />
        <FormType Type="String" Value="1" />
        <DB Type="String" Value="AllBusinessUnits" />
        <FuncID Type="String" Value="SOE" />
        <Status Type="String" Value="" />
        <FileType Type="String" Value="SFL" />
        <Descriptions>
          <Default Type="String" Value="Sales Order Entry" />
          <L01 Type="String" Value="Sales Order Entry" />
          <L33 Type="String" Value="Saisie commande client" />
          <L34 Type="String" Value="Entrada de órdenes de venta" />
          <L39 Type="String" Value="Inserimento ordine di vendita" />
          <L49 Type="String" Value="Aufträge erfassen" />
          <L55 Type="String" Value="Entrada de pedido de venda" />
          <L81 Type="String" Value="å?—注オーダー入力" />
          <L86 Type="String" Value="销售订å?•å½•å…¥" />
          <L87 Type="String" Value="銷售訂單錄入" />
        </Descriptions>
      </Header>
    <FormDesignerAppVer Type="String" Value="5.1" SFLOnly="1" />
    </Root>I am using the XMLTYPE constructor and passing in the BLOB column and the character set id of the XML data stored in the BLOB column in order to extract and update a node in the XML as follows:
    select xmltype(srce_form_detail,873) from SRCE_FORM where 873 above corresponds to the utf-8 encoding of the XML data in the BLOB column i.e. AL32UTF8, but this results in the above error.
    I have also tried converting the BLOB to a CLOB first as below where BLOB2CLOB is a function that converts the BLOB to a CLOB:
    select xmltype(BLOB2CLOB(srce_form_detail)).EXTRACT('/Root/Header/DB').getStringVal() XMLSrc  from SRCE_FORM;This results in the following error:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00210: expected '<' instead of '¿'
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 272
    ORA-06512: at line 1
    Looking at the XML in the BLOB I noticed that it contains a BOM(byte order mark) and this is causing the XML parsing to fail and I don't know how to deal with it and I don't want to simply SUBSTR it out.
    What I am trying to achieve is to extract the contents of the DB node in the XML and depending on its value I need to update the 'Value' part of that node. I am stuck at the point of extracting the contents of the DB node.
    I hope I have provided enough information and I would appreciate any suggestions on how best to resolve this - my XML knowledge is very limited so I would appreciate any help.
    Regards,
    Mohinder

    Hi Marc
    Thanks for your response.
    You are correct that the blob contains Japanese and Chinese characters but I was expecting that using the XMLTYPE constructor would convert the character set albeit with some data loss or then not display the Chinese and Japanese characters correctly.
    It seems to me that XMLTYPE is not handling/interpreting the BOM contained in the BLOB since even converting the BLOB to CLOB is resulting in an error. If I use SUBSTR and ignore the BOM to extract the XML from the BLOB then it works and as expected the Chinese and Japanese characters are not displayed correctly, they are displayed as '¿' corresponding to the lines beginning with L81, L86 & L87 , see below:
    select xmltype(SUBSTR(BLOB2CLOB(srce_form_detail),4)) from SRCE_FORM
    <?xml version="1.0" encoding="utf-8"?>
    <Root CRC="-4065505">
      <Header Converted="0">
        <Version Type="String" Value="512" />
        <Revision Type="String" Value="29" />
        <SunSystemsVersion Type="String" Value="" />
        <Date Type="String" Value="20080724" />
        <Time Type="String" Value="165953" />
        <DAG Type="String" Value="" />
        <ChkID Type="String" Value="" />
        <FormType Type="String" Value="1" />
        <DB Type="String" Value="AllBusinessUnits" />
        <FuncID Type="String" Value="SOE" />
        <Status Type="String" Value="" />
        <FileType Type="String" Value="SFL" />
        <Descriptions>
          <Default Type="String" Value="Sales Order Entry" />
          <L01 Type="String" Value="Sales Order Entry" />
          <L33 Type="String" Value="Saisie commande client" />
          <L34 Type="String" Value="Entrada de ¿¿rdenes de venta" />
          <L39 Type="String" Value="Inserimento ordine di vendita" />
          <L49 Type="String" Value="Auftr¿¿ge erfassen" />
          <L55 Type="String" Value="Entrada de pedido de venda" />
          <L81 Type="String" Value="¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿" />
          <L86 Type="String" Value="¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿" />
          <L87 Type="String" Value="¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿" />
        </Descriptions>
      </Header>Can you please let me know how I can extract the binary dump of the BLOB and post it on the forum as I don't know how to do this. Below is snippet of the hexadecimal dump, that includes the BOM. I can post the full hexadecimal dump if this can help you to reproduce the error ?
    EFBBBF3C3F786D6C2076657273696F6E3D22312E302220656E636F64696E673D227574662D38223F3E0D0A3C526F6F74204352433D222D34303635353035223E0D0A20203C48656164657220436F6E7665727465643D2230223E0D0A202020203C56657273696F6E20547970653D22537472696E67222056616C75653D2235313222202F3E0D0A202020203C5265766973696F6E20547970653D22537472696E67222056616C75653D22323922202F3E0D0A202020203C53756E53797374656D7356657273696F6E20547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C4461746520547970653D22537472696E67222056616C75653D22323030383037323422202F3E0D0A202020203C54696D6520547970653D22537472696E67222056616C75653D2231363539353322202F3E0D0A202020203C44414720547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C43686B494420547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C466F726D5479706520547970653D22537472696E67222056616C75653D223122202F3E0D0A202020203C444220547970653D22537472696E67222056616C75653D22416C6C427573696E657373556E69747322202F3E0D0A202020203C46756E63494420547970653D22537472696E67222056616C75653D22534F4522202F3E0D0A202020203C53746174757320547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C46696C655479706520547970653D22537472696E67222056616C75653D2253464C22202F3E0D0A202020203C4465736372697074696F6E733E0D0A2020202020203C44656661756C7420547970653D22537472696E67222056616C75653D2253616C6573204F7264657220456E74727922202F3E0D0A2020202020203C4C303120547970653D22537472696E67222056616C75653D2253616C6573204F7264657220456E74727922202F3E0D0A2020202020203C4C333320547970653D22537472696E67222056616C75653D2253616973696520636F6D6D616E646520636C69656E7422202F3E0D0A2020202020203C4C333420547970653D22537472696E67222056616C75653D22456E747261646120646520C3B37264656E65732064652076656E746122202F3E0D0A2020202020203C4C333920547970653D22537472696E67222056616C75653D22496E736572696D656E746F206F7264696E652064692076656E6469746122202F3E0D0A2020202020203C4C343920547970653D22537472696E67222056616C75653D224175667472C3A4676520657266617373656E22202F3E0D0A2020202020203C4C353520547970653D22537472696E67222056616C75653D22456E74726164612064652070656469646F2064652076656E646122202F3E0D0A2020202020203C4C383120547970653D22537472696E67222056616C75653D22E58F97E6B3A8E382AAE383BCE38380E383BCE585A5E58A9B22202F3E0D0A2020202020203C4C383620547970653D22537472696E67222056616C75653D22E99480E594AEE8AEA2E58D95E5BD95E585A522202F3E0D0A2020202020203C4C383720547970653D22537472696E67222056616C75653D22E98AB7E594AEE8A882E596AEE98C84E585A522202F3E0D0A202020203C2F4465736372697074696F6E733E0D0A20203C2F4865616465723E0D0A20203C466F726D3E0D0A202020203C4372656174696F6E4C616E6720547970653D22537472696E67222056616C75653D223031222053464C4F6E6C793D223122202F3E0D0A202020203C416374696F6E733E0D0A2020202020203C5065726D697373696F6E73202F3E0D0A202020203C2F416374696F6E733E0D0A202020203C48656C70202F3E0D0A202020203C466F6E743E0D0A2020202020203C446566466F6E7453697A6520547970653D22496E7465676572222056616C75653D2238222053464C4F6E6C793D223122202F3E0D0A2020202020203C466F6E743E0D0A20202020202020203C4C616E677561676520547970653D22537472696E67222056616C75653D2244656661756C7422202F3E0D0A20202020202020203C466F6E744E616D6520547970653D22537472696E67222056616C75653D224D532053616E7320536572696622202F3E0D0A2020202020203C2F466F6E743E0D0A2020202020203C466F6E743E0D0A20202020202020203C4C616E677561676520547970653D22537472696E67222056616C75653D22383122202F3E0D0A20202020202020203C466F6E744E616D6520547970653D22537472696E67222056616C75653D224D5320554920476F7468696322202F3E0D0A2020202020203C2F466F6E743E0D0A202020203C2F466F6E743E0D0A202020203C436F6E74726F6C733E0D0A2020202020203C436F6E74726F6C3E0D0A20202020202020203C436F6E74726F6C5479706520547970653D22496E746567657222204644496E743D2231222056616C75653D223122202F3E0D0A20202020202020203C446973706C61795479706520547970653D22537472696E6722204644496E743D2230222056616C75653D22466F726D2057696E646F77222053464C4F6E6C793D223122202F3E0D0A20202020202020203C43617074696F6E20547970653D22537472696E6722204644496E743D2230222056616C75653D2253597C3F7C55547C3F7C3F3F3F3F3F3F22202F3E0DThe XML I posted so far is actually truncated as the full XML is quite big but I showed the beginning of it as this is the section I believe that is not being handled properly. Furthermore I am able to write the BLOB out to a file successfully without any errors using DBMS_LOB & UTL_FILE.PUT_RAW and this seems to handle the BOM without any issues but what I really need to do is read a single node in the XML and update it directly preferably using XMLTYPE directly with the BLOB.
    I would welcome your suggestions on how best to read a single node and update it when the XML is contained in a BLOB.
    Regards,
    Mohinder

  • Move XMLTYPE data to a remote  database

    Hello,
    I need your experience !!!!!
    I am working with the 10.2.1 database.
    I have try to call a remote procedure (using DBLINK) with a XMLTYPE parameter, I get a error link to a lob locator.
    One solution could be to save XMLTYPE to disk.
    Some body know other solution to transfer XMLTYPE data to a remote database.
    Thanks in advance
    Best Regards

    A future alternative will be Oracle streams and b.t.w. one of the advantages (sometimes not, but anyway) of an Oracle database is that you can use object orientated methods, relational methods, java solutions, etc. and nowadays XML methods. XML was once all about transporting data, creating an uniform interface between solutions (databases, application/webservers, technology stacks, etc...). Think out of the Box. XMLDB isn't relational, but it is packaged in one. Make use of it and vice versa.

Maybe you are looking for