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.

Similar Messages

  • 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

  • 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;
    /

  • 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

  • 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/]

  • My iphone 5in use for about 35 seconds,becomes  very hot.Why?

    My  IPHONE 5,when  in  use,for insytance, in facebook,for about 35 seconds it  heats and becomes very,very hot.... why ? It's not because of the light,çause  my son's iphone 4 daes'nt happen this....

    User Tip:  How to deal with MacBook Pro and MacBook heat? 

  • Query about XMLTYPE column structured storage in Oracle Xml db

    Dear All,
    DB Version: Oracle 11g (11.2.0.3.0)
    I have an table having one column as XMLTYPE with Structured storage.
    CREATE TABLE Orders
        Order_id NUMBER NOT NULL,
        Order_etc VARCHAR2(100),
        Order_desc XMLType NOT NULL
        XMLTYPE Order_desc STORE AS OBJECT RELATIONAL XMLSCHEMA  "http://localhost/public/xsd/order_desc_xsd.xsd" ELEMENT "OrderState";
    I have then registered the XSD with XML Db schema which is required for Structured storage.
    Before this table creation I had created a table (db_objects) of XMLTYPE and was able to use the below query to check for what all objects the XMLTYPE table got broken into when I registered its XSD.
        SELECT column_name,     
               data_type
        FROM   user_tab_cols
        WHERE  table_name = 'DB_OBJECTS';
    And used below query to look for data stored in Object-Relational structure for my table (DB_OBJECTS) created with XMLTYPE definition.
      SELECT EXTRACTVALUE(xseq.column_value, '/THISROW/OWNER')       AS owner
        ,      EXTRACTVALUE(xseq.column_value, '/THISROW/OBJECT_NAME') AS object_name
        ,      EXTRACTVALUE(xseq.column_value, '/THISROW/OBJECT_TYPE') AS object_type
        ,      EXTRACTVALUE(xseq.column_value, '/THISROW/OBJECT_ID')   AS object_id
        ,      EXTRACTVALUE(xseq.column_value, '/THISROW/CREATED')     AS created
        FROM   db_objects do
         ,      TABLE(XMLSEQUENCE(EXTRACT(VALUE(do), '/ROWSET/THISROW'))) xseq 
        WHERE  ROWNUM <= 10;
    Now could someone let me know, how to find how the column (Order_desc) of XMLTYPE was broken down into further objects just like I did for the Table with XMLTYPE (as shown above)?
    Many Thanks.

    First given that you are on 11.2, ExtractValue is deprecated and the documentation lists three options to use instead.  Here is one option (untested)
    SELECT owner, object_name, object_type, object_id, created
      FROM db_objects do,
           XMLTable('/ROWSET/THISROW'
                    PASSING do.object_value
                    COLUMNS
                    -- Set data types accordingly
                    owner        VARCHAR2(20) PATH 'owner',
                    object_name  VARCHAR2(20) PATH 'object_name',
                    object_type  VARCHAR2(20) PATH 'object_type',
                    object_id    VARCHAR2(20) PATH 'object_id',
                    created      VARCHAR2(20) PATH 'created');
    Second, why does column order matter?  You are storing in an object relational method.  As long as the XML is valid per the schema, the Oracle will be able to store the data and later retrieve it as well.  How that data is stored is mostly Oracle internals and should not be touched as it can be changed from version to version.  You can use schema annotation to control how Oracle maps and stores the XML, but nothing in there specifies column order that I am aware of.
    It seems additional details are missing as to what you need the information for so that would help others answer your question.

  • Rumours about a new ipod!

    i didnt know where to post this sio i'll give it a shot here.
    Has anyone else heard rumours of a new ipod in development to be released around easter time? I herad this today but i'm not sure if they're talking ** lol Please help as i would wait for this development before purchasing an ipod . Many thanks

    but i was just wondering because if a new product is coming out in the near future i would like to see it before making a purchase
    If you want something, buy it.
    If you are gonna wait for the "new, improved" anything, you are gonna wait forever, as most products (especially electronics/computers) are ussualy in some sort of development/improvement all the time.
    Companies (including Apple) don't want you to wait and buy something in six months.

  • What are the rumours about the warranty to my iPhone 4S if I replace the back plate to my phone?

    Can anyone help?

    No rumors neccessary.
    If you take it apart, the warrnaty is voided.
    If you replace the back plate, the warrnaty is voided.

  • Who do I ask about PS elements 8 becoming compatible with windows 8???

    do I have any hope at all??  I downloaded it again from here, as I lost the disc at somepoint in time, I removed it from old near dead computer and cant load it to new one...   I read it was only windows 7 or lower... but I tried anyway..  and have no idea what Im doing so even if it works I dont think I know how to make it work as it came out in zillions of files..  What can I do, or who can I ask about windows 8 becoming available????? 

    There will not be any changes made to older Adobe programs to make them compatible with newer operating systems if that is what you are wondering.  Creating new versions of software is where most any company focuses their attention.

  • There seems to be a lot of rumours at the moment that iPhone batteries are swelling and damaging phones because of being overcharged, is there any truth to this rumour?

    My granddaughter has informed me (after having her iPhone 4 repaired, for a broken screen) that she was told by the repairer that charging a phone overnight every night will not only overcharge the battery (and reduce the life off the battery), but also can result in the battery swelling and breaking the screen and/or the back glass of the phone.
    I have googled this question and observed that there are 50/50 remarks within a variety of blogs about this, (it seems there are a lot of rumours about overcharging) obviously there are some really silly responses to the "overcharging" theory, and some that do seem to almost come with some authority. Some say charging every night will definitely damage the battery, some say it will definitely not damage the battery.
    I personally don't believe these rumours to be true, but thought it best to ask the experts, hence this question.
    Please let me know if there is any truth to this rumour, so that I can reassure not only myself, but also my children and grandchildren, who are now scared of charging their phones.

    dougwatkins wrote:
    My granddaughter has informed me (after having her iPhone 4 repaired, for a broken screen) that she was told by the repairer that charging a phone overnight every night will not only overcharge the battery (and reduce the life off the battery), but also can result in the battery swelling and breaking the screen and/or the back glass of the phone.
    What is true is that the vast majority of swelling/exploding/flaming batteries in iPhones that have been documented can be traced directly to botched repairs by unauthorized servicers or to counterfeit batteries sold on ebay and elsewhere.
    Though any rechargable battery can fail, it is extremely unlikely in an unmodified, undamaged iPhone.  If your granddaughter had her phone repaired by anyone other than Apple, she is at more risk now of experiencing a catastrophic failure of the phone than she ever was.  She no longer has an iPhone. Apple will not service her phone at all if it was opened by a 3rd party.

Maybe you are looking for

  • Macbook Air resolution question - text not crisp

    I have the 13" Macbook Air (mid-2011 model). I found the text to generally be too small on the default resolution so I changed it from 1440x900 to 1280x800. Everything is bigger but the text actually looks slightly blurry and not nearly as crisp or s

  • How to create an Aux object on Arranger?

    I've got an audiotrack open on the left, which's output is routed to Bus 8. Right next to it (and this is what I really do like in the OSX Logic ) is the channel-strip of BUS8. However, being in the arranger window, I can't help but wonder - how woul

  • UTL_TCP - connection loss

    Hi guys, I would need a help with UTL_TCP package... Oracle version is: SELECT * FROM V$VERSION; Oracle Database 11g Release 11.2.0.2.0 - 64bit Production PL/SQL Release 11.2.0.2.0 - Production "CORE    11.2.0.2.0    Production" TNS for Linux: Versio

  • HT201359 How to switch the apps store

    How to switch from u.s store to malaysian store

  • Internatinoal Coverage

    I got this phone to use while outside of the US.  I have the right service and see that I get a signal but I'm not able to call, receive calls, text etc.  What am I missing?  Verizon Support is no help..