[11g] adding a virtual col to a binary XML table?

Hi
Is it possible to add a virtual col to an existing binay XML table ?
CREATE TABLE compagnie_binaryXML OF XMLType
XMLTYPE STORE AS BINARY XML
VIRTUAL COLUMNS
(vircolcomp AS (EXTRACTVALUE(OBJECT_VALUE,'/compagnie/comp')),
vircolnomcomp AS (EXTRACTVALUE(OBJECT_VALUE,'/compagnie/nomComp')),
vircolnompil AS (EXTRACTVALUE(OBJECT_VALUE,'/compagnie/pilotes/pilote/nom')),
vircolbrevpil AS (EXTRACTVALUE(OBJECT_VALUE,'/compagnie/pilotes/pilote/@brevet')));
OK, but
ALTER TABLE compagnie_binaryXML ADD vircolsalpil AS (EXTRACTVALUE(OBJECT_VALUE,'/compagnie/pilotes/pilote/s
alaire'));
ORA-22856: impossible d'ajouter des colonnes à des tables objet

Hi
IMHO this has nothing to do with XMLType... They simply forget to change the checks performed before adding a column... In fact, this is a "known problem" with object tables.
SQL> create type ttt as object (n number);
  2  /
SQL> create table t of ttt;
SQL> alter table t add v as (to_char(n));
alter table t add v as (to_char(n))
ERROR at line 1:
ORA-22856: cannot add columns to object tables
oracle@helicon:~/ [DBA11106] oerr ora 22856
22856, 00000, "cannot add columns to object tables"
// *Cause:   An attempt was made to add columns to an object table. Object
//           tables cannot be altered to add columns since its
//           definition is based on an object type.
// *Action:  Create a new type with additional attributes, and use the new
//           type to create an object table. The new object table will have
//           the desired columns.In summary, I would open an SR and let fix the problem.
HTH
Chris

Similar Messages

  • Why Isn't xmlindex being used in slow query on binary xml table eval?

    I am running a slow simple query on Oracle database server 11.2.0.1 that is not using an xmlindex. Instead, a full table scan against the eval binary xml table occurs. Here is the query:
    select -- /*+ NO_XMLINDEX_REWRITE no_parallel(eval)*/
          defid from eval,
          XMLTable(XMLNAMESPACES(DEFAULT 'http://www.cigna.com/acme/domains/eval/2010/03',
          'http://www.cigna.com/acme/domains/derived/fact/2010/03' AS "ns7"),
          '$doc/eval/derivedFacts/ns7:derivedFact' passing eval.object_value as "doc" columns defid varchar2(100) path 'ns7:defId'
           ) eval_xml
    where eval_xml.defid in ('59543','55208'); The predicate is not selective at all - the returned row count is the same as the table row count (325,550 xml documents in the eval table). When different values are used bringing the row count down to ~ 33%, the xmlindex still isn't used - as would be expected in a purely relational nonXML environment.
    My question is why would'nt the xmlindex be used in a fast full scan manner versus a full table scan traversing the xml in each eval table document record?
    Would a FFS hint be applicable to an xmlindex domain-type index?
    Here is the xmlindex definition:
    CREATE INDEX "EVAL_XMLINDEX_IX" ON "EVAL" (OBJECT_VALUE)
      INDEXTYPE IS "XDB"."XMLINDEX" PARAMETERS
      ('XMLTable eval_idx_tab XMLNamespaces(DEFAULT ''http://www.cigna.com/acme/domains/eval/2010/03'',
      ''http://www.cigna.com/acme/domains/derived/fact/2010/03'' AS "ns7"),''/eval''
           COLUMNS defId VARCHAR2(100) path ''/derivedFacts/ns7:derivedFact/ns7:defId''');Here is the eval table definition:
    CREATE
      TABLE "N98991"."EVAL" OF XMLTYPE
        CONSTRAINT "EVAL_ID_PK" PRIMARY KEY ("EVAL_ID") USING INDEX PCTFREE 10
        INITRANS 4 MAXTRANS 255 COMPUTE STATISTICS 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 "ACME_DATA" ENABLE
      XMLTYPE STORE AS SECUREFILE BINARY XML
        TABLESPACE "ACME_DATA" ENABLE STORAGE IN ROW CHUNK 8192 CACHE NOCOMPRESS
        KEEP_DUPLICATES STORAGE(INITIAL 106496 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS
        2147483645 PCTINCREASE 0 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT)
      ALLOW NONSCHEMA ALLOW ANYSCHEMA VIRTUAL COLUMNS
        "EVAL_DT" AS (SYS_EXTRACT_UTC(CAST(TO_TIMESTAMP_TZ(SYS_XQ_UPKXML2SQL(
        SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03"; (::)
    /eval/@eval_dt'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') AS TIMESTAMP
    WITH
      TIME ZONE))),
        "EVAL_CAT" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";/eval/@category'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50))),
        "ACME_MBR_ID" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";/eval/@acmeMemberId'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50))),
        "EVAL_ID" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";/eval/@evalId'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50)))
      PCTFREE 0 PCTUSED 80 INITRANS 4 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 "ACME_DATA" ; Sample cleansed xml snippet:
    <?xml version = '1.0' encoding = 'UTF-8' standalone = 'yes'?><eval createdById="xxxx" hhhhMemberId="37e6f05a-88dc-41e9-a8df-2a2ac6d822c9" category="eeeeeeee" eval_dt="2012-02-11T23:47:02.645Z" evalId="12e007f5-b7c3-4da2-b8b8-4bf066675d1a" xmlns="http://www.xxxxx.com/vvvv/domains/eval/2010/03" xmlns:ns2="http://www.cigna.com/nnnn/domains/derived/fact/2010/03" xmlns:ns3="http://www.xxxxx.com/vvvv/domains/common/2010/03">
       <derivedFacts>
          <ns2:derivedFact>
             <ns2:defId>12345</ns2:defId>
             <ns2:defUrn>urn:mmmmrunner:Medical:Definition:DerivedFact:52657:1</ns2:defUrn>
             <ns2:factSource>tttt Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:47:02.645Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>boolean</ns2:type>
                <ns2:value>true</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>52600</ns2:defId>
             <ns2:defUrn>urn:ddddrunner:Medical:Definition:DerivedFact:52600:2</ns2:defUrn>
             <ns2:factSource>cccc Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:47:02.645Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>string</ns2:type>
                <ns2:value>null</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>59543</ns2:defId>
             <ns2:defUrn>urn:ddddunner:Medical:Definition:DerivedFact:52599:1</ns2:defUrn>
             <ns2:factSource>dddd Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:47:02.645Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>string</ns2:type>
                <ns2:value>INT</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
                With the repeating <ns2:derivedFact> element continuing under the <derivedFacts>The Oracle XML DB Developer's Guide 11g Release 2 isn't helping much...
    Any assitance much appreciated.
    Regards,
    Rick Blanchard

    odie 63, et. al.;
    Attached is the reworked select query, xmlindex, and 2ndary indexes. Note: though namespaces are used; we're not registering any schema defns.
    SELECT /*+ NO_USE_HASH(eval) +/ --/*+ NO_QUERY_REWRITE no_parallel(eval)*/
    eval_xml.eval_catt, df.defid FROM eval,
    --df.defid FROM eval,
    XMLTable(XMLNamespaces( DEFAULT 'http://www.cigna.com/acme/domains/eval/2010/03',
                            'http://www.cigna.com/acme/domains/derived/fact/2010/03' AS "ns7" ),
            '/eval' passing eval.object_value
             COLUMNS
               eval_catt VARCHAR2(50) path '@category',
               derivedFact XMLTYPE path '/derivedFacts/ns7:derivedFact')eval_xml,
    XMLTable(XMLNamespaces('http://www.cigna.com/acme/domains/derived/fact/2010/03' AS "ns7",
                              DEFAULT 'http://www.cigna.com/acme/domains/eval/2010/03'),
            '/ns7:derivedFact' passing eval_xml.derivedFact
             COLUMNS
               defid VARCHAR2(100) path 'ns7:defId') df
    WHERE df.defid IN ('52657','52599') AND eval_xml.eval_catt LIKE 'external';
    --where df.defid = '52657';
    SELECT /*+ NO_USE_HASH(eval +/ --/*+ NO_QUERY_REWRITE no_parallel(eval)*/
    eval_xml.eval_catt, df.defid FROM eval,
    --df.defid FROM eval,
    XMLTable(XMLNamespaces( DEFAULT 'http://www.cigna.com/acme/domains/eval/2010/03',
                            'http://www.cigna.com/acme/domains/derived/fact/2010/03' AS "ns7" ),
            '/eval' passing eval.object_value
             COLUMNS
               eval_catt VARCHAR2(50) path '@category',
               derivedFact XMLTYPE path '/derivedFacts/ns7:derivedFact')eval_xml,
    XMLTable(XMLNamespaces('http://www.cigna.com/acme/domains/derived/fact/2010/03' AS "ns7",
                              DEFAULT 'http://www.cigna.com/acme/domains/eval/2010/03'),
            '/ns7:derivedFact' passing eval_xml.derivedFact
             COLUMNS
               defid VARCHAR2(100) path 'ns7:defId') df
    WHERE df.defid IN ('52657','52599') AND eval_xml.eval_catt LIKE 'external';
    --where df.defid = '52657'; create index defid_2ndary_ix on eval_idx_tab_II (defID);
         eval_catt VARCHAR2(50) path ''@CATEGORY''');
    create index eval_catt_2ndary_ix on eval_idx_tab_I (eval_catt);The xmlindex is getting picked up but a couple of problesm:
    1. In the developemnt environment, no xml source records for defid '52657' or '52599' are being displayed - just an empty output set occurs; in spite of these values being present and stored in the source xml.
    This really has me stumped, as can query the eval table to see the actual xml defid vaues '52657' and '52599' exist. Something appears off with the query - which didn't return records even before the corrresponding xml index was created.
    2. The query still performs slowly, in spite of using the xmlindex. The execution plan shows a full table scan of eval occurring whether or not a HASH JOIN or MERGE JOIN (gets used in place of the HASH JOIN when the NO_USE_HASH(eval) int is used.
    3. Single column 2ndary indexes created respectively for eval_catt and defid are not used in the execution plan - which may be expected upon further consideration.
    In the process of running stats at this moment, to see if performance improves....
    At this point, really after why item '1.' is occurring?
    Edited by: RickBlanchardSRSCigna on Apr 16, 2012 1:33 PM

  • Migrate B-Tree Indexes of XML O-R Table to XMLIndex on Binary XML Table

    We need slight help on how to migrate existing B-TREE Indexes from XML Obj-Rel Tables to XMLIndex on new XML Binary Tables
    We use searches on Nested Collection Elements (defined unbounded in XSD)
    and related DDL for XML Obj-Rel Tables is shown below:
    CREATE TABLE TNMAB_AGREEMENT_XML
    AGREEMENT_XML xmltype,
    CREATE_BY     VARCHAR2(15) NULL ,
    CREATE_DT_GMT     TIMESTAMP NULL ,
    CREATE_CLIENT_ID VARCHAR2(65) NULL ,
    UPDATE_BY     VARCHAR2(15) NULL ,
    UPDATE_DT_GMT     TIMESTAMP NULL ,
    UPDATE_CLIENT_ID VARCHAR2(65) NULL ,
    PIC_VERSION_NUM     NUMBER(20) NULL
    XMLTYPE COLUMN AGREEMENT_XML XMLSCHEMA "AB_Agreement_V1_XMLDB.xsd" ELEMENT "Agreement"
    VARRAY AGREEMENT_XML.XMLDATA."SHIPPING_PARTY_GROUPS"
    STORE AS TABLE SHIPPING_PARTY_GROUPS_NT
    (PRIMARY KEY (NESTED_TABLE_ID, ARRAY_INDEX) ENABLE)
    VARRAY SHIPPING_PARTIES
    STORE AS TABLE SHIPPING_PARTIES_NT
    (PRIMARY KEY (NESTED_TABLE_ID, ARRAY_INDEX) ENABLE)
    VARRAY AGREEMENT_XML.XMLDATA."SALES_OFFICE_CODES"."STRING_WRAPPERS"
    STORE AS TABLE SALES_OFFICE_CODES_NT
    (PRIMARY KEY (NESTED_TABLE_ID, ARRAY_INDEX) ENABLE)
    TABLESPACE TNMAB_XMLDB_ME_DATA;
    Table has PK and Unique Index which for the Binary XML Table, it will be setup on Virtual Columns (to enforce
    Unique Constraints)
    We have 6 more Normal Indexes on this Table, some created on Nested Elements as shown below:
    -- 4 Normal B-TREE Indexes on Leaf level Elements
    create index TNMAB_AGREEMENT_XML_IDX1 on TNMAB_AGREEMENT_XML (AGREEMENT_XML.XMLDATA."AGREEMENT_VERSION")
    tablespace TNMAB_XMLDB_ME_INDX;
    create index TNMAB_AGREEMENT_XML_IDX2 on TNMAB_AGREEMENT_XML (AGREEMENT_XML.XMLDATA."LAST_UPDATED_BY")
    tablespace TNMAB_XMLDB_ME_INDX;
    create index TNMAB_AGREEMENT_XML_IDX3 on TNMAB_AGREEMENT_XML (AGREEMENT_XML.XMLDATA."LAST_UPDATED")
    tablespace TNMAB_XMLDB_ME_INDX;
    create index TNMAB_AGREEMENT_XML_IDX4 on TNMAB_AGREEMENT_XML (AGREEMENT_XML.XMLDATA."CREATION_DATE")
    tablespace TNMAB_XMLDB_ME_INDX;
    --2 Indexes created on Nested Table (Collection)
    create index TNMAB_AGREEMENT_XML_NT_IDX1 on SALES_OFFICE_CODES_NT NT(NT.STR_VAL, NT.NESTED_TABLE_ID)
    tablespace TNMAB_XMLDB_ME_INDX;
    create index TNMAB_AGREEMENT_XML_NT_IDX2 on SHIPPING_PARTIES_NT NT(NT.CUSTOMER_HOLDER.SAP_ID, NT.NESTED_TABLE_ID)
    tablespace TNMAB_XMLDB_ME_INDX;
    Could you please let us know how we should migrate above Indexes to XMLIndex format.
    Specifically, not sure how the last 2 Indexes on Nested Tables is to be defined.
    Any help or resources pointing to this would be greatly appreciated.
    Thanks for the help,
    Auro

    Can't tell due to using XMLDATA pseudocolumn. Would need a sample XML document structure that can be used to define the XPATH structure and ALSO need the database version you are using (ALL digits) to see if you would need / can use STRUCTURED or UNSTRUCTURED XMLINDEX indexes.
    See the XML Index section (http://www.liberidu.com/blog/?page_id=441) on for guidance and/or of course the XMLDB Developers Guide for your database version
    http://www.liberidu.com/blog/?page_id=441
    XMLIndex (part 1) – The Concepts
    XMLIndex (Part 2) – XMLIndex Path Subsetting
    XMLIndex (Part 3) – XMLIndex Syntax Dissected
    XMLIndex Performance and Fuzzy XPath Searches
    Structured XMLIndex (Part 1) – Rules of Numb
    Structured XMLIndex (Part 2) – Howto build a structured XMLIndex
    Structured XMLIndex (Part 3) – Building Multiple XMLIndex Structures

  • Errors creating indexes on Binary XML Tables

    Hi,
    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 - Production
    I'm currently having an issue when attempting to create a suitable index on a binary xml table. I have a Binary xml table that stores a number of xml documents. I have created an index on this table as follows:
    create index TEST_WQI_idx_1 on TEST_WEB_QUOTE_INDX1(OBJECT_VALUE)
    INDEXTYPE IS XDB.XMLINDEX
    PARAMETERS ('PATHS (INCLUDE
    (/webPolicy/QuoteId))');
    Querying the table with the following:
    SQL> l
    1 select xmlcast(xmlquery('/webPolicy/Sections/interopSection[1]/PolicyItems/item/Version/text()' PASSING OBJECT_VALUE RETURNING CONTENT)
    2 as number) "VERSION",
    3 xmlcast(xmlquery('/webPolicy/QuoteId/text()' PASSING OBJECT_VALUE RETURNING CONTENT)
    4 as number) "QUOTEID"
    5 FROM TEST_WEB_QUOTE_INDX1
    6 where xmlcast(xmlquery('/webPolicy/QuoteId/text()' PASSING OBJECT_VALUE RETURNING CONTENT)
    7* as number) = 22824
    SQL> /
    VERSION QUOTEID
    1 22824
    Execution Plan
    Plan hash value: 3559428808
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 545 | 1071K| 1030 (1)| 00:00:19 |
    | 1 | SORT AGGREGATE | | 1 | 3022 | | |
    |* 2 | TABLE ACCESS BY INDEX ROWID | SYS895336_TEST_WQI__PATH_TABLE | 1 | 3022 | 2 (0)| 00:00:01 |
    |* 3 | INDEX RANGE SCAN | SYS895336_TEST_WQI__PIKEY_IX | 1 | | 1 (0)| 00:00:01 |
    |* 4 | FILTER | | | | | |
    | 5 | TABLE ACCESS FULL | TEST_WEB_QUOTE_INDX1 | 545 | 1071K| 4 (0)| 00:00:01 |
    | 6 | SORT AGGREGATE | | 1 | 3022 | | |
    |* 7 | TABLE ACCESS BY INDEX ROWID| SYS895336_TEST_WQI__PATH_TABLE | 1 | 3022 | 2 (0)| 00:00:01 |
    |* 8 | INDEX RANGE SCAN | SYS895336_TEST_WQI__PIKEY_IX | 1 | | 1 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter(SYS_XMLI_LOC_ISTEXT("SYS_P0"."LOCATOR","SYS_P0"."PATHID")=1)
    3 - access("SYS_P0"."RID"=:B1 AND "SYS_P0"."PATHID"=HEXTORAW('5E6C') )
    4 - filter(CAST( (SELECT "SYS"."STRAGG"("SYS_P2"."VALUE") FROM
    "WEB_STAGING"."SYS895336_TEST_WQI__PATH_TABLE" "SYS_P2" WHERE "SYS_P2"."PATHID"=HEXTORAW('5E6C') AND
    "SYS_P2"."RID"=:B1 AND SYS_XMLI_LOC_ISTEXT("SYS_P2"."LOCATOR","SYS_P2"."PATHID")=1) AS number)=22824)
    7 - filter(SYS_XMLI_LOC_ISTEXT("SYS_P2"."LOCATOR","SYS_P2"."PATHID")=1)
    8 - access("SYS_P2"."RID"=:B1 AND "SYS_P2"."PATHID"=HEXTORAW('5E6C') )
    Note
    - dynamic sampling used for this statement (level=2)
    - Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)
    However, I also need to add an additional field to this index to allow appropriate queries against the data in the table, version number. This field can be seen from the statement above (VERSION) which runs OK and returns the data I’d expect. However, when I attempt to add this index using the following statement I get an error returned and the index becomes corrupted:
    alter index TEST_WQI_idx_1 rebuild
    parameters ('PATHS (INCLUDE ADD
    (/webPolicy/Sections/interopSection[1]/PolicyItems/item/Version))');
    After some investigation, the issue seems to revolve around the use of the [1] condition in the statement /interopSection[1]. I can create the index by removing the [1] condition, but this does not return the expected result. In actual fact, as there are 2 interopSection elements in the xml file, both with a version number of 1, the statement returns 11, which would appear to be the two version numbers concatenated together. I need to be able to reference the version number from the first interopSection in the queries against the table, and I need to be able to index this column correctly for performance issues.
    I'm unsure why this xpath statement is not working correctly in the alter index statement, but returns ok when used within the query against the table and was wondering if you would be able to help me to have a working index against this element.
    Thanks in advance for any help you can provide in relation to this.

    Sorry, here is the error:
    Error starting at line 20 in command:
    alter index TEST_WQI_idx_1 rebuild
    parameters ('PATHS (INCLUDE ADD
    (/webPolicy/Sections/interopSection[1]/PolicyItems/item/Version))')
    Error report:
    SQL Error: ORA-29858: error occurred in the execution of ODCIINDEXALTER routine
    ORA-64131: XMLIndex Metadata: failure during the looking up of the dictionary
    ORA-30968: invalid XPATH or NAMESPACE option for XML Index
    29858. 00000 - "error occurred in the execution of ODCIINDEXALTER routine"
    *Cause:    Failed to successfully execute the ODCIIndexAlter routine.
    *Action:   Check to see if the routine has been coded correctly.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • [[11g] many XMLSCHEMA for a given binary XML table

    Hi,
    --1-----------------------------------
    I cannot create a table associated with several xmlschemas.
    create table "VALIDATE_XML_SCHEMA" of XMLTYPE
    XMLTYPE STORE AS BASICFILE BINARY XML
    XMLSCHEMAS (XMLSCHEMA "http://www.binary.com/root.xsd" ELEMENT "ROOT",
    XMLSCHEMA "http://www.different.com/root.xsd" ELEMENT "ROOT") DISALLOW NONSCHEMA;
    ==> ORA 22853
    Does this syntax is wrong?
    --2----------------------------------
    What about add and remove an existing associated xmlschma ?
    ALTER table "VALIDATE_XML_SCHEMA"
    REMOVE XMLSCHEMAS (XMLSCHEMA "http://www.different.com/root.xsd" ELEMENT "ROOT");
    ALTER table "VALIDATE_XML_SCHEMA"
    ADD XMLSCHEMAS (XMLSCHEMA "http://www.different.com/root.xsd" ELEMENT "ROOT") DISALLOW NONSCHEMA;
    ---------------------------------

    OK, so here it goes ...
    TEST1.xsd
    <?xml version = "1.0" encoding = "UTF-8"?>
    <xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
          elementFormDefault = "qualified">
      <xsd:element name = "TEST1XML">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element ref = "ID"/>
            <xsd:element ref = "Description"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name = "ID">
        <xsd:simpleType>
          <xsd:restriction base = "xsd:string">
            <xsd:length value = "4"/>
          </xsd:restriction>
        </xsd:simpleType>
      </xsd:element>
      <xsd:element name = "Description">
        <xsd:simpleType>
          <xsd:restriction base = "xsd:string">
            <xsd:maxLength value = "35"/>
          </xsd:restriction>
        </xsd:simpleType>
      </xsd:element>
    </xsd:schema>TEST2.xsd
    <?xml version = "1.0" encoding = "UTF-8"?>
    <xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
          elementFormDefault = "qualified">
      <xsd:element name = "TEST2XML">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element ref = "ID"/>
            <xsd:element ref = "AccessedOn"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name = "ID">
        <xsd:simpleType>
          <xsd:restriction base = "xsd:string">
            <xsd:length value = "4"/>
          </xsd:restriction>
        </xsd:simpleType>
      </xsd:element>
      <xsd:element name = "AccessedOn" type="xsd:dateTime" />
    </xsd:schema>and the offending script
    SET TIMING ON;
    BEGIN
       DBMS_XMLSCHEMA.REGISTERSCHEMA(
         SCHEMAURL => 'http://localhost/xsd/TEST1.xsd',
         SCHEMADOC => BFILENAME('XML_FILES_DIR','TEST1.xsd'),
         LOCAL     => TRUE,
         GENTYPES  => FALSE,
         GENBEAN   => FALSE,
         GENTABLES => FALSE,
         FORCE     => FALSE,
         CSID      => NLS_CHARSET_ID('AL32UTF8'),
         OPTIONS   => DBMS_XMLSCHEMA.REGISTER_BINARYXML);
    END;
    BEGIN
       DBMS_XMLSCHEMA.REGISTERSCHEMA(
         SCHEMAURL => 'http://localhost/xsd/TEST2.xsd',
         SCHEMADOC => BFILENAME('XML_FILES_DIR','TEST2.xsd'),
         LOCAL     => TRUE,
         GENTYPES  => FALSE,
         GENBEAN   => FALSE,
         GENTABLES => FALSE,
         FORCE     => FALSE,
         CSID      => NLS_CHARSET_ID('AL32UTF8'),
         OPTIONS   => DBMS_XMLSCHEMA.REGISTER_BINARYXML);
    END;
    CREATE TABLE XML_TEST_TBL OF XMLTYPE
       XMLTYPE STORE AS SECUREFILE BINARY XML
       XMLSCHEMAS( XMLSCHEMA "http://localhost/xsd/TEST1.xsd" ELEMENT "TEST1XML",
                   XMLSCHEMA "http://localhost/xsd/TEST2.xsd" ELEMENT "TEST2XML")
       DISALLOW NONSCHEMA;
    COMMIT;After running the script, I get
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.45
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:01.47
    CREATE TABLE XML_TEST_TBL OF XMLTYPE
       XMLTYPE STORE AS SECUREFILE BINARY XML
       XMLSCHEMAS( XMLSCHEMA "http://localhost/xsd/TEST1.xsd" ELEMENT "TEST1XML",
                   XMLSCHEMA "http://localhost/xsd/TEST2.xsd" ELEMENT "TEST2XML")
       DISALLOW NONSCHEMA
    Error at line 28
    ORA-22853: invalid LOB storage option specificationSo, I am indeed hitting the issue !
    And to complement the posts made so far, all the other errors (ALTER TABLE syntax, multiple schemas for OBJECT RELATIONAL storage) mentioned still occur in 11.1.0.7 ....
    Maybe Mark can advise on how to proceed with this. I must say though that I am not too happy creating SRs... It might give a bad impression about me AND about the product and that would be unfair on both counts.
    Best Regards
    Philip

  • Add a unique constraint on binary XML table

    How add a unique constraint of "brevet" field?
    The following INSERT failed
    SQL Error: ORA-19025: EXTRACTVALUE renvoie la valeur d'un seul noeud
    19025. 00000 - "EXTRACTVALUE returns value of only one node"
    If the ALTER is made after the INSERT is done, INSERT is valid but ALTER failed with the same error message!
    /* copy the file compavions.xml
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <compagnie>
         <comp>AB</comp>
         <flotte>
              <avion immat="F-WTSS" capacite="90">
                   <typeAv>Concorde</typeAv>
              </avion>
              <avion immat="F-GFDR" capacite="145">
                   <typeAv>A320</typeAv>
              </avion>
              <avion immat="F-GTYA" capacite="150">
                   <typeAv>A320</typeAv>
              </avion>
         </flotte>
         <nomComp>Air Blagnac</nomComp>
         <pilotes>
              <pilote>
              <brevet>PL-1</brevet>
              <nom>C. Sigaudes</nom>
              </pilote>
              <pilote>
              <brevet>PL-2</brevet>
              <nom>P. Filloux</nom>
              </pilote>
         </pilotes>
    </compagnie>
    in C:\...
    --DROP DIRECTORY repxml;
    --CREATE DIRECTORY repxml AS 'C:\...';
    DROP TABLE pilote_binary_xml5;
    CREATE TABLE pilote_binary_xml5 OF XMLType
    XMLTYPE STORE AS BINARY XML
    VIRTUAL COLUMNS
    (col AS (EXTRACTVALUE(OBJECT_VALUE, '/compagnie/pilotes/pilote/brevet')));
    ALTER TABLE pilote_binary_xml5 ADD CONSTRAINT brevet_unique UNIQUE (col);
    INSERT INTO pilote_binary_xml5 VALUES (XMLType(BFILENAME ('REPXML','compavions.xml'), NLS_CHARSET_ID ('AL32UTF8')));
    --ALTER TABLE pilote_binary_xml5 ADD CONSTRAINT brevet_unique UNIQUE (col);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    You could try something like
    (extract(OBJECT_VALUE,compagnie/pilotes/pilote/brevet').getStringVal());
    but this is probably unadvisable.
    I suggest an alternative is for you to look at XMLINDEX so that you can bring the 'proper' XML functions into play like XMLTABLE etc.

  • Online Redefinition of Binary XML column not possible?

    DB version 11.2.0.1 x64 (still working on upgrading to 11.2.0.3)
    create table redef_test (
            id number(19,0) not null,
            xml XMLType,
            primary key (id)
        XMLTYPE COLUMN "XML" STORE AS CLOB;
    table REDEF_TEST created.
    exec dbms_redefinition.can_redef_table( 'USER', 'redef_test' );
    anonymous block completed
    drop table redef_test;
    create table redef_test (
            id number(19,0) not null,
            xml XMLType,
            primary key (id)
        XMLTYPE COLUMN "XML" STORE AS BINARY XML;
    table REDEF_TEST dropped.
    table REDEF_TEST created.
    exec dbms_redefinition.can_redef_table( 'USER', 'redef_test' );
    Error starting at line 1 in command:
    exec dbms_redefinition.can_redef_table( 'USER', 'redef_test' )
    Error report:
    ORA-12090: Kan de tabel "USER"."REDEF_TEST" online niet opnieuw definiëren.
    ORA-06512: in "SYS.DBMS_REDEFINITION", regel 139
    ORA-06512: in "SYS.DBMS_REDEFINITION", regel 1782
    ORA-06512: in regel 1
    12090. 00000 -  "cannot online redefine table \"%s\".\"%s\""
    *Cause:    An attempt was made to online redefine a table that is either a
               clustered table, AQ table, temporary table, IOT overflow table
               or table with FGA/RLS enabled.
    *Action:   Do not attempt to online redefine a table that is  a
               clustered table, AQ table, temporary table, IOT overflow table
               or table with FGA/RLS enabled.Also came across ORA-42040 on the internet while searching for a solution:
    ORA-42040     cannot online redefine table "string"."string" with column of binary XML type
    Cause:     Do not attempt to online redefine a table with a column of binary XML type.
    Action:     An attempt was made to redefine a table with a column of binary XML type.
    Why this limitation to binary xml? I was under the impression that binary xml was put forward by oracle as the 'format of the future'; yet an important feature as online redefinition cannot be used anymore it seems.
    My reason for this question: I have a table that should have been partitioned (based on a virtual column derived from an xpath in the xml column) but isn't at this moment. I'm trying to use online redefinition to partition the existing table, but all the suggested ways of doing this don't seem to work.
    Another thing i tried was a 'CTAS', but those seem to have problems with virtual columns.
    CREATE TABLE d_new (
        id,
        xml,
        PRIMARY KEY (id)
    XMLTYPE COLUMN xml STORE AS SECUREFILE BINARY XML
    VIRTUAL COLUMNS
        timestamp AS (TO_TIMESTAMP(extractvalue(xml,'/e:d/c:dHeader/c:creationTime',
            'xmlns:e="http://www.example.com/myproject/schema/e/nl"
             xmlns:c="http://www.example.com/myunidoc/schema/common"'),'YYYY-MM-DD"T"HH24:MI:SS'))
    PARTITION BY RANGE (timestamp)
        PARTITION p2010_09 VALUES LESS THAN (TO_DATE('1-10-2010','DD-MM-YYYY')),
        PARTITION p2012_05 VALUES LESS THAN (TO_DATE('1-6-2012','DD-MM-YYYY')),
        PARTITION px VALUES LESS THAN (MAXVALUE)
    as
    select id,xml from d_table;
    Error at Command Line:40 Column:19
    Error report:
    SQL Error: ORA-54014: De resultatentabel van een CTAS-bewerking bevat een of meer virtuele kolommen.

    I would have tested it myself but my current version (11.2.0.3) has a bug regarding virtual columns...
    One thing you can try is :
    1) Create your new empty partitioned table (D_NEW) with only one partition
    2) Perform an ALTER TABLE EXCHANGE PARTITION between old and new tables
    3) Drop old table
    4) SPLIT PARTITIONs on the new table

  • Cannot display complete document in binary XML XMLType column

    I've been trying to get a query to work that will display the complete XML document stored in a column of XMLType, binary XML storage.
    <b/>
    I"m using Toad 10.6.1.3.
    <b/>
    I'm running Oracle client:
    {code}Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE 11.1.0.7.0 Production
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production{code}
    <b/>
    The table is defined:
    {code}CREATE TABLE AUDITED_EVENT_XML_MIN (
    AUDITED_EVENT_XML_PK_ID NUMBER(10) PRIMARY KEY,
    /* The time the audit record was created. */
    CREATED_TIME TIMESTAMP(6) WITH LOCAL TIME ZONE NOT NULL,
    /* Well-formed XML message */
    XML_EVENT_CONTENT XMLType
    XMLTYPE COLUMN "XML_EVENT_CONTENT" STORE AS BINARY XML;
    {code}
    <b/>
    The XML has no namespace. The SQL that I tried is:
    {code}select e.xml_event_content.extract('/') from AUDITED_EVENT_XML e;{code}
    <b/>
    I also tried a simpler approach.
    {code}select * from AUDITED_EVENT_XML e;{code}
    <b/>
    and got this error:
    {code}ORA-21500: internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]{code}
    <b/>
    I'm a newbie; I'm sure there is a simple way to do this; but I can't find it in the Oracle XML DB Developers Guide.
    It would also be helpful to know how to do this for documents that have a declared namespace (without a xsd schema)...
    Thanks in advance...
    Edited by: flyeagle5683 on Sep 4, 2012 3:18 PM

    When ran from the Command window in PL/SQL Developer
    Connected to Oracle Database 11g Enterprise Edition Release 11.1.0.6.0
    SQL>
    SQL> CREATE TABLE AUDITED_EVENT_XML_MIN (
      2      AUDITED_EVENT_XML_PK_ID NUMBER(10) PRIMARY KEY,
      3      /* The time the audit record was created. */
      4      CREATED_TIME TIMESTAMP(6) WITH LOCAL TIME ZONE NOT NULL,
      5      /* Well-formed XML message */
      6      XML_EVENT_CONTENT XMLType
      7      )
      8      XMLTYPE COLUMN "XML_EVENT_CONTENT" STORE AS BINARY XML;
    Table created
    SQL> insert into audited_event_xml_min values (1, systimestamp, xmltype('<root><child1>Val1</child1></root>'));
    1 row inserted
    SQL> commit;
    Commit complete
    SQL> select * from AUDITED_EVENT_XML_MIN e;
    AUDITED_EVENT_XML_PK_ID CREATED_TIME                                      XML_EVENT_CONTENT
                          1 05-SEP-12 09.24.36.546435 AM                      <root>
                                                                                <child1>Val1</child1>
                                                                              </root>
    SQL> select e.xml_event_content.extract('/') from AUDITED_EVENT_XML_MIN e;
    E.XML_EVENT_CONTENT.EXTRACT('/
    <root>
      <child1>Val1</child1>
    </root>
    SQL> I also ran the two SELECT statements from SQL*Plus, (11.2.0.3 32-bit Instant Client) and received the exact same results.
    I'm guessing your version of Toad (or something between it and the DB) does not like XMLType data types being returned.
    Try
    select e.xml_event_content.extract('/').getStringVal() from AUDITED_EVENT_XML_MIN e;or .getClobVal() if the XML is large and see what happens.

  • [11g] XML Schema full validation with binary XML ?

    Hi,
    Oracle's doc quotes " Loading XML data into XML schema-based binary XML storage causes full validation against the target XML schemas. ".
    After registering this XML Schema which indicates that a company must have at least a code, name and pilotes element :
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xdb="http://xmlns.oracle.com/xdb"
    xdb:storeVarrayAsTable="true" version="1.0">
    <xsd:element name="compagnie" type="compagnieType"/>
    <xsd:complexType name="compagnieType">
    <xsd:sequence>
    <xsd:element name="comp" type="compType" minOccurs="1" xdb:SQLName="COMP"/>
    <xsd:element name="pilotes" type="pilotesType" minOccurs="1" xdb:SQLName="PILOTES"/>
    <xsd:element name="nomComp" type="nomCompType" minOccurs="1" xdb:SQLName="NOMCOMP"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="pilotesType">
    <xsd:sequence>
    <xsd:element minOccurs="1" maxOccurs="unbounded"
    name="pilote" type="piloteType" xdb:SQLName="PILOTE"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="piloteType">
    <xsd:sequence>
    <xsd:element name="nom" type="nomType" xdb:SQLName="NOM"/>
    <xsd:element name="salaire" type="salaireType" minOccurs="0"
         xdb:SQLName="SALAIRE"/>
    </xsd:sequence>
    <xsd:attribute name="brevet" xdb:SQLName="BREVET">
    <xsd:simpleType>
    <xsd:restriction base="xsd:string">
    <xsd:minLength value="1"/>
    <xsd:maxLength value="4"/>
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:attribute>
    </xsd:complexType>
    I can therefore insert a row no valid into this table
    CREATE TABLE compagnie_binaryXML_grammaire OF XMLType
    XMLTYPE STORE AS BINARY XML
    XMLSCHEMA "http://www.soutou.net/compagnies3.xsd"
    ELEMENT "compagnie"
    ALLOW NONSCHEMA
    VIRTUAL COLUMNS (vircolcomp AS (EXTRACTVALUE(OBJECT_VALUE,'/compagnie/comp')));
    SQL> INSERT INTO compagnie_binaryXML_grammaire VALUES
    2 (XMLTYPE.CREATEXML('<?xml version="1.0" encoding="ISO-8859-1"?>
    3 <compagnie>
    4 <pilotes></pilotes>
    5 <nomComp>No pilot and no comp!</nomComp>
    6 </compagnie>').CREATESCHEMABASEDXML('http://www.soutou.net/compagnies3.xsd'
    1 ligne crÚÚe.
    Unless the following instruction is done, no valid XML file can be added.
    ALTER TABLE compagnie_binaryXML_grammaire
         ADD CONSTRAINT valide_compagniebinaryXML
         CHECK (XMLIsValid(OBJECT_VALUE) = 1);
    Where is the difference between the behaviour of an object-relational table ?

    My guess is that the virtual column spoils the soup (could you check).
    The following works for me on 11.1.0.6.0.
    connect / as sysdba
    drop user test cascade;
    create user test identified by test;
    grant xdbadmin, dba to test;
    connect test/test
    spool encoding_test01.txt
    var schemaPath varchar2(256)
    var schemaURL  varchar2(256)
    set long 100000000
    col SCHEMA_URL FOR a60
    col object_name for a50
    select * from v$version;
    purge recyclebin;
    alter session set recyclebin=OFF;
    drop table VALIDATE_XML_SCHEMA;
    prompt  Create Folder for TEST schema, user
    declare
       retb boolean;
    begin
      retb := dbms_xdb.createfolder('/test');
    end;
    prompt  =================================================================
    prompt  Register Relational XML SChema
    prompt  =================================================================
    prompt  XML SChema
    begin
      :schemaURL  := 'http://www.relational.com/root.xsd';
      :schemaPath := '/test/root_relational.xsd';
    end;
    prompt  Cleaning up
    call  DBMS_XMLSCHEMA.deleteSchema(:schemaURL,4);
    commit;
    prompt  XSD Schema
    declare
      res boolean;
      xmlSchema xmlType := xmlType(
    '<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:xdb="http://xmlns.oracle.com/xdb"
                xmlns="http://www.relational.com/root.xsd" targetNamespace="http://www.relational.com/root.xsd"
                elementFormDefault="qualified"
                attributeFormDefault="unqualified"
                xdb:storeVarrayAsTable="true">
         <xs:element name="ROOT" xdb:defaultTable="ROOT_TABLE" xdb:maintainDOM="false">
              <xs:annotation>
                   <xs:documentation>Example XML Schema</xs:documentation>
              </xs:annotation>
              <xs:complexType xdb:maintainDOM="false">
                   <xs:sequence>
                        <xs:element name="ID" type="xs:integer" xdb:SQLName="ID"/>
                        <xs:element ref="INFO"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="INFO" xdb:SQLName="INFO_TYPE">
              <xs:complexType xdb:maintainDOM="false">
                   <xs:sequence>
                        <xs:element name="INFO_ID" type="xs:integer" xdb:SQLName="TYPE_INFO_ID"/>
                        <xs:element name="INFO_CONTENT"
                    xdb:SQLName="TYPE_INFO_CONTENT" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
    </xs:schema>');
    begin
    if (dbms_xdb.existsResource(:schemaPath)) then
        dbms_xdb.deleteResource(:schemaPath);
    end if;
    res := dbms_xdb.createResource(:schemaPath,xmlSchema);
    end;
    alter session set events='31098 trace name context forever';
    BEGIN
      DBMS_XMLSCHEMA.registerSchema
      (SCHEMAURL => :schemaURL,
      SCHEMADOC => xdbURIType(:schemaPath).getClob(),
      LOCAL     => TRUE,   -- local
      GENTYPES  => FALSE,  -- generate object types
      GENBEAN   => FALSE,  -- no java beans
      GENTABLES => FALSE,  -- generate object tables
      OWNER     => USER);
    END;
    commit;
    prompt  =================================================================
    prompt  Register Binary XML SChema
    prompt  =================================================================
    prompt  XML SChema
    begin
      :schemaURL  := 'http://www.binary.com/root.xsd';
      :schemaPath := '/test/root_binary.xsd';
    end;
    prompt  Cleaning up
    call  DBMS_XMLSCHEMA.deleteSchema(:schemaURL,4);
    commit;
    prompt  XSD Schema
    declare
      res boolean;
      xmlSchema xmlType := xmlType(
    '<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:xdb="http://xmlns.oracle.com/xdb"
                xmlns="http://www.binary.com/root.xsd" targetNamespace="http://www.binary.com/root.xsd"
                elementFormDefault="qualified"
                attributeFormDefault="unqualified"
                xdb:storeVarrayAsTable="true">
         <xs:element name="ROOT" xdb:defaultTable="ROOT_TABLE" xdb:maintainDOM="false">
              <xs:annotation>
                   <xs:documentation>Example XML Schema</xs:documentation>
              </xs:annotation>
              <xs:complexType xdb:maintainDOM="false">
                   <xs:sequence>
                        <xs:element name="ID" type="xs:integer" xdb:SQLName="ID"/>
                        <xs:element ref="INFO"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="INFO" xdb:SQLName="INFO_TYPE">
              <xs:complexType xdb:maintainDOM="false">
                   <xs:sequence>
                        <xs:element name="INFO_ID" type="xs:integer" xdb:SQLName="TYPE_INFO_ID"/>
                        <xs:element name="INFO_CONTENT"
                    xdb:SQLName="TYPE_INFO_CONTENT" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
    </xs:schema>');
    begin
    if (dbms_xdb.existsResource(:schemaPath)) then
        dbms_xdb.deleteResource(:schemaPath);
    end if;
    res := dbms_xdb.createResource(:schemaPath,xmlSchema);
    end;
    alter session set events='31098 trace name context forever';
    BEGIN
      DBMS_XMLSCHEMA.registerSchema
      (SCHEMAURL => :schemaURL,
      SCHEMADOC => xdbURIType(:schemaPath).getClob(),
      LOCAL     => TRUE,   -- local
      GENTYPES  => FALSE,  -- generate object types
      GENBEAN   => FALSE,  -- no java beans
      GENTABLES => FALSE,  -- generate object tables
      OPTIONS   => DBMS_XMLSCHEMA.REGISTER_BINARYXML,
      OWNER     => USER);
    END;
    commit;
    prompt  =================================================================
    prompt  Register SECOND Binary XML SChema
    prompt  =================================================================
    prompt  XML SChema
    begin
      :schemaURL  := 'http://www.different.com/roots.xsd';
      :schemaPath := '/test/roots.xsd';
    end;
    prompt  Cleaning up
    call  DBMS_XMLSCHEMA.deleteSchema(:schemaURL,4);
    commit;
    prompt  XSD Schema
    declare
      res boolean;
      xmlSchema xmlType := xmlType(
    '<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:xdb="http://xmlns.oracle.com/xdb"
                xmlns="http://www.different.com/roots.xsd" targetNamespace="http://www.different.com/roots.xsd"
                elementFormDefault="qualified"
                attributeFormDefault="unqualified"
                xdb:storeVarrayAsTable="true">
         <xs:element name="ROOTS" xdb:maintainDOM="false">
              <xs:annotation>
                   <xs:documentation>Example XML Schema</xs:documentation>
              </xs:annotation>
              <xs:complexType xdb:maintainDOM="false">
                   <xs:sequence>
                        <xs:element name="ID" type="xs:integer" xdb:SQLName="ID"/>
                        <xs:element ref="INFO"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="INFO" xdb:SQLName="INFO_TYPE">
              <xs:complexType xdb:maintainDOM="false">
                   <xs:sequence>
                        <xs:element name="INFO_ID" type="xs:integer" xdb:SQLName="TYPE_INFO_ID"/>
                        <xs:element name="INFO_CONTENT"
                    xdb:SQLName="TYPE_INFO_CONTENT" type="xs:string"/>
                   </xs:sequence>          </xs:complexType>
         </xs:element>
    </xs:schema>');
    begin
    if (dbms_xdb.existsResource(:schemaPath)) then
        dbms_xdb.deleteResource(:schemaPath);
    end if;
    res := dbms_xdb.createResource(:schemaPath,xmlSchema);
    end;
    alter session set events='31098 trace name context forever';
    BEGIN
      DBMS_XMLSCHEMA.registerSchema
      (SCHEMAURL => :schemaURL,
      SCHEMADOC => xdbURIType(:schemaPath).getClob(),
      LOCAL     => TRUE,   -- local
      GENTYPES  => FALSE,  -- generate object types
      GENBEAN   => FALSE,  -- no java beans
      GENTABLES => FALSE,  -- generate object tables
      OPTIONS   => DBMS_XMLSCHEMA.REGISTER_BINARYXML,
      OWNER     => USER);
    END;
    commit;
    prompt  =================================================================
    prompt  END Registration Process
    prompt  =================================================================
    select xmlType(xdbURIType ('/test/root.xsd').getClob())
    from   dual;
    alter session set events='31098 trace name context forever';
    select schema_url, binary
    from   user_xml_schemas;
    select * from tab;
    select object_name, object_type from user_objects;
    prompt  =================================================================
    prompt  BASICFILE - XMLSCHEMA (default) - DISALLOW NONSCHEMA
    prompt  =================================================================
    drop table "VALIDATE_XML_SCHEMA";
    create table "VALIDATE_XML_SCHEMA" of XMLTYPE
    XMLTYPE STORE AS BASICFILE BINARY XML
    XMLSCHEMA "http://www.binary.com/root.xsd"
      ELEMENT "ROOT";
    prompt  No schema defined
    insert into "VALIDATE_XML_SCHEMA"
    values
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <ROOT>
      <ID>0</ID>
      <INFO>
        <INFO_ID>0</INFO_ID>
        <INFO_CONTENT>Text</INFO_CONTENT>
      </INFO>
    </ROOT>'))
    prompt  Bogus, noexistent schema defined
    insert into "VALIDATE_XML_SCHEMA"
    values
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <ROOT xmlns="http://www.bogus.com/root.xsd">
      <ID>0</ID>
      <INFO>
        <INFO_ID>0</INFO_ID>
        <INFO_CONTENT>Text</INFO_CONTENT>
      </INFO>
    </ROOT>'))
    prompt  Binary schema defined
    insert into "VALIDATE_XML_SCHEMA"
    values
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <ROOT xmlns="http://www.binary.com/root.xsd">
      <ID>0</ID>
      <INFO>
        <INFO_ID>0</INFO_ID>
        <INFO_CONTENT>Text</INFO_CONTENT>
      </INFO>
    </ROOT>'))
    prompt  Binary schema with different location path
    insert into "VALIDATE_XML_SCHEMA"
    values
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <ROOTS xmlns="http://www.different.com/roots.xsd">
      <ID>0</ID>
      <INFO>
        <INFO_ID>0</INFO_ID>
        <INFO_CONTENT>Text</INFO_CONTENT>
      </INFO>
    </ROOTS>'))
    prompt  Binary schema with incorrect "root(s)"
    insert into "VALIDATE_XML_SCHEMA"
    values
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <ROOT xmlns="http://www.different.com/roots.xsd">
      <ID>0</ID>
      <INFO>
        <INFO_ID>0</INFO_ID>
        <INFO_CONTENT>Text</INFO_CONTENT>
      </INFO>
    </ROOT>'))
    prompt  Relational registered schema
    insert into "VALIDATE_XML_SCHEMA"
    values
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <ROOT xmlns="http://www.relational.com/root.xsd">
      <ID>0</ID>
      <INFO>
        <INFO_ID>0</INFO_ID>
        <INFO_CONTENT>Text</INFO_CONTENT>
      </INFO>
    </ROOT>'))
    prompt  =================================================================
    prompt  BASICFILE - XMLSCHEMA - ALLOW NONSCHEMA
    prompt  =================================================================
    drop table "VALIDATE_XML_SCHEMA";
    create table "VALIDATE_XML_SCHEMA" of XMLTYPE
    XMLTYPE STORE AS BASICFILE BINARY XML
    XMLSCHEMA "http://www.binary.com/root.xsd"
      ELEMENT "ROOT"
    ALLOW NONSCHEMA;
    prompt  No schema defined
    insert into "VALIDATE_XML_SCHEMA"
    values
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <ROOT>
      <ID>0</ID>
      <INFO>
        <INFO_ID>0</INFO_ID>
        <INFO_CONTENT>Text</INFO_CONTENT>
      </INFO>
    </ROOT>'))
    prompt  Bogus, noexistent schema defined
    insert into "VALIDATE_XML_SCHEMA"
    values
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <ROOT xmlns="http://www.bogus.com/root.xsd">
      <ID>0</ID>
      <INFO>
        <INFO_ID>0</INFO_ID>
        <INFO_CONTENT>Text</INFO_CONTENT>
      </INFO>
    </ROOT>'))
    prompt  Binary schema defined
    insert into "VALIDATE_XML_SCHEMA"
    values
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <ROOT xmlns="http://www.binary.com/root.xsd">
      <ID>0</ID>
      <INFO>
        <INFO_ID>0</INFO_ID>
        <INFO_CONTENT>Text</INFO_CONTENT>
      </INFO>
    </ROOT>'))
    prompt  Binary schema with different location path
    insert into "VALIDATE_XML_SCHEMA"
    values
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <ROOTS xmlns="http://www.different.com/roots.xsd">
      <ID>0</ID>
      <INFO>
        <INFO_ID>0</INFO_ID>
        <INFO_CONTENT>Text</INFO_CONTENT>
      </INFO>
    </ROOTS>'))
    prompt  Binary schema with incorrect "root(s)"
    insert into "VALIDATE_XML_SCHEMA"
    values
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <ROOT xmlns="http://www.different.com/roots.xsd">
      <ID>0</ID>
      <INFO>
        <INFO_ID>0</INFO_ID>
        <INFO_CONTENT>Text</INFO_CONTENT>
      </INFO>
    </ROOT>'))
    prompt  Relational registered schema
    insert into "VALIDATE_XML_SCHEMA"
    values
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <ROOT xmlns="http://www.relational.com/root.xsd">
      <ID>0</ID>
      <INFO>
        <INFO_ID>0</INFO_ID>
        <INFO_CONTENT>Text</INFO_CONTENT>
      </INFO>
    </ROOT>'))
    -- Output
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE     11.1.0.6.0     Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    5 rows selected.
    Recyclebin purged.
    Session altered.
    drop table VALIDATE_XML_SCHEMA
    ERROR at line 1:
    ORA-00942: table or view does not exist
    Create Folder for TEST schema, user
    declare
    ERROR at line 1:
    ORA-31003: Parent / already contains child entry test
    ORA-06512: at "XDB.DBMS_XDB", line 316
    ORA-06512: at line 4
    =================================================================
    Register Relational XML SChema
    =================================================================
    XML SChema
    PL/SQL procedure successfully completed.
    Cleaning up
    call  DBMS_XMLSCHEMA.deleteSchema(:schemaURL,4)
    ERROR at line 1:
    ORA-31000: Resource 'http://www.relational.com/root.xsd' is not an XDB schema document
    ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 106
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 102
    ORA-06512: at line 1
    Commit complete.
    XSD Schema
    PL/SQL procedure successfully completed.
    Session altered.
    PL/SQL procedure successfully completed.
    Commit complete.
    =================================================================
    Register Binary XML SChema
    =================================================================
    XML SChema
    PL/SQL procedure successfully completed.
    Cleaning up
    call  DBMS_XMLSCHEMA.deleteSchema(:schemaURL,4)
    ERROR at line 1:
    ORA-31000: Resource 'http://www.binary.com/root.xsd' is not an XDB schema document
    ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 106
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 102
    ORA-06512: at line 1
    Commit complete.
    XSD Schema
    PL/SQL procedure successfully completed.
    Session altered.
    PL/SQL procedure successfully completed.
    Commit complete.
    =================================================================
    Register SECOND Binary XML SChema
    =================================================================
    XML SChema
    PL/SQL procedure successfully completed.
    Cleaning up
    call  DBMS_XMLSCHEMA.deleteSchema(:schemaURL,4)
    ERROR at line 1:
    ORA-31000: Resource 'http://www.different.com/roots.xsd' is not an XDB schema document
    ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 106
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 102
    ORA-06512: at line 1
    Commit complete.
    XSD Schema
    PL/SQL procedure successfully completed.
    Session altered.
    PL/SQL procedure successfully completed.
    Commit complete.
    =================================================================
    END Registration Process
    =================================================================
    Session altered.
    SCHEMA_URL                                                   BIN
    http://www.relational.com/root.xsd                           NO
    http://www.binary.com/root.xsd                               YES
    http://www.different.com/roots.xsd                           YES
    3 rows selected.
    no rows selected
    no rows selected
    =================================================================
    BASICFILE - XMLSCHEMA (default) - DISALLOW NONSCHEMA
    =================================================================
    drop table "VALIDATE_XML_SCHEMA"
    ERROR at line 1:
    ORA-00942: table or view does not exist
    Table created.
    No schema defined
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    ERROR at line 3:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LSX-00021: undefined element "ROOT"
    Bogus, noexistent schema defined
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    ERROR at line 3:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LSX-00023: unknown namespace URI "http://www.bogus.com/root.xsd"
    Binary schema defined
    1 row created.
    Binary schema with different location path
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    ERROR at line 3:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LSX-00023: unknown namespace URI "http://www.different.com/roots.xsd"
    Binary schema with incorrect "root(s)"
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    ERROR at line 3:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LSX-00023: unknown namespace URI "http://www.different.com/roots.xsd"
    Relational registered schema
    (xmltype('<?xml version="1.0" encoding="UTF-8"?>
    ERROR at line 3:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LSX-00023: unknown namespace URI "http://www.relational.com/root.xsd"
    =================================================================
    BASICFILE - XMLSCHEMA - ALLOW NONSCHEMA
    =================================================================
    Table dropped.
    Table created.
    No schema defined
    1 row created.
    Bogus, noexistent schema defined
    1 row created.
    Binary schema defined
    1 row created.
    Binary schema with different location path
    1 row created.
    Binary schema with incorrect "root(s)"
    1 row created.
    Relational registered schema
    1 row created.

  • Range partitioning on virtual column based on binary xmltype column

    Alright, our DBA finally got around to upgrading to 11.2.0.2. Now I'm running into another issue:
    CREATE TABLE USER.DI_D2
        ID NUMBER(19, 0) NOT NULL ,
        XML SYS.XMLTYPE ,
        PRIMARY KEY ( ID )
      XMLTYPE XML STORE AS SECUREFILE BINARY XML
      VIRTUAL COLUMNS
        ts AS (TO_TIMESTAMP(extractvalue(xml,'/d:d/c:dHeader/c:creationTime',
            'xmlns:d="http://www.example.com/m/d/schema/di"
             xmlns:c="http://www.example.com/m/schema/common"'),'YYYY-MM-DD"T"HH24:MI:SS'))
      PARTITION BY RANGE (ts)
        PARTITION d_p2012_07 VALUES LESS THAN (TO_DATE('1-8-2012','DD-MM-YYYY')),
        PARTITION d_px VALUES LESS THAN (MAXVALUE)
      );On our old 11.2.0.1 install this command works fine (tho due to other issues 11.2.0.1 doesn't work for our search queries)
    On our 11.2.0.2 install, I get the following error:
    Error at Command Line:10 Column:37
    Error report:
    SQL Error: ORA-14513: Partitiekolom mag niet van het gegevenstype object zijn.
    14513. 00000 -  "partitioning column may not be of object datatype"
    *Cause:    Partitioning column specified by the user was an object datatype
               (object, REF, nested table, array) which is illegal.
    *Action:   Ensure that no partitioning column is an object datatype.Anyone know what's up with that? What changed between the 2 DB versions that could cause this to fail?

    Alright, seems that's just a display issue then.
    Looking in user_lobs like suggested above gives
    TABLE_NAME COLUMN_NAME SECUREFILE
    DI_D       XMLDATA     YES        I was opening the table in SQL Developer and then looking in the tab SQL (12th tab); with a XmlType table it seems to always show Basicfile even if it's actually a Securefile.
    I'd like to use the suggested xmlcast/xmlquery solution, however it doesn't seem to play well with our custom timestamp format.
    "CREATION_TIME" AS (XMLCAST(XMLQUERY('declare default element namespace "http://www.example.com/m/d/schema/i";declare namespace c="http://www.example.com/m/schema/common";/d/c:dHeader/c:creationTime' PASSING OBJECT_VALUE RETURNING CONTENT) AS TIMESTAMP))
    Error at Command Line:1 Column:0
    Error report:
    SQL Error: ORA-54002: In de uitdrukking van een virtuele kolom kunnen alleen zuivere functies worden opgegeven.
    "CREATION_TIME" AS (TO_TIMESTAMP(XMLQUERY('declare default element namespace "http://www.example.com/m/d/schema/i";declare namespace c="http://www.example.com/m/schema/common";/d/c:dHeader/c:creationTime' PASSING OBJECT_VALUE RETURNING CONTENT),'YYYY-MM-DD"T"HH24:MI:SS'))
    Error at Command Line:9 Column:45
    Error report:
    SQL Error: ORA-00932: inconsistente gegevenstypen: - verwacht, - gekregen
    00932. 00000 -  "inconsistent datatypes: expected %s got %s"
    *Cause:   
    *Action:
    "CREATION_TIME" AS (TO_TIMESTAMP(EXTRACTVALUE("OBJECT_VALUE",'/di:d/c:dHeader/c:creationTime','xmlns:di="http://www.example.com/m/d/schema/i" xmlns:c="http://www.example.com/m/schema/common"'),'YYYY-MM-DD"T"HH24:MI:SS'))
    table "USER"."DI_D" created.

  • Issues faced with XML (Objt-Rel) - Plan to move to Binary XML (schema-less)

    Hi All,
    Our Production DB has Oracle XMLDB implementation using 9 XMLDB Object-Relational
    Tables. These have been implemented almost since a year, and we faced several issues,
    have listed some of the most important ones:
    Obviously it is Object-Relational implementation, so we have 4-5 XSDs to start with that
    support the Object-Relational schema
    1) copyEvolve Issues : Due to changing Business Requirements constantly, we had to constantly
    and continuously modify/upgrade XSDs and then use "copyEvolve" to apply new XSDs
    Encountered several issues with CopyEvolve
    2) "Home-grown" solution to evolve XSD/Schema:
    We came up with our own Solution to migrate/evolve XSD schema.
    a) Backup all data from 9 XML DB Tables to 9 CLOB Tables (data is thus "dereferenced" and "delinked"
    from underlying XSDs
    b) Since data is backed up to CLOB Tables, go ahead and drop the entire schema and register
    new XSDs and recreate Tables. (GRANTS and PUBLIC SYNONYMS reappled, needless to say)
    c) Reload data from backed up CLOB Tables to newly created XMLDB (Obj-Relational) Tables
    Above approach (without "copyEvolve") has worked fine so far and helped in each Release/ every migration
    With our data sets becoming increasingly huge, downtime is not sufficient to follow this successful, home-grown
    approach and as a result we would like to get away from Object-Relational XMLDB Tables altogether.
    3) Our Application currently uses XPath heavily on all 9 XMLDB Tables and we understand XPath is already
    deprecated by Oracle (as of 11.2.0.2)
    We are seriously considering doing the following:
    1) Migrate all 9 XMLDB Tables and modify underlying Storage from "Object-Relational" to Binary XML (Schema-less)
    2) Modify Appln code with all XPath replaced by corresponding XQuery constructs
    3) Replace existing "B-TREE" based Indexes in Object-Relational XMLDB Tables with either a) Indexes on Virtual DB Columns to enforce Primary Key and Unique Constraints and b) XMLIndex on all other Non-Unique Columns instead of
    the corresponding "B-TREE" based Indexes
    What we hope to achieve with the above:
    1) Eliminate XSD Usage completely (and copyEvolve nightmares thereby)
    2) Eliminate Usage of XPath totally
    3) Better Performance overall :-)
    Would like to get some advice and feedback on our Proposed Plan and mainly are we taking the
    right direction especially in respect of Performance, Point 3) listed above
    Any feedback or tips would be truly appreciated
    Regards and Thanks
    Auro

    WRT to XPATH Vs XQuery.
    1. XPATH is a subset of XQuery.. Any XPATH expression is, by definition, an example of simple XQuery expression, so XPATH is not depricated.
    2. What we are depricateing are the older, oracle specific XML operators (EXTRACT(), EXTRACTVALUE(), EXISTSNODE()), that ONLY support XPATH. We are depricating these in favour of the new SQL/XML operators (XMLTABLE, XMLQUERY, XMLEXISTS) defined by the SQL standards committee. These operators provide support for the full XQquery standard, and implicitly all of the XPATH expressions that were supported by the older operators. This menas we strongly recommned that new code, developed to work with 11g make use of nrw newer operators. Personally I cannot see a point where we would ever consider de-supportting the older operators, we are well aware of how much code makes use of them.
    What this means is that any code that is written using the older operators will continue to work, unmodified. However should a bug surface in the use of the older operators, we would strongly recommend that the code in question be migrated to the new operators as part of the remidiation process.
    Also, once the initial pain of learning the new syntax is overcome, I truely believe that the new operators result in much more efficient and mantainable code, so taking the time to do code renevation when possible will probably pay off in the long term...
    WRT to moving away from Schema-Based OR storage, I would look at the kind of changes you have made to the XML Schema. If they are the kind of changes that would be supported by in-place evolution in 11g then you might want to re-consider this. If, on the other hand you are regularly making changes to the XML schema that are not backwardsly compatable with your older XML Schema then Schema-Based binary XML storeage (which is more flexible than Schema-Based Object-Relational storage) or even non-schema based Binary XML may be a better choice for your applicaiton..
    I would experment by registering the oldest version of your XML Schema in 11gR2, and then testing each of the evolutions you have gone through to see if 11GR2 inplace evolution would have managed them. Also, ask yourself do you expect your XML Schema to keep changing so drastically moving forward, or were some of these changes the results of the growing pains associated with learning how to use XML schema effectively. BTW the approach you outline is effectively what CopyEvolve is doing under the covers...
    Bear in mind that for the use-cases Object-Relational storage addesses, when all of the XPATH expressions are correctly re-written into SQL operations on the underlying tables, and where the majority of queries end up accessing or updating leaf-level nodes in the XML, it is unlikely that a Binary XML / Unstructured XML Index combination will deliver similar performance. If you are only accesss a small subset of the leaf-level nodes, creating structured XML Indexes that project out the nodes in question may be able to deliver similar performance to an Object-Relational storage model, but you will need to get the index definitions correct.
    -Mark
    Edited by: mdrake on Mar 7, 2011 7:40 PM

  • ORA-00939 when creating XML table with Virtual Columns

    Getting error on creating table with VIRTUAL COLUMNS:
    Error at Command Line:4 Column:31
    Error report:
    SQL Error: ORA-00939: too many arguments for function
    00939. 00000 - "too many arguments for function"
    Without VIRTUAL COLUMNS works fine.
    Where to start?
    Is it possible to add Virtual Columns after a table is created?
    CREATE TABLE TDS_XML OF XMLType
    XMLSCHEMA "http://xmlns.abc.com/tds/TDSSchemaGen2.xsd"
    ELEMENT "TDSTestData"
      VIRTUAL COLUMNS
      TESTID AS (
        XMLCast(
                  XMLQuery('declare default element namespace "http://xmlns.abc.com/tds/TDSSchemaGen2.xsd"; /TDSTestData/TestID' PASSING OBJECT_VALUE RETURNING CONTENT)  AS VARCHAR2(32)
       )SQL*Plus: Release 11.2.0.2.0 Production on Mon Apr 30 20:17:29 2012
    Copyright (c) 1982, 2010, Oracle. All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> select * from v$version;
    BANNER
    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 64-bit Windows: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    SQL>

    victor_shostak wrote:
    Figured, Virtual Columns work only for Binary XML.They are only supported, currently, for Binary XML.

  • Unable to create binary xmltype table

    HI Gentlemen,
    As I have serious difficulties with O-R storage, I now tried to create my ebm table in binary storage. The schemas were registered, no SQL-annotations at all.
    When I try to create the table, I always get an error message (see below). Does anybody know how to circumvent this?
    Thanks, regards
    Miklos HERBOLY
    SQL> @showkbvschemas
    SQL> /*
    SQL>   showKbvSchemas.sql
    SQL> */
    SQL> select any_path from resource_view where any_path like '%GKSADMIN%'
      2  /
    ANY_PATH                                                                       
    /sys/schemas/GKSADMIN                                                          
    /sys/schemas/GKSADMIN/EBM                                                      
    /sys/schemas/GKSADMIN/EBM/datentypen_V1.40.xsd                                 
    /sys/schemas/GKSADMIN/EBM/ehd_header_V1.40.xsd                                 
    /sys/schemas/GKSADMIN/EBM/ehd_root_V1.40.xsd                                   
    /sys/schemas/GKSADMIN/EBM/go_body_V1.30.xsd                                    
    /sys/schemas/GKSADMIN/EBM/go_header_V1.30.xsd                                  
    /sys/schemas/GKSADMIN/EBM/go_root_V1.30.xsd                                    
    /sys/schemas/GKSADMIN/EBM/keytabs_V1.40.xsd                                    
    17 Zeilen ausgewählt.
    SQL> /* eof */And now let us try to create the table:
    SQL> @crbinebm
    SQL> /* createBinaryEbmTable.sql */
    SQL> drop table ebm
      2  /
    drop table ebm
    FEHLER in Zeile 1:
    ORA-00942: Tabelle oder View nicht vorhanden
    SQL> CREATE TABLE ebm OF XMLType
      2    XMLTYPE STORE AS BINARY XML
      3    XMLSCHEMA          "EBM/go_root_V1.30.xsd"
      4    ELEMENT               "ehd"
      5    VIRTUAL COLUMNS
      6        (KV_COL AS (XMLCast(XMLQuery('xquery version "1.0"; (: :)
      7         declare namespace ehd="urn:ehd/001"; (: :)
      8         /ehd:ehd/ehd:header/ehd:provider/ehd:organization/ehd:id/@EX'
      9         PASSING OBJECT_VALUE RETURNING CONTENT)
    10         AS number)))
    11    PARTITION BY LIST (kv_COL)
    12        (
    13        PARTITION kv_Schleswig_Holstein VALUES ('01'),
    14        PARTITION kv_Hamburg VALUES ('02'),
    15        PARTITION kv_Bremen VALUES ('03'),
    16        PARTITION kv_Niedersachsen VALUES ('17'),
    17        PARTITION kv_Westfalen_Lippe VALUES ('20'),
    18        PARTITION kv_Nordrhein VALUES ('38'),
    19        PARTITION kv_Hessen VALUES ('46'),
    20        PARTITION kv_Rheinland_Pfalz VALUES ('51'),
    21        PARTITION kv_Baden_Wuerttemberg VALUES ('52'),
    22        PARTITION kv_Bayerns VALUES ('71'),
    23        PARTITION kv_Berlin VALUES ('72'),
    24        PARTITION kv_Saarland VALUES ('73'),
    25        PARTITION kbv VALUES ('74'),
    26        PARTITION kv_Mecklenburg_Vorpommern VALUES ('78'),
    27        PARTITION kv_Brandenburg VALUES ('83'),
    28        PARTITION kv_Sachsen_Anhalt VALUES ('88'),
    29        PARTITION kv_Thueringen VALUES ('93'),
    30        PARTITION kv_Sachsen VALUES ('98')
    31        )
    32  /
      XMLTYPE STORE AS BINARY XML
    FEHLER in Zeile 2:
    ORA-06502: PL/SQL: numerischer oder Wertefehler: Zeichenfolgenpuffer zu klein
    ORA-06512: in "XDB.DBMS_XDBUTIL_INT", Zeile 993
    SQL> /* EOF */
    SQL> spool offJust for your information, my table creation as pure relational, with one xmltype column based on the ebm schemas, was successful.

    HI Marco,
    Thank you very much. Yes, binary schema registration was OK. Then I visited the link you supplied and set up a createBinaryEbmTable script accordingly. Here are the results:
    SQL> @createBinaryEbmTable
    SQL> /* createBinaryEbmTable.sql */
    SQL> drop table ebm
      2  /
    Tabelle wurde gelöscht.
    SQL> CREATE TABLE ebm (
      2    kv               CHAR(2),
      3    xml_document          XMLType)
      4    SEGMENT CREATION IMMEDIATE
      5    NOCOMPRESS NOLOGGING
      6    TABLESPACE USERS
      7    XMLTYPE COLUMN xml_document STORE AS SECUREFILE BINARY XML
      8   (TABLESPACE USERS NOCOMPRESS  KEEP_DUPLICATES)
      9    XMLSCHEMA          "EBM/go_root_V1.30.xsd"
    10    ELEMENT               "ehd"
    11    PARTITION BY LIST (kv)
    12        (
    13        PARTITION kv_Schleswig_Holstein VALUES ('01'),
    14        PARTITION kv_Hamburg VALUES ('02'),
    15        PARTITION kv_Bremen VALUES ('03'),
    16        PARTITION kv_Niedersachsen VALUES ('17'),
    17        PARTITION kv_Westfalen_Lippe VALUES ('20'),
    18        PARTITION kv_Nordrhein VALUES ('38'),
    19        PARTITION kv_Hessen VALUES ('46'),
    20        PARTITION kv_Rheinland_Pfalz VALUES ('51'),
    21        PARTITION kv_Baden_Wuerttemberg VALUES ('52'),
    22        PARTITION kv_Bayerns VALUES ('71'),
    23        PARTITION kv_Berlin VALUES ('72'),
    24        PARTITION kv_Saarland VALUES ('73'),
    25        PARTITION kbv VALUES ('74'),
    26        PARTITION kv_Mecklenburg_Vorpommern VALUES ('78'),
    27        PARTITION kv_Brandenburg VALUES ('83'),
    28        PARTITION kv_Sachsen_Anhalt VALUES ('88'),
    29        PARTITION kv_Thueringen VALUES ('93'),
    30        PARTITION kv_Sachsen VALUES ('98')
    31        )
    32  /
    Tabelle wurde erstellt.
    SQL> /* EOF */
    SQL> @loadxmlfileascolumn_Int
    SQL> /* loadXmlFileAsColumn_INT.sql - interactive version */
    SQL> @@sourcedir
    SQL> /*
    SQL>   set SOURCE_DIR for XML
    SQL>   Parameter 1: source directory
    SQL> */
    SQL>
    SQL> create or replace directory SOURCE_DIR as '&source_directory'
      2  /
    Geben Sie einen Wert für source_directory ein: c:\gks\kbv\h\ebm
    alt   1: create or replace directory SOURCE_DIR as '&source_directory'
    neu   1: create or replace directory SOURCE_DIR as 'c:\gks\kbv\h\ebm'
    Verzeichnis wurde erstellt.
    SQL>
    SQL> declare
      2    InstanceDocument varchar2(4000);
      3  begin
      4    INSERT INTO &XMLTypeTable
      5        VALUES (&id, XMLType(bfilename('SOURCE_DIR', '&InstanceDocument'),
      6             nls_charset_id('ISO-8859-1')));
      7  end;
      8  /
    Geben Sie einen Wert für xmltypetable ein: ebm
    alt   4:   INSERT INTO &XMLTypeTable
    neu   4:   INSERT INTO ebm
    Geben Sie einen Wert für id ein: 46
    Geben Sie einen Wert für instancedocument ein: test46.xml
    alt   5:     VALUES (&id, XMLType(bfilename('SOURCE_DIR', '&InstanceDocument'),
    neu   5:     VALUES (46, XMLType(bfilename('SOURCE_DIR', 'test46.xml'),
    declare
    FEHLER in Zeile 1:
    ORA-31061: XDB-Fehler: XML event error
    ORA-19202: Fehler bei XML-Verarbeitung 
    LSX-00333: Message 333 not found; No message file for product=XDK, facility=LSX
    aufgetreten
    ORA-06512: in Zeile 4
    SQL> spool offAs you see, yet another issue: I modified the pattern in the corresponding scheme to grow in length step-by-step, and it did not like this as well. And, I really do not know, why no messages are found: my XDK_HOME points to %ORACLE_HOME%\XDK where the mesg files are, but som other parts of the XDK kit is under %ORACLE_HOM%\LIB. Any idea?
    Thanks, regards
    Miklos

  • Question about binary XML

    It seems the binary XML storage can be schema based or non-schema based. What are the advantages of schema based over non-schema based? My XML doc could be very big, and I need to add/modify some elements without loading the whole XML doc in memory for performance reason, should my XML doc be schema based or not?
    create table xmlOrders(
    id number primary key,
    doc xmltype,
    xmltype column doc store as binary xml
    Thanks,
    Denny

    I read to many open questions between the lines.
    Have a read here: http://www.liberidu.com/blog/?cat=23 (skip the non binary stuff) and maybe the following will also give you some insight regarding what you are looking for:
    Encoding and validation: http://www.liberidu.com/blog/?p=332
    Some of the possibilities: http://www.liberidu.com/blog/?p=264
    Choosing a applicable storage model: http://www.liberidu.com/blog/?p=203
    There are a lot of URL's in there, pointing to the appropriate sections in the XMLDB Developers Guide (=your ultimate resource for answers)
    Definitely read Marks presentation: http://www.oracle.com/technology/tech/xml/xmldb/Current/11g%20new%20features.ppt.pdf (for binary xml see: slide 23, 24, 25)
    and...what is "big" ?
    Message was edited by:
    Marco Gralike

  • Binary XML lightest-weight transform?

    Database 11.2.0.2.
    I have a set of small XML documents stored in a schema-based binary XML column (pubdate, author, language, title, etc.).
    I'm using the XML, combined with a bit of longer (blob-based) text to generate a text index using a user_datastore.
    I have a requirement to (a) change the names of one or two XML tags (to help the indexer disambiguate between two elements, for example), and to change the case of one or two elements (to make the language all uppercase, for example).
    What's the most efficient way to make these types of changes -- hopefully within PL/SQL, since that is what the current datastore procedure uses.
    The procedure currently looks like:
    create or replace procedure GenerateText(pRID in ROWID, pTextClob IN OUT NOCOPY CLOB) as
    begin
        for x in (select docid, XMLSerialize(CONTENT docxml as clob) as xmldata
                  from docs where rowid = pRID)
        loop
            dbms_lob.copy(pTextClob, x.xmldata, DBMS_LOB.LOBMAXSIZE);
            for y in (select doctext from doc_components where docid = x.docid and length(doctext) > 0)
             loop
              dbms_lob.append(pTextClob, y.doctext);
             end loop;
        end loop;
      end GenerateText;XMLTRANSFORM looks like the appropriate method, but it's not something I've used before. If it's the best way, do you have any suggestions on a quick primer on how to build the appropriate XSLT?

    #1. We need to see the code that is being used to invoke the stylesheet.
    #2. We need to see the document that is being transformed...
    It's most likely a bug in 9g which has been fixed in 11g...

Maybe you are looking for

  • Checking Payload of WorkFlow Step in BPM

    Hello All,                 I was trying the scenario MessageSplit Using BPM I am stuck at send Step after receiver determination ,I want to know what is the payload (input output) after each workflow step in the BPM ,but i am unable to check . Is the

  • Reading a binary image.

    can anybody shed some light on this for me? thanks :)

  • Using a third party audio plugin (Soundsoap Pro 2)

    Hi, Am I able to use Soundsoap Pro 2 from within Final Cut Express 4? How would I access Soundsoap from Final Cut if the answer is yes. Thank you, Tricia

  • Downloaded oracle 10g license for 30days

    i have downloaded a oracle 10g from oracle website, but i found that it can only be used for 30days, i am just a student, i just want to learn it. does anyone know what will happened after 30 days? how long can i use? what is the technical difference

  • 400,101004 error "unknown error" - some kind of login issue

    I'm getting a 400,101004 error - "Unknown error"  It is of course a known error that has to do with my login account. This has happened to me before but I don't remember how to fix it. John Heckman