Using DBMS_XMLSCHEMA.registerSchema

Hi:
use DBMS_XMLSCHEMA.registerSchema procedure to register the XML Schema of invoiceformtest.xsd
But I got error
What I tried is
DBMS_XMLSCHEMA.registerSchema(
SCHEMAURL => 'http://localhost.mylocalhost.com:8080/xdb/invoiceformtest.xsd',
SCHEMADOC => bfilename('XMLDIR','invoiceformtest.xsd'),
CSID => nls_charset_id('AL32UTF8'));
END;
where is my error?
Please help
sem

1) What was the error you got?
2) What version of Oracle (4 digits)
3) Your question belongs in the {forum:id=34} forum, so search that forum for your error and if you don't find the answer, repost your question there with the additional details.

Similar Messages

  • Dbms_xmlschema.registerschema, (ORA-31084: error while creating table )..

    Hello,
    I have some problems with dbms_xmlschema.registerschema
    My database is: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    My XSD schema is (SEPA pain.002.001.03.xsd) also available on this url: http://code.google.com/p/leontestbed/source/browse/trunk/bc2/sample/Schema/pain.002.001.03.xsd?r=241
    After
    begin
       DOK_XML_UTIL.p_vnesi_xsd_blob(401941242); -- store a XSD on file system from blob field
       dbms_xmlschema.registerschema(
        schemaurl => 'http://localhost/TEST1.XSD',
        schemadoc => bfilename('ETAX_LOAD','TEST1.XSD'),
        csid => nls_charset_id('AL32UTF8'));
    commit;
    end;I get:
    ORA-31084: error while creating table "INIS_PROD"."Document2781_TAB" for element "Document"
    ORA-02320: failure in creating storage table for nested table column "XMLDATA"."CstmrPmtStsRpt"."OrgnlPmtInfAndSts"
    ORA-01792: maximum number of columns in a table or view is 1000
    ORA-02310: exceeded maximum number of allowable columns in table
    ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 37
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 65
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 136
    ORA-06512: at line 4
    What I'am doing wrong or what is the reason for this error..

    Arrgghhh.....
    begin
       DOK_XML_UTIL.p_vnesi_xsd_blob(401941242);
       dbms_xmlschema.registerschema(
        schemaurl => 'http://localhost/TEST1.XSD',
        schemadoc => bfilename('ETAX_LOAD','TEST1.XSD'),
        csid => nls_charset_id('AL32UTF8')
        , local => true
      , genTypes => false
      , genTables => false);
    commit;
    end;sorry...

  • Register XML schema using dbms_xmlschema in Oracle 11g

    I have a xsd file located at C:\temp\test.xsd
    I need to register this schema to create a XMLType table for Object Relational XML Storage.
    How do I register the schema for relational storage?
    I do not seem to find any example on internet for registering the schema for relational storage.
    Any help would be highly appreciated.

    Thanks for help. The table is created now. But it created a CLOB table whereas I want a relational table with rows and columns. Is it because the schema was registered with SCHEMADOC as bfilename? How do I get the relational storage?
    BEGIN
       DBMS_XMLSCHEMA.registerSchema(
        SCHEMAURL=> 'TESTDEPT.XSD',
        SCHEMADOC=> bfilename('XML_DIR','TESTDEPT.XSD'),
        LOCAL=> TRUE,
        GENTYPES=> TRUE,
        GENTABLES=> FALSE,
        CSID=> nls_charset_id('AL32UTF8'));
    END;
    CREATE TABLE TESTDEPT OF XMLType
      XMLTYPE store AS OBJECT RELATIONAL
      XMLSCHEMA "TESTDEPT.XSD" ELEMENT "root";
    desc TESTDEPT;
      Name                           Null     Type                                                                                                                                                                                         
    SYS_NC_ROWINFO$                         XMLTYPE()        
    SELECT dbms_metadata.get_ddl('TABLE','TESTDEPT') from dual;
      DBMS_METADATA.GET_DDL('TABLE','TESTDEPT')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(CLOB)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
      CREATE TABLE "DMUSER"."TESTDEPT" OF XMLTYPE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
      XMLSCHEMA "TESTDEPT.XSD" ELEMENT "root" ID 4090 PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
      TABLESPACE "USERS" 
    My database version:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production    
    PL/SQL Release 11.2.0.1.0 - Production                                          
    CORE 11.2.0.1.0 Production                                                        
    TNS for 64-bit Windows: Version 11.2.0.1.0 - Production                         
    NLSRTL Version 11.2.0.1.0 - Production

  • DBMS_XMLSCHEMA.REGISTERSCHEMA' must be declared

    Hi,
    I'm new to Oracle XMLDB. I tried to register a schema but got this error:
    DBMS_XMLSCHEMA.REGISTERSCHEMA' must be declared
    I installed 9.2.0.4.0 patch just last week.
    Please advise. Thank you!

    $ sqlplus scott/tiger
    SQL*Plus: Release 9.2.0.6.0 - Production on Tue Sep 12 07:52:13 2006
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.6.0 - Production
    SQL> select 1 from all_users where username = 'XDB';
             1
             1
    SQL> select 1 from all_users where username = 'FOO';
    no rows selected
    SQL>The script is on the server and has to run by someone with DBA privilige

  • Dbms_xmlschema.registerschema

    I can run dbms_xmlschema.registerschema fine as a standalone pl/sql block but as soon as I create a procedure to wrap around this procedure in a package,
    I am getting following erross.
    SQL> @test_regschema
    Calling dbms_xmlschema.registerschema('http://sbcld.sbc.com/tea/tldapi.xsd',)
    error at 510ORA-01031: insufficient privileges
    Any ideas.

    PRivlidges granted by roles are not granted in procedures. You'll need to grant all the privlidges associated with connect and resoure

  • Registerschema gives ORA-01792: maximum number of columns...

    Hi,
    DB: Oracle9i Enterprise Edition Release 9.2.0.6.0
    Opp Sys: HP-UX
    I've just increased the size of an XSD we have loaded in a customers database and attempting to reload using dbms_xmlschema.registerschema gives the following error:
    ORA-31084: error while creating table "SOLO"."LetterRoot5799_TAB" for element "LetterRoot"
    ORA-01792: maximum number of columns in a table or view is 1000
    ORA-02310: exceeded maximum number of allowable columns in table
    ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 0
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 26
    ORA-06512: at "SOLO.WORK_TEST_LETTERS_XSD", line 23
    ORA-06512: at line 2
    Is there a work around for this?
    Thanks,
    Mike Moore

    Hi! I faced the same problem as author of a thread. At first it was just the same and I used solution that was offered - add attribute xdb:SQLInline="false".
    But now this error (ORA-01792: maximum number of columns in a table or view is 1000) became to rise on element that doesn't have a lot of attributes or subelements that coul exceed limit of 1000! Moreover it is based on complex type that already exists! It was created during another schema registration, which is included in schema that I'm trying to register now!
    Does anyone challenged this problem?
    I use Oracle9i Enterprise Edition Release 9.2.0.5.0

  • SQL*Loader problem - not efficient, parsing error for big xml files

    Hi Experts,
    First of all, I would like to store xml files in object relation way. Therefore I created a schema and a table for it (see above).
    I wants to propagate it (by using generated xml files), hence I created a control file for sql loader (see above).
    I have two problems for it.
    1, It takes a lot of time. It means I can upload a ~80MB file in 2 hours and a half.
    2, At bigger files, I got the following error messages (OCI-31011: XML parsing failed OCI-19202: Error occurred in XML processing LPX-00243: element attribute value must be enclosed in quotes). It is quite interesting because my xml file is generated and I could generated and uploaded the first and second half of the file.
    Can you help me to solve these problems?
    Thanks,
    Adam
    Control file
    UNRECOVERABLE
    LOAD DATA
    CHARACTERSET UTF8
    INFILE *
    APPEND
    INTO TABLE coll_xml_objrel
    XMLTYPE(xml)
    FIELDS
    ident constant 2
    ,file_name filler char(100)
    ,xml LOBFILE (file_name) TERMINATED BY EOF
    BEGINDATA
    generated1000x10000.xml
    Sql Loader command
    sqlldr.exe username/password@//localhost:1521/SID control='loader.ctl' log='loadr.log' direct=true
    Schema
    <?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://www.something.com/shema/simple_searches" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.something.com/shema/simple_searches">
        <element name="searches" type="tns:searches_type"></element>
        <element name="search" type="tns:search_type"></element>
        <element name="results" type="tns:results_type"></element>
        <element name="result" type="tns:result_type"></element>
        <complexType name="searches_type">
            <sequence>
                <element ref="tns:search" maxOccurs="unbounded"></element>
            </sequence>
        </complexType>
        <complexType name="search_type">
            <sequence>
                <element ref="tns:results"></element>
            </sequence>
            <attribute ref="tns:id" use="required"></attribute>
            <attribute ref="tns:type" use="required"></attribute>
        </complexType>
        <complexType name="results_type">
            <sequence maxOccurs="unbounded">
                <element ref="tns:result"></element>
            </sequence>
        </complexType>
        <complexType name="result_type">
            <attribute ref="tns:id" use="required"></attribute>
        </complexType>
        <simpleType name="type_type">
            <restriction base="string">
                <enumeration value="value1"></enumeration>
                <enumeration value="value2"></enumeration>
            </restriction>
        </simpleType>
        <attribute name="type" type="tns:type_type"></attribute>
        <attribute name="id" type="string"></attribute>
    </schema>
    Create table
    create table coll_xml_objrel
    ident Number(20) primary key,
    xml xmltype)
    Xmltype column xml
    store as object relational
    xmlschema "http://www.something.com/schema/simple_searches.xsd"
    Element "searches";

    Hi Odie_63,
    Thanks for your answer.
    I will post this question in the XML DB forum too (edit: I realized that you have done it. Thanks for it).
    1, Version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    2, see above
    3, I have registered my schema with using dbms_xmlschema.registerSchema function.
    Cheers,
    Adam
    XML generator:
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import javax.xml.stream.XMLOutputFactory;
    import javax.xml.stream.XMLStreamException;
    import javax.xml.stream.XMLStreamWriter;
    public class mainGenerator {
        public static void main(String[] args) throws FileNotFoundException, XMLStreamException {
            // TODO Auto-generated method stub
            final long numberOfSearches = 500;
            final long numberOfResults = 10000;
            XMLOutputFactory xof = XMLOutputFactory.newFactory();
            XMLStreamWriter writer = xof.createXMLStreamWriter(new FileOutputStream("C:\\Working\\generated500x10000.xml"));
            writer.writeStartDocument();
            writer.writeStartElement("tns","searches", "http://www.something.com/schema/simple_searches");
            writer.writeNamespace("tns", "http://www.something.com/schema/simple_searches");
            for (long i = 0; i < numberOfSearches; i++){
                Long help = new Long(i);
                writer.writeStartElement("tns","search", "http://www.something.com/schema/simple_searches);
                writer.writeAttribute("tns", "http://www.something.com/schema/simple_searches", "type", "value1");
                writer.writeAttribute("tns", "http://www.something.com/schema/simple_searches", "id", help.toString());
                writer.writeStartElement("tns","results", "http://www.something.com/schema/simple_searches");
                for (long j = 0; j < numberOfResults; j++){
                    writer.writeStartElement("tns","result", "http://www.something.com/schema/simple_searches");
                    Long helper = new Long(i*numberOfResults+j);
                    writer.writeAttribute("tns", "http://www.something.com/schema/simple_searches", "id", helper.toString());
                    writer.writeEndElement();
                writer.writeEndElement();
                writer.writeEndElement();
            writer.writeEndElement();
            writer.writeEndDocument();
            writer.close();
    registerSchema:
    begin
    dbms_xmlschema.registerSchema(
    'http://www.something.com/schema/simple_searches',
    '<?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://www.something.com/schema/simple_searches" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.something.com/schema/simple_searches">
        <element name="searches" type="tns:searches_type"></element>
        <element name="search" type="tns:search_type"></element>
        <element name="results" type="tns:results_type"></element>
        <element name="result" type="tns:result_type"></element>
        <complexType name="searches_type">
            <sequence>
                <element ref="tns:search" maxOccurs="unbounded"></element>
            </sequence>
        </complexType>
        <complexType name="search_type">
            <sequence>
                <element ref="tns:results"></element>
            </sequence>
            <attribute ref="tns:id" use="required"></attribute>
            <attribute ref="tns:type" use="required"></attribute>
        </complexType>
        <complexType name="results_type">
            <sequence maxOccurs="unbounded">
                <element ref="tns:result"></element>
            </sequence>
        </complexType>
        <complexType name="result_type">
            <attribute ref="tns:id" use="required"></attribute>
        </complexType>
        <simpleType name="type_type">
            <restriction base="string">
                <enumeration value="value1"></enumeration>
                <enumeration value="value2"></enumeration>
            </restriction>
        </simpleType>
        <attribute name="type" type="tns:type_type"></attribute>
        <attribute name="id" type="string"></attribute>
    </schema>',
    TRUE, TRUE, FALSE, FALSE);
    end

  • Problem in including a defined schema

    Hi :
    I am trying to register a schema using dbms_xmlschema.registerSchema().
    I have registered one schema already and now I am trying to register another schema which has an "include" statement to refer the already registered schema. I do this by having the line below in the schema which I am trying to register :
    <xs:include schemaLocation="feature.xsd"/>
    I get an error as follows :
    ERROR at line 1:
    ORA-31000: Resource 'feature.xsd' is not an XDB schema document
    ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 0
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 26
    ORA-06512: at line 2
    Please let me know if this is valid. I queried the xdb.RESOURCE_VIEW and did find the feature.xsd registered as follows :
    /sys/schemas/SPTREMBL/accelrys.com/feature.xsd
    Thanks for your help.
    Sudhakar

    I think I found the problem. Thanks
    Sudhakar

  • Schema won't register - same URL as non-existent schema

    Hi,
    Schema registration using DBMS_XMLSCHEMA.registerSchema(...) fails with 'An attempt was made to register a schema with the same URL as a previously registered schema'. However, when I try and delete using DBMS_XMLSCHEMA.deleteSchema(...) I get 'ORA-31000 Resource http://www.sepa.org.uk/RBMP/RBMP_datasheet.xsd is not an XDB schema document'. I also can't see the document in the ALL_XML_SCHEMAS view.
    Only reference to a solution for this problem that I can find refers to using DBMS_XMLSCHEMA.PURGESCHEMA but I'm on 10g and this appears to be new in 11g.
    Any ideas how I can get out of this one?
    Chris
    Edited by: chrisis on Nov 24, 2008 11:22 AM

    Thanks Marco, I'll try and get our DBA to purge the recycle bin and try again. Though I can't see anything there that looks like it relates to my schema.
    The database version is 10.2.0.1.0. and I did the delete like this
         DBMS_XMLSCHEMA.deleteSchema(
         SCHEMAURL => 'http://www.sepa.org.uk/RBMP/RBMP_datasheet.xsd',
         DELETE_OPTION => dbms_xmlschema.DELETE_CASCADE_FORCE
    It seemed to work as the underlying objects were dropped and the url isn't visible in ALL_XML_SCHEMAS. AFAIK I'm the only one currently working with XMLDB on this instance and I'm almost certain that I only had the one session open at the time.
    Chris

  • Maximum length for an XML schema

    Hi everybody,
    Is there a limit on the maximum length for an XML schema? I am trying to register an XML schema using dbms_xmlschema.registerSchema(). The schema registration process seems to go fine when the length of the schema is short. But the registration process always hangs when I increase the XML schema with additional types/elements. Is there a limit on the maximum length of the XML schema with regards to registering it to Oracle?
    Thanks!
    IK

    Hi Erhan,
    Let's say I have a really big XML schema in file "schemaA.xsd", like so:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sampleA="http://abc.com/schemaA" targetNamespace="http://abc.com/schemaA">
    <xsd:element name="Employee">
    <xsd:sequence>
    <xsd:element name="Address" type="sampleA:AddressType"/>
    <xsd:element name="Contact" type="sampleA:ContactInfoType"/>
    </xsd:element>
    <xsd:complexType name="AddressType">......</xsd:complexType>
    <xsd:complexType name="ContactInfoType">....</xsd:complexType>
    </xsd:schema>
    I can separate this schema into multiple smaller schemas (<32KB) by using the proper imports:
    In file "sampleA.xsd":
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sampleB="http://abc.com/schemaB"
    xmlns:sampleA="http://abc.com/schemaA" targetNamespace="http://abc.com/schemaA">
    <xsd:import namespace="http://abc.com/schemaB" schemaLocation="schemaB.xsd"/>
    <xsd:element name="Employee">
    <xsd:sequence>
    <xsd:element name="Address" type="sampleB:AddressType"/>
    <xsd:element name="Contact" type="sampleB:ContactInfoType"/>
    </xsd:element>
    </xsd:schema>
    And in file "sampleB.xsd", I might have something like this:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sampleB="http://abc.com/schemaB" targetNamespace="http://abc.com/schemaB">
    <xsd:complexType name="AddressType">......</xsd:complexType>
    <xsd:complexType name="ContactInfoType">....</xsd:complexType>
    </xsd:schema>
    So, you see how I have separated that one really big XML schema in file "schemaA.xsd" into two XML schema files: "schemaA.xsd" and "schemaB.xsd". Also, I have added <import> tags in schemaA.xsd to refer to elements, complext types, etc. defined in schemaB.xsd. So long as these schema files are < 32KB, I can register them (using dbms_xmlschema.registerSchema()) without any problems into Oracle.
    Let me know if what I said above is not too clear. Hope you find your solution soon!
    Thanks!
    Irene

  • Validating against an XSD

    I'm trying to validate an imported XML file (in a clob) against an XSD. It is slightly complicated in that the XSD import another. I have tried to register both, using dbms_xmlschema.registerSchema, but the second one gets:
    ORA-01031: insufficient privileges
    ORA-06512: at "XDB.DBMS_XDBZ0", line 275
    ORA-06512: at "XDB.DBMS_XDBZ", line 7
    ORA-06512: at line 1
    ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 37
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 61
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 126
    ORA-06512: at line 25
    I've not found much information on this topic. Any ideas?
    I have a supplemental question. This file is being parsed using XMLDOM. Is there a way to extract an element and its contents as a piece of XML text that I can include in an error log?
    Thanks
    Steve

    Now I remember why we switched to using XMLTYPE when extracting information from the XML in PL/SQL.
    declare
      l_main_doc    dbms_xmldom.DOMDocument;
      l_main_xml    XMLTYPE;
      l_output      VARCHAR2(500);
      l_clob        CLOB := 'a';
      l_sample      VARCHAR2(500);
      l_nodelist dbms_xmldom.domnodelist;
    begin
      l_sample := '<Block>
    <Item><Record>1</Record><Value>123</Value></Item>
    <Item><Record>2</Record><Value>999</Value></Item>
    </Block>';
      -- DOMDoc way
      l_main_doc := dbms_xmldom.newDOMDocument(l_sample);
      l_nodelist := dbms_xslprocessor.selectnodes(dbms_xmldom.makenode(l_main_doc),
                                                  '/Block/Item[Record="2"]');
      dbms_xmldom.writeToClob(dbms_xmldom.item(l_nodelist,0),l_clob);
      dbms_output.put_line('#1');
      dbms_output.put_line(l_clob);
      dbms_xmldom.freeDocument(l_main_doc);
      -- XMLType way
      l_main_xml := XMLTYPE(l_sample);
      l_output := l_main_xml.extract('/Block/Item[Record="2"]').getStringVal();
      dbms_output.put_line('#2');
      dbms_output.put_line(l_output);
    end;outputs
    #1
    <Item>
      <Record>2</Record>
      <Value>999</Value>
    </Item>
    #2
    <Item>
      <Record>2</Record>
      <Value>999</Value>
    </Item>

  • Problem in use xmlgen.insertXML to insert XML file to Object Viewse

    I am trying to update XML file to Object View but it failed. Refer to the steps that I was doing.
    1) Use utl_file.get_line to read XML file which I generated (It is no problem)
    2)The xml data is
    <?xml version="1.0" ?>
    - <ROWSET>
    - <ROW num="1">
    <PK_NO>305</PK_NO>
    <ACC_NAME>PAPERS AND CLIPS</ACC_NAME>
    <FROM_NAME>MB METAL PTE LTD</FROM_NAME>
    <MAS_NO>990015</MAS_NO>
    <MAS_DATE>2000-04-07 15:47:52.0</MAS_DATE>
    <CURR_CODE>SGD</CURR_CODE>
    <MAS_CODE>WRFQ</MAS_CODE>
    <REMARK>SADKJAS</REMARK>
    - <LINEITEMLIST_NTAB>
    - <LINEITEMLIST_NTAB_ITEM>
    <ITEM_NO>1</ITEM_NO>
    <STK_C>2506401</STK_C>
    <SP_STK_C>H282828</SP_STK_C>
    <STK_NAME>STICK-ON-NOTES - 11110 1.5, 12 100 SHEET PADS</STK_NAME>
    <UOM>SET</UOM>
    <QTY>10</QTY>
    <SALES_PRICE>95.50</SALES_PRICE>
    <REMARK>SADKJAS</REMARK>
    </LINEITEMLIST_NTAB_ITEM>
    - <LINEITEMLIST_NTAB_ITEM>
    <ITEM_NO>2</ITEM_NO>
    <STK_C>7706001</STK_C>
    <SP_STK_C>H282828</SP_STK_C>
    <STK_NAME>FACESHIELD/EYE PROT CLEAR GLASS WTR PLATE, STANDARD DREW</STK_NAME>
    <UOM>PCS</UOM>
    <QTY>1</QTY>
    <SALES_PRICE>100</SALES_PRICE>
    <REMARK>SADKJAS</REMARK>
    </LINEITEMLIST_NTAB_ITEM>
    </LINEITEMLIST_NTAB>
    </ROW>
    </ROWSET>
    3) From Object View, I generated xml file is
    - <ROWSET>
    - <ROW num="1">
    <PK_NO>2</PK_NO>
    <ACC_NAME>PAPERS AND CLIPS</ACC_NAME>
    <FROM_NAME>MB METAL PTE LTD</FROM_NAME>
    <MAS_NO>990015</MAS_NO>
    <MAS_DATE>2000-06-07 00:00:00.0</MAS_DATE>
    <CURR_CODE>SGD</CURR_CODE>
    <MAS_CODE>WRFQ</MAS_CODE>
    - <LINEITEMLIST_NTAB>
    - <LINEITEMLIST_NTAB_ITEM>
    <ITEM_NO>1</ITEM_NO>
    <STK_C>2506401</STK_C>
    <STK_NAME>STICK-ON-NOTES - 11110 1.5,X2 12 100 SHEET PADS</STK_NAME>
    <UOM>SET</UOM>
    <QTY>1</QTY>
    <SALES_PRICE>10</SALES_PRICE>
    </LINEITEMLIST_NTAB_ITEM>
    </LINEITEMLIST_NTAB>
    </ROW>
    - <ROW num="2">
    <PK_NO>4</PK_NO>
    <ACC_NAME>ABC</ACC_NAME>
    <FROM_NAME>VBF</FROM_NAME>
    <MAS_NO>99200</MAS_NO>
    <MAS_DATE>2000-01-04 00:00:00.0</MAS_DATE>
    <CURR_CODE>SGD</CURR_CODE>
    <MAS_CODE>DSDS</MAS_CODE>
    <REMARK>WRFQ</REMARK>
    <LINEITEMLIST_NTAB />
    </ROW>
    </ROWSET>
    3) I use INSTEAD OF trigger for Object View to insert the data to database.
    I got the message is:
    ORA-29532: Java call terminated by uncaught Java exception: oracle.xml.sql.OracleXMLSQLException:5.
    Anybody can give me the advise for that.
    null

    If you have the ftp server at 8080 running (9iR2 only) the simples way is to upload it to the database through that server. You can then do whatever you want using the xdburitype() procedure.
    Below is an excerpt of a script I use to register XML schema's (I've got some very long ones, about 150K). It should work with "any" file..
    begin
         dbms_xmlschema.registerSchema (
              schemaURL => 'http://www.agralin.nl/WebQuery/ns/&1',
              schemaDoc => xdburitype('/age/&1..xsd'),
              local => TRUE,
              genTables => FALSE,
              genbean => FALSE,
              genTypes => TRUE,
              force => FALSE,
              owner => 'AGE'
    end;

  • Error while trying to use BFILENAME during schema registration

    Hi,
    I'm having difficulty in understanding the BFILENAME function while trying to register a schema. The schema is physically present in the following location
    USERNAME: WEBUSER
    LOCATION: XML Schemas ---> MyHeaderSchema.xsd
    And I'm trying to register it as follows:
    declare
    V_XML_SCHEMA XMLTYPE := XMLType(BFILENAME('WEBUSER','MyHeaderSchema.xsd'),nls_charset_id('AL32UTF8'));
    begin
    DBMS_XMLSCHEMA.registerSchema
    SCHEMAURL => 'http://my.schemas.com/header.xsd',
    SCHEMADOC => V_XML_SCHEMA,
    LOCAL => TRUE,
    GENBEAN => FALSE,
    GENTYPES => TRUE,
    GENTABLES => FALSE,
    ENABLEHIERARCHY => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
    end;
    I get the error:
    Error report:
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.XMLTYPE", line 296
    ORA-06512: at line 2
    22285. 00000 - "non-existent directory or file for %s operation"
    *Cause:    Attempted to access a directory that does not exist, or attempted
    to access a file in a directory that does not exist.
    *Action:   Ensure that a system object corresponding to the specified
    directory exists in the database dictionary, or
    make sure the name is correct.
    Can you please help?

    I was curious if there was already some functionality in SQL Developer I might have missed. So I checked. Apparently SQL Developer still doesn't have any functionality to support XML Schema's in / for XMLDB (I keep them asking, but anyway).
    So an XML Schema is just treated as plain text. Still.
    However, the following worked for me. Is there a difference if I use XDBURIType Vs BFILENAME and do a getBLOB() Vs XMLType?XDBUriType is part of the URIType factory functionality and in this case, XDBUritype enables you to get the content stored out of the XDB Repository
    BFileName give you the possibility to get your content from the server via a BFile locator construct
    getBLOB is an operator on xdburitype and converts the uritype datatype into binary LOB datatype
    XMLType is the datatype that should be used for XML content
    If you use GENTYPES => TRUE then during registration via using DBMS_XMLSCHEMA objects and types will be created to "represent" the "format" of the XML defined by the XML Schema.

  • Performance issues - which oracle xml technology to use?

    Our company has spent some time researching different oracle xml technologies to obtain the fastest performence but also have the flexibily of a changing xml schemas across revs.
    Not registering schemas gives the flexibity of quickly changing schemas between revs and simpler table structure, but hurts performance quite a bit compared to registering schemas.
    Flat non xml tables seems the fastest but seeing that everything is going xml, this doesn;t seems like a choice.
    Anyhow, let me know any input/experience anyone can offer.
    here's what we have tested all with simple
    10000 record tests, each of the form:
    insert into po_tab values (1,
    xmltype('<PurchaseOrder xmlns="http://www.oracle.com/PO.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.oracle.com/PO.xsd
    http://www.oracle.com/PO.xsd">
    <PONum>akkk</PONum>
    <Company>Oracle Corp</Company>
    <Item>
    <Part>9i Doc Set</Part>
    <Price>2550</Price>
    </Item>
    <Item>
    <Part>8i Doc Set</Part>
    <Price>350</Price>
    </Item>
    </PurchaseOrder>'));
    we have tried three schenerios
    -flat tables, non xml db
    -xml db with registering schemas
    -xml db but not registering schemas, just using XmlType
    and adding oracle text xml indexes with paths to speed up
    queries
    now for the results
    - flat tables, non xml db (we where thinking of using it like this to ease fetching of data for ui views in ad hoc situations, then have code to export the data into
    xml, is there any oracle tool that will let me
    export the data into
    xml automatically via a schema?)
    create table po_tabSimple(
    id int constraint id_pk PRIMARY KEY,
    part varchar2(100),
    price number
    insert into po_tabSimple values (i, 'test', 1.000);
    select part from po_tabSimple;
    2 seconds (Quickest)
    -xml db with registering schemas
    declare
    doc varchar2(1000) := '<schema
    targetNamespace="http://www.oracle.com/PO.xsd"
    xmlns:po="http://www.oracle.com/PO.xsd"
    xmlns="http://www.w3.org/2001/XMLSchema">
    <complexType name="PurchaseOrderType">
    <sequence>
    <element name="PONum" type="decimal"/>
    <element name="Company">
    <simpleType>
    <restriction base="string">
    <maxLength value="100"/>
    </restriction>
    </simpleType>
    </element>
    <element name="Item" maxOccurs="1000">
    <complexType>
    <sequence>
    <element name="Part">
    <simpleType>
    <restriction base="string">
    <maxLength value="1000"/>
    </restriction>
    </simpleType>
    </element>
    <element name="Price" type="float"/>
    </sequence>
    </complexType>
    </element>
    </sequence>
    </complexType>
    <element name="PurchaseOrder" type="po:PurchaseOrderType"/>
    </schema>';
    begin
    dbms_xmlschema.registerSchema('http://www.oracle.com/PO.xsd', doc);
    end;
    create table po_tab(
    id number,
    po sys.XMLType
    xmltype column po
    XMLSCHEMA "http://www.oracle.com/PO.xsd"
    element "PurchaseOrder";
    select EXTRACT(po_tab.po, '/PurchaseOrder/Item/Part/text()','xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"').getStringVal() from po_tab;
    4 sec
    -xml db but not registering schemas, just using XmlType
    and adding oracle text xml indexes with paths to speed up
    queries
    create table po_tabOld(
    id number,
    po sys.XMLType
    select EXTRACT(po_tabOld.po, '/PurchaseOrder/Item/Part/text()','xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"').getStringVal() from po_tabOld;
    41 seconds without indexes
    41 seconds with indexes
    here are the indexes used
    CREATE INDEX po_tabColOld_idx ON po_tabOld(po) indextype is ctxsys.ctxxpath;
    CREATE INDEX po_tabOld_idx ON po_tabOld X (X.po.extract('/PurchaseOrder/Item/Part/text()','xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"').getStringVal());

    Our company has spent some time researching different oracle xml technologies to obtain the fastest performence but also have the flexibily of a changing xml schemas across revs.
    Not registering schemas gives the flexibity of quickly changing schemas between revs and simpler table structure, but hurts performance quite a bit compared to registering schemas.
    Flat non xml tables seems the fastest but seeing that everything is going xml, this doesn;t seems like a choice.
    Anyhow, let me know any input/experience anyone can offer.
    here's what we have tested all with simple
    10000 record tests, each of the form:
    insert into po_tab values (1,
    xmltype('<PurchaseOrder xmlns="http://www.oracle.com/PO.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.oracle.com/PO.xsd
    http://www.oracle.com/PO.xsd">
    <PONum>akkk</PONum>
    <Company>Oracle Corp</Company>
    <Item>
    <Part>9i Doc Set</Part>
    <Price>2550</Price>
    </Item>
    <Item>
    <Part>8i Doc Set</Part>
    <Price>350</Price>
    </Item>
    </PurchaseOrder>'));
    we have tried three schenerios
    -flat tables, non xml db
    -xml db with registering schemas
    -xml db but not registering schemas, just using XmlType
    and adding oracle text xml indexes with paths to speed up
    queries
    now for the results
    - flat tables, non xml db (we where thinking of using it like this to ease fetching of data for ui views in ad hoc situations, then have code to export the data into
    xml, is there any oracle tool that will let me
    export the data into
    xml automatically via a schema?)
    create table po_tabSimple(
    id int constraint id_pk PRIMARY KEY,
    part varchar2(100),
    price number
    insert into po_tabSimple values (i, 'test', 1.000);
    select part from po_tabSimple;
    2 seconds (Quickest)
    -xml db with registering schemas
    declare
    doc varchar2(1000) := '<schema
    targetNamespace="http://www.oracle.com/PO.xsd"
    xmlns:po="http://www.oracle.com/PO.xsd"
    xmlns="http://www.w3.org/2001/XMLSchema">
    <complexType name="PurchaseOrderType">
    <sequence>
    <element name="PONum" type="decimal"/>
    <element name="Company">
    <simpleType>
    <restriction base="string">
    <maxLength value="100"/>
    </restriction>
    </simpleType>
    </element>
    <element name="Item" maxOccurs="1000">
    <complexType>
    <sequence>
    <element name="Part">
    <simpleType>
    <restriction base="string">
    <maxLength value="1000"/>
    </restriction>
    </simpleType>
    </element>
    <element name="Price" type="float"/>
    </sequence>
    </complexType>
    </element>
    </sequence>
    </complexType>
    <element name="PurchaseOrder" type="po:PurchaseOrderType"/>
    </schema>';
    begin
    dbms_xmlschema.registerSchema('http://www.oracle.com/PO.xsd', doc);
    end;
    create table po_tab(
    id number,
    po sys.XMLType
    xmltype column po
    XMLSCHEMA "http://www.oracle.com/PO.xsd"
    element "PurchaseOrder";
    select EXTRACT(po_tab.po, '/PurchaseOrder/Item/Part/text()','xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"').getStringVal() from po_tab;
    4 sec
    -xml db but not registering schemas, just using XmlType
    and adding oracle text xml indexes with paths to speed up
    queries
    create table po_tabOld(
    id number,
    po sys.XMLType
    select EXTRACT(po_tabOld.po, '/PurchaseOrder/Item/Part/text()','xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"').getStringVal() from po_tabOld;
    41 seconds without indexes
    41 seconds with indexes
    here are the indexes used
    CREATE INDEX po_tabColOld_idx ON po_tabOld(po) indextype is ctxsys.ctxxpath;
    CREATE INDEX po_tabOld_idx ON po_tabOld X (X.po.extract('/PurchaseOrder/Item/Part/text()','xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"').getStringVal());

  • Errors when using inplace schema evolution

    Hi, i have been having some issues when attempting to use inplace schema evolution to add a new element into an existing xsd file currently registered on the database and was looking for some help with this if possible.
    Firstly, Oracle details are as follows :
    Oracle Database 11g Enterprise Edition 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 IBM/AIX RISC System/6000: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - ProductionThe xsd registered on the database is called truncheadtest2.xsd :
    <?xml version="1.0" encoding="UTF-8"?>
    <!--W3C Schema generated by XMLSpy v2009 sp1 (http://www.altova.com)-->
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
         <xs:element name="title">
              <xs:simpleType>
                   <xs:restriction base="xs:string"/>
              </xs:simpleType>
         </xs:element>
         <xs:element name="clientRiskEventHeader" xdb:defaultTable="EVLN_CLIENTRISKEVENTHEADER">
              <xs:complexType xdb:SQLType="EVLN_CLIENTRISKEVENTHEADER_T">
                   <xs:sequence>
                        <xs:element ref="title" xdb:SQLName="TITLE"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
    </xs:schema>registered via :
    BEGIN
      DBMS_XMLSCHEMA.registerSchema(
       SCHEMAURL => 'http://xmlns.kfis.co.uk/testevheader/xsdin/truncheadertest.xsd',
      SCHEMADOC => XDBURIType('/public/web_quotes/header/xsd/test/SchemaTest/truncheadtest2.xsd').getCLOB());
    END;i have then created a new xsd, to add the new element to the xsd (using minoccurs to allow backwards compatibility between xml files conforming to the 1st xsd and this new xsd), called truncheadtestfn3.xsd :
    <?xml version="1.0" encoding="UTF-8"?>
    <!--W3C Schema generated by XMLSpy v2009 sp1 (http://www.altova.com)-->
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
         <xs:element name="title">
              <xs:simpleType>
                   <xs:restriction base="xs:string"/>
              </xs:simpleType>
         </xs:element>
         <xs:element name="forename">
              <xs:simpleType>
                   <xs:restriction base="xs:string"/>
              </xs:simpleType>
         </xs:element>
         <xs:element name="clientRiskEventHeader" xdb:defaultTable="EVLN_CLIENTRISKEVENTHEADER">
              <xs:complexType xdb:SQLType="EVLN_CLIENTRISKEVENTHEADER_T">
                   <xs:sequence>
                        <xs:element ref="title" xdb:SQLName="TITLE"/>
                        <xs:element ref="forename" minOccurs="0" xdb:SQLName="FORENAME"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
    </xs:schema>I can run the following code to create the difference doc between the 2 versions of the schema document, without errors:
    DECLARE
       schemaDiff XMLType;
       res boolean;
    BEGIN
       SELECT xmlDiff
            xdburitype('/public/web_quotes/header/xsd/test/SchemaTest/truncheadtest2.xsd').getXML(),
            xdburitype('/public/web_quotes/header/xsd/test/SchemaTest/truncheadtestfn3.xsd').getXML()
       INTO schemaDiff
       FROM dual;
       IF (dbms_xdb.existsResource('/public/web_quotes/header/xsd/test/SchemaTest/header.xml')) THEN
           dbms_xdb.deleteResource('/public/web_quotes/header/xsd/test/SchemaTest/header.xml');
       END IF;
       res :=
         dbms_xdb.createResource('/public/web_quotes/header/xsd/test/SchemaTest/header.xml',schemaDiff);
         dbms_xmlschema.inPlaceEvolve('http://xmlns.kfis.co.uk/testevheader/xsdin/truncheadertest.xsd',schemaDiff,2);
    END;
    / which creates the following xml file:
    - <xd:xdiff xsi:schemaLocation="http://xmlns.oracle.com/xdb/xdiff.xsd http://xmlns.oracle.com/xdb/xdiff.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <?oracle-xmldiff operations-in-docorder="true" output-model="snapshot" diff-algorithm="global"?>
    - <xd:insert-node-before xd:node-type="element" xd:xpath="/xs:schema[1]/xs:element[2]">
    - <xd:content>
    - <xs:element name="forename">
    - <xs:simpleType>
      <xs:restriction base="xs:string" />
      </xs:simpleType>
      </xs:element>
      </xd:content>
      </xd:insert-node-before>
    - <xd:append-node xd:node-type="element" xd:parent-xpath="/xs:schema[1]/xs:element[2]/xs:complexType[1]/xs:sequence[1]">
    - <xd:content>
      <xs:element ref="forename" minOccurs="0" xdb:SQLName="FORENAME" />
      </xd:content>
      </xd:append-node>
      </xd:xdiff>However, when i then run the inplace schema evolution code for option 1, i get the following error:
    Error report:
    ORA-22324: altered type has compilation errors
    ORA-22328: object "WEB_STAGING"."EVLN_CLIENTRISKEVENTHEADER_T" has errors.
    PLS-00215: String length constraints must be in range (1 .. 32767)
    ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 173
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 231
    ORA-06512: at line 17
    22324. 00000 -  "altered type has compilation errors"
    *Cause:    The use of the ALTER TYPE statement caused a compilation error.
    *Action:   Correct the error reported and resubmit the statement.I am getting this issue when attempting to add any string value to the existing xsd and i was wondering if you had any idea what the issue was here and how i could resolve this.
    Thanks.

    Hi,
    When you use INPLACE_TRACE flag, it traces the operations that would be performed with option 1.
    If you look at the trace file produced in this case, you'll see where the error is coming from :
    ------------ QMTS Executing SQL ------------
    ALTER TYPE "TEST"."EVLN_CLIENTRISKEVENTHEADER_T" ADD ATTRIBUTE "FORENAME" VARCHAR2 CASCADE NOT INCLUDING TABLE DATA
    /The mandatory length specification is absent.
    I thought adding an explicit xs:maxLength restriction would solve the problem, but it happens the generated DDL still lacks the length specification.
    After some tries, I found that the issue seems related to the usage of ref elements in the schema.
    On a side note, it's not the first time we see problems associated with ref (Cf. how do i get xml db to work right with imported or included schemas?).
    The workaround is to use a named type.
    I've also added an xdb:defaultTable annotation to the top-level element ("title") so that the registration process doesn't generate a table for it :
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
         <xs:element name="title" xdb:defaultTable="">
              <xs:simpleType>
                   <xs:restriction base="xs:string">
                     <xs:maxLength value="200"/>
                   </xs:restriction>
              </xs:simpleType>
         </xs:element>
         <xs:simpleType name="forenameType">
              <xs:restriction base="xs:string">
                   <xs:maxLength value="30"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:element name="clientRiskEventHeader" xdb:defaultTable="EVLN_CLIENTRISKEVENTHEADER">
              <xs:complexType xdb:SQLType="EVLN_CLIENTRISKEVENTHEADER_T">
                   <xs:sequence>
                        <xs:element ref="title" xdb:SQLName="TITLE"/>
                        <xs:element name="forename" type="forenameType" minOccurs="0" xdb:SQLName="FORENAME"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
    </xs:schema>

Maybe you are looking for