ORA-30951

Hi!!
During insert an xml doc I'm getting the error:
ORA-30951: Element or attribute at Xpath /Security/SecurityInformation/FundInformation/TotalAssets exceeds maximum length
This is the part of the xml doc:
<Security id="16850" xmlns="http://mydb/security_v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mydb/security_v1.1 security.xsd">
     <Symbol>AAAGX</Symbol>
     <Name>AAL Aggressive Growth A</Name>
     <ShortName>AAAGX</ShortName>
     <SecurityType>Stock Fund</SecurityType>
     <SecurityInformation>
          <FundInformation>
               <FundFamily>AAL Mutual Funds</FundFamily>
               <Sector>Healthcare</Sector>
               <Industry>Advertising</Industry>
               <Industry>ElectricUtilities</Industry>
               <AssetGroup>Large Growth</AssetGroup>
               <Category Capitalization="Small" Class="Value"/>
               <ExpenseRatio>0.62</ExpenseRatio>
               <TotalAssets>34423803904</TotalAssets>
               <MinInitialInvestment>10000</MinInitialInvestment>
               <MinSubsequentInvestment>100</MinSubsequentInvestment>
          </FundInformation>
And this is the part of the schema:
<xsd:element name="FundInformation">
                         <xsd:complexType>
                              <xsd:sequence>
                                   <xsd:element name="FundFamily" type="xsd:string"/>
                                   <xsd:element name="Sector" type="security:SectorType" minOccurs="0"/>
                                   <xsd:element name="Industry" type="security:IndustryType" minOccurs="0" maxOccurs="unbounded"/>
                                   <xsd:element name="AssetGroup" type="xsd:string"/>
                                   <!--xsd:choice-->
                                   <xsd:element name="Category" type="security:CategoryType" minOccurs="0"/>
                                   <xsd:element name="FixedIncome" type="security:FixedIncomeType" minOccurs="0"/>
                                   <!--/xsd:choice-->
                                   <xsd:element name="ExpenseRatio" type="security:SecurityDecimalType"/>
                                   <xsd:element name="TotalAssets" type="security:SecurityDecimalType"/>
                                   <xsd:element name="MinInitialInvestment" type="xsd:integer" minOccurs="0"/>
                                   <xsd:element name="MinSubsequentInvestment" type="xsd:integer" minOccurs="0"/>
                              </xsd:sequence>
                         </xsd:complexType>
                    </xsd:element>
What did I wrong?
Thanks for your help!!

In this case I think SPY is wrong
SQL>
SQL>
SQL> var schemaURL varchar2(64);
SQL> --
SQL> begin
  2    :schemaURL := 'security.xsd';
  3  end;
  4  /
PL/SQL procedure successfully completed.
SQL> call dbms_xmlSchema.deleteSchema(:schemaURL,4)
  2  /
Call completed.
SQL> declare
  2    xmlSchema xmltype := xmltype(
  3  '<?xml version="1.0" encoding="UTF-8"?>
  4  <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:security="http://mydb/security_v
1.1" targetNamespace="http://mydb/security_v1.1" elementFormDefault="qualified" attributeFormDefault="unqualified">
  5     <xsd:element name="FundInformation" xdb:defaultTable="FUND_TABLE">
  6             <xsd:complexType xdb:SQLType="FUND_T">
  7                     <xsd:sequence>
  8                             <xsd:element name="FundFamily" type="xsd:string"/>
  9                             <xsd:element name="Sector" type="xsd:string" minOccurs="0"/>
10                             <xsd:element name="Industry" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
11                             <xsd:element name="AssetGroup" type="xsd:string"/>
12                             <xsd:element name="Category" type="xsd:string" minOccurs="0"/>
13                             <xsd:element name="FixedIncome" type="xsd:decimal" minOccurs="0"/>
14                             <xsd:element name="ExpenseRatio" type="security:SecurityDecimalType"/>
15                             <xsd:element name="TotalAssets" type="security:SecurityDecimalType"/>
16                             <xsd:element name="MinInitialInvestment" type="xsd:integer" minOccurs="0"/>
17                             <xsd:element name="MinSubsequentInvestment" type="xsd:integer" minOccurs="0"/>
18                     </xsd:sequence>
19             </xsd:complexType>
20     </xsd:element>
21     <xsd:simpleType name="SecurityDecimalType">
22             <xsd:restriction base="xsd:decimal">
23                     <xsd:minInclusive value="0"/>
24                     <xsd:totalDigits value="13"/>
25                     <xsd:fractionDigits value="4"/>
26             </xsd:restriction>
27     </xsd:simpleType>
28  </xsd:schema>');
29  begin
30     dbms_xmlSchema.registerSchema(:schemaURL,xmlSchema);
31  end;
32  /
PL/SQL procedure successfully completed.
SQL> desc FUND_TABLE
Name                                      Null?    Type
TABLE of SYS.XMLTYPE(XMLSchema "security.xsd" Element "FundInformation") STORAGE Object-relational TYPE "FUND_T"
SQL> --
SQL> desc FUND_T
Name                                      Null?    Type
SYS_XDBPD$                                         XDB.XDB$RAW_LIST_T
FundFamily                                         VARCHAR2(4000 CHAR)
Sector                                             VARCHAR2(4000 CHAR)
Industry                                           Industry8403_COLL
AssetGroup                                         VARCHAR2(4000 CHAR)
Category                                           VARCHAR2(4000 CHAR)
FixedIncome                                        NUMBER
ExpenseRatio                                       NUMBER(13,4)
TotalAssets                                        NUMBER(13,4)
MinInitialInvestment                               NUMBER(38)
MinSubsequentInvestment                            NUMBER(38)
SQL> --
SQL> insert into FUND_TABLE values ( xmltype(
  2  '<FundInformation xmlns="http://mydb/security_v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://my
db/security_v1.1 security.xsd">
  3  <FundFamily>AAL Mutual Funds</FundFamily>
  4  <Sector>Healthcare</Sector>
  5  <Industry>Advertising</Industry>
  6  <Industry>ElectricUtilities</Industry>
  7  <AssetGroup>Large Growth</AssetGroup>
  8  <Category/>
  9  <ExpenseRatio>0.62</ExpenseRatio>
10  <TotalAssets>34423803904</TotalAssets>
11  <MinInitialInvestment>10000</MinInitialInvestment>
12  <MinSubsequentInvestment>100</MinSubsequentInvestment>
13  </FundInformation>'))
14  /
insert into FUND_TABLE values ( xmltype(
ERROR at line 1:
ORA-30951: Element or attribute at Xpath /FundInformation/TotalAssets exceeds
maximum length
SQL>
SQL>
SQL> var schemaURL varchar2(64);
SQL> --
SQL> begin
  2    :schemaURL := 'security.xsd';
  3  end;
  4  /
PL/SQL procedure successfully completed.
SQL> call dbms_xmlSchema.deleteSchema(:schemaURL,4)
  2  /
Call completed.
SQL> declare
  2    xmlSchema xmltype := xmltype(
  3  '<?xml version="1.0" encoding="UTF-8"?>
  4  <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:security="http://mydb/security_v
1.1" targetNamespace="http://mydb/security_v1.1" elementFormDefault="qualified" attributeFormDefault="unqualified">
  5     <xsd:element name="FundInformation" xdb:defaultTable="FUND_TABLE">
  6             <xsd:complexType xdb:SQLType="FUND_T">
  7                     <xsd:sequence>
  8                             <xsd:element name="FundFamily" type="xsd:string"/>
  9                             <xsd:element name="Sector" type="xsd:string" minOccurs="0"/>
10                             <xsd:element name="Industry" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
11                             <xsd:element name="AssetGroup" type="xsd:string"/>
12                             <xsd:element name="Category" type="xsd:string" minOccurs="0"/>
13                             <xsd:element name="FixedIncome" type="xsd:decimal" minOccurs="0"/>
14                             <xsd:element name="ExpenseRatio" type="security:SecurityDecimalType"/>
15                             <xsd:element name="TotalAssets" type="security:SecurityDecimalType"/>
16                             <xsd:element name="MinInitialInvestment" type="xsd:integer" minOccurs="0"/>
17                             <xsd:element name="MinSubsequentInvestment" type="xsd:integer" minOccurs="0"/>
18                     </xsd:sequence>
19             </xsd:complexType>
20     </xsd:element>
21     <xsd:simpleType name="SecurityDecimalType">
22             <xsd:restriction base="xsd:decimal">
23                     <xsd:minInclusive value="0"/>
24                     <xsd:totalDigits value="15"/>
25                     <xsd:fractionDigits value="4"/>
26             </xsd:restriction>
27     </xsd:simpleType>
28  </xsd:schema>');
29  begin
30     dbms_xmlSchema.registerSchema(:schemaURL,xmlSchema);
31  end;
32  /
PL/SQL procedure successfully completed.
SQL> desc FUND_TABLE
Name                                      Null?    Type
TABLE of SYS.XMLTYPE(XMLSchema "security.xsd" Element "FundInformation") STORAGE Object-relational TYPE "FUND_T"
SQL> --
SQL> desc FUND_T
Name                                      Null?    Type
SYS_XDBPD$                                         XDB.XDB$RAW_LIST_T
FundFamily                                         VARCHAR2(4000 CHAR)
Sector                                             VARCHAR2(4000 CHAR)
Industry                                           Industry8404_COLL
AssetGroup                                         VARCHAR2(4000 CHAR)
Category                                           VARCHAR2(4000 CHAR)
FixedIncome                                        NUMBER
ExpenseRatio                                       NUMBER(15,4)
TotalAssets                                        NUMBER(15,4)
MinInitialInvestment                               NUMBER(38)
MinSubsequentInvestment                            NUMBER(38)
SQL> --
SQL> insert into FUND_TABLE values ( xmltype(
  2  '<FundInformation xmlns="http://mydb/security_v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://my
db/security_v1.1 security.xsd">
  3  <FundFamily>AAL Mutual Funds</FundFamily>
  4  <Sector>Healthcare</Sector>
  5  <Industry>Advertising</Industry>
  6  <Industry>ElectricUtilities</Industry>
  7  <AssetGroup>Large Growth</AssetGroup>
  8  <Category/>
  9  <ExpenseRatio>0.62</ExpenseRatio>
10  <TotalAssets>34423803904</TotalAssets>
11  <MinInitialInvestment>10000</MinInitialInvestment>
12  <MinSubsequentInvestment>100</MinSubsequentInvestment>
13  </FundInformation>'))
14  /
1 row created.
SQL>
SQL>
SQL>The original definition of SecurityDecimalType is a total 13 digits, with 4 reserved for fractional values, leaving 9 digits for the non fractional value. Your instance document contains a non fractional value with 11 digits. As can be seen if we alter the definition to allow for a total of 15 digits then everything works as expected.
I also checked and the XDB schema validator does not catch this issue either. I will file a bug on the schema validator for this issue.

Similar Messages

  • ORA-30951: Element or attribute at Xpath /AC//Doc[@] exceeds maximum length

    Hi All,
    I am trying to load the XML Files into a Table using the SQL Loader and i am getting the Error
    Record 1: Rejected - Error on table COMMONASSETCATALOG.
    ORA-30951: Element or attribute at Xpath /AC/T[1]/T[1]/T[1]/T[1]/T[1]/Doc[@] exceeds maximum length
    The <Doc> Element which is child of the <T> contains an XML Schema inside it..
    The Doc Element is declared in Schema as
    <xs:complexType name="AsDocType">
              <xs:annotation>
                   <xs:documentation>A (Doc)ument, a container for any type of file</xs:documentation>
              </xs:annotation>
              <xs:sequence minOccurs="0" maxOccurs="unbounded">
                   <xs:any namespace="##any" processContents="lax"/>
              </xs:sequence>
              <xs:attributeGroup ref="AsDocAtts"/>
         </xs:complexType>
    The Size of the XML Content that <Doc> Node has is around 34Kb.
    Could you pls let me know how to resolve this..
    Thanks
    Sateesh

    Hi All,
    I am trying to load the XML Files into a Table using the SQL Loader and i am getting the Error
    Record 1: Rejected - Error on table COMMONASSETCATALOG.
    ORA-30951: Element or attribute at Xpath /AC/T[1]/T[1]/T[1]/T[1]/T[1]/Doc[@] exceeds maximum length
    The <Doc> Element which is child of the <T> contains an XML Schema inside it..
    The Doc Element is declared in Schema as
    <xs:complexType name="AsDocType">
              <xs:annotation>
                   <xs:documentation>A (Doc)ument, a container for any type of file</xs:documentation>
              </xs:annotation>
              <xs:sequence minOccurs="0" maxOccurs="unbounded">
                   <xs:any namespace="##any" processContents="lax"/>
              </xs:sequence>
              <xs:attributeGroup ref="AsDocAtts"/>
         </xs:complexType>
    The Size of the XML Content that <Doc> Node has is around 34Kb.
    Could you pls let me know how to resolve this..
    Thanks
    Sateesh

  • XML data value exceeds maximum length - ORA-30951

    Hello,
    I am receiving ORA-30951: Element or attribute at Xpath /dataroot/Respondent[1]/Response[3]/Value exceeds maximum length error during the XML load.
    I have registered the schema and it works fine when the Value is less than 64k but fails if its greater. I tried changing the type of Value to type="xsd:base64Binary" xdb:maintainDOM="false" xdb:SQLName="LOB_DATA" xdb:SQLType="BLOB" but then I get ORA-00932: inconsistent datatypes error.
    Can someone please let me know what I am doing wrong or is there a way I can load more than 64k length elements on 10g?
    Thanks
    Here is my schema.
    var SCHEMAURL varchar2(256)
    var XMLSCHEMA CLOB
    set define off
    begin
    :SCHEMAURL := 'http://xmlns.example.com/Svy_Resp.xsd';
    :XMLSCHEMA := '<?xml version="1.0"; encoding="utf-16"?>
    <xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0"; xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
    <xsd:element name="dataroot" xdb:defaultTable="SVY_RESP_XML_SCHEMA" type="datarootType" />
    <xsd:complexType name="datarootType" xdb:maintainDOM="false"
    xdb:SQLType="Dataroot_T">
    <xsd:sequence>
    <xsd:element maxOccurs="unbounded" name="Respondent" type="RespondentType" />
    </xsd:sequence>
    <xsd:attribute name="generated" type="xsd:dateTime" />
    </xsd:complexType>
    <xsd:complexType name="RespondentType" xdb:maintainDOM="false" xdb:SQLType="Respondent_Type">
    <xsd:sequence>
    <xsd:element name="RespondentID" type="xsd:int" />
    <xsd:element name="KsID" type="xsd:int" />
    <xsd:element name="email" type="xsd:string" />
    <xsd:element name="SyID" type="xsd:int" />
    <xsd:element name="KSuID" type="xsd:int" />
    <xsd:element name="Completed" type="xsd:int" />
    <xsd:element name="SubmitDateTime" type="xsd:dateTime" />
    <xsd:element maxOccurs="unbounded" name="Response" type="ResponseType" />
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="ResponseType" xdb:maintainDOM="false" xdb:SQLType="Response_Type">
    <xsd:sequence>
    <xsd:element name="ResponseID" type="xsd:int" />
    <xsd:element name="RespondentID" type="xsd:int" />
    <xsd:element name="CID" type="xsd:int" />
    <xsd:element name="AID" type="xsd:int" />
    <xsd:element name="Value" type="xsd:string"/>
    <xsd:element name="QID" type="xsd:int" />
    <xsd:element name="SID" type="xsd:int" />
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>';
    end;
    /

    Thanks for the quick response. I am not able to modify the source file, but will it be possible to set the value to NULL if it exceeds the max length instead of failure?
    Thanks

  • ORA-30951: ...exceeds maximum length

    Oracle Database 10g Release 10.2.0.1.0 - Production
    I am new to XML and having a problem importing data using the XML Repository. I have annotated the schema and validated it using XML Spy. I am able to register the schema w/o errors. I am now working through the issues as they occur during the insertion of xml documents. Thes section below is giving me an error (bottom) that the data exceeds the maximum length. The "DATA" in the xml doc is a pdf file that has been converted to characters by some method. The size element has a data value of 5008. Seems to be too long for a varchar2. I tried RAW, CLOB, BLOB. I was pretty sure they wouldn't work and they didn't. I get an error that the xml/xdb types are incompatible.
    How can I modify the schema to get this element to load?
    Is it possible to tell oracle to ignore an element so I can eliminate those that are not critical? This would be very helpful.
    Thanks!
    Schema -
    <xs:element name="NpdbReportList" minOccurs="0">
    <xs:complexType>
    <xs:sequence maxOccurs="unbounded">
    <xs:element name="NpdbReport" minOccurs="0">
    <xs:complexType>
    <xs:all minOccurs="0">
    <xs:element name="DCN" minOccurs="0"/>
    <xs:element name="DateReport" type="Date" minOccurs="0"/>
    <xs:element name="ReportType" type="IdRef" minOccurs="0"/>
    <xs:element ref="LOB" minOccurs="0"/>
    </xs:all>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:complexType name="LOB" xdb:SQLType="LOB_T"xdb:maintainDOM="false">
    <xs:all>
         <xs:element name="Type" type="IdRef"/>
         <xs:element name="Size"/>
         <xs:element name="Data" xdb:maintainDOM="false" xdb:SQLName="LOB_DATA" xdb:SQLType="VARCHAR2"/>
    </xs:all>
    </xs:complexType>
    ftp> mput *
    mput Smyth_Steven_1386367.XML? y
    227 Entering Passive Mode (127,0,0,1,83,221)
    150 ASCII Data Connection
    550- Error Response
    ORA-30951: Element or attribute at Xpath /Provider/NpdbReportList/NpdbReport[1]/LOB/Data exceeds maximum length
    550 End Error Response
    28706 bytes sent in 0.014 seconds (1.9e+03 Kbytes/s)
    ftp>

    Thanks for your time Marco.
    Here is the header:
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- edited with XMLSpy v2010 rel. 2 (http://www.altova.com) by Joe (DSI) -->
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" elementFormDefault="qualified" attributeFormDefault="unqualified" xdb:storeVarrayAsTable="true" xdb:mapStringToNCHAR="true" xdb:mapUnboundedStringToLob="true">
    I made the following change -
    <xs:element name="Data" xdb:maintainDOM="false" xdb:SQLName="LOB_DATA" xdb:SQLType="CLOB"/>
    I received this error -
    ORA-31094: incompatible SQL type "CLOB" for attribute or element "Data"
    ORA-06512: at "XML_TEST.XML_TEST_SCHEMA_REGISTER", line 48
    I did a little more testing after the first post. I used the same type as an element that is defining image data.
    <xs:element name="Data" type="xs:base64Binary" xdb:maintainDOM="false" xdb:SQLName="LOB_DATA" xdb:SQLType="BLOB"/>
    While this did register and I was able to load a record, I am guessing that this will render the data for this element usless but at least the record loads. I'll still need to resolve this issue as the .pdf data is important.
    Thanks
    Joe

  • ORA-30951 Problems

    I am somewhat new to oracle and I am having a very hard time registering a large XML schema (approx 1MB). I tried the following code but I do not understand where or what the problem is. Is it with the XML schema? If so how do I find the line that it is on.
    SQL>
    SQL> DECLARE
    2
    3 -- OS file whose content needs to be read.
    4 fileName VARCHAR2(50) := 'test.xsd';
    5
    6
    7 -- Directory Object specifying the file location.
    8 directoryName VARCHAR2(50) := 'SOURCE_DIR';
    9
    10 -- CLOB Object to hold the content of the file from the user specified di
    rectory.
    11 fileContent CLOB;
    12
    13
    14 BEGIN
    15 fileContent := xdb_utilities.getFileContent(fileName, directoryName);
    16 dbms_xmlschema.registerSchema('test12', fileContent);
    17 END;
    18 /
    DECLARE
    ERROR at line 1:
    ORA-30951: Element or attribute at Xpath /schema/simpleType[149]/annotation/appi
    nfo[2][@] exceeds maximum length
    ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 20
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 31
    ORA-06512: at line 16
    Thanks,
    Crim

    Suggest you post your question in the XDB forum...
    XML DB
    as you will get good help from mdrake in there as he knows what he's talking about regarding XML stuff.
    ;)

  • ORA-30951 when registering TPoX schemas

    Hello,
    I am trying to register the schemas for TPoX benchmark of XMLType Object Relational storage.
    BEGIN
    DBMS_XMLSCHEMA.registerSchema(
    SCHEMAURL => 'http://www.fixprotocol.org/FIXML-4-4 fixml-fields-base-4-4.xsd',
    SCHEMADOC => bfilename('XML_FILES_DIR','fixml-fields-base-4-4.xsd'),
    LOCAL => TRUE,
    CSID => nls_charset_id('AL32UTF8'));
    END;
    I get the following error:
    ORA-30951: Element or attribute at Xpath /schema/simpleType[131]/annotation/appinfo[2][@] exceeds maximum length
    The element it refers to, indeed is quite large:
    <xs:appinfo xmlns:x="http://www.fixprotocol.org/fixml/metadata.xsd">
    <x:EnumDoc value="EUSUPRA" desc="EuroSupranationalCoupons"/>
    <x:EnumDoc value="FAC" desc="FederalAgencyCoupon"/>
    <x:EnumDoc value="FADN" desc="FederalAgencyDiscountNote"/>
    <x:EnumDoc value="PEF" desc="PrivateExportFunding"/>
    <x:EnumDoc value="SUPRA" desc="USDSupranationalCoupons"/>
    <x:EnumDoc value="FUT" desc="Future"/>
    <x:EnumDoc value="OPT" desc="Option"/>
    <x:EnumDoc value="CORP" desc="CorporateBond"/>
    <x:EnumDoc value="CPP" desc="CorporatePrivatePlacement"/>
    <x:EnumDoc value="CB" desc="ConvertibleBond"/>
    <x:EnumDoc value="DUAL" desc="DualCurrency"/>
    <x:EnumDoc value="EUCORP" desc="EuroCorporateBond"/>
    <x:EnumDoc value="XLINKD" desc="IndexedLinked"/>
    <x:EnumDoc value="STRUCT" desc="StructuredNotes"/>
    <x:EnumDoc value="YANK" desc="YankeeCorporateBond"/>
    <x:EnumDoc value="FOR" desc="ForeignExchangeContract"/>
    <x:EnumDoc value="CS" desc="CommonStock"/>
    <x:EnumDoc value="PS" desc="PreferredStock"/>
    <x:EnumDoc value="BRADY" desc="BradyBond"/>
    <x:EnumDoc value="EUSOV" desc="EuroSovereigns"/>
    <x:EnumDoc value="TBOND" desc="USTreasuryBond"/>
    <x:EnumDoc value="TINT" desc="InterestStripFromAnyBondOrNote"/>
    <x:EnumDoc value="TIPS" desc="TreasuryInflationProtectedSecurities"/>
    <x:EnumDoc value="TCAL" desc="PrincipalStripOfACallableBondOrNote"/>
    <x:EnumDoc value="TPRN" desc="PrincipalStripFromANoncallableBondOrNote"/>
    <x:EnumDoc value="UST" desc="USTreasuryNoteDeprecatedValueUseTNOTE"/>
    <x:EnumDoc value="USTB" desc="USTreasuryBillDeprecatedValueUseTBILL"/>
    <x:EnumDoc value="TNOTE" desc="USTreasuryNote"/>
    <x:EnumDoc value="TBILL" desc="USTreasuryBill"/>
    <x:EnumDoc value="REPO" desc="Repurchase"/>
    <x:EnumDoc value="FORWARD" desc="Forward"/>
    <x:EnumDoc value="BUYSELL" desc="BuySellback"/>
    <x:EnumDoc value="SECLOAN" desc="SecuritiesLoan"/>
    <x:EnumDoc value="SECPLEDGE" desc="SecuritiesPledge"/>
    <x:EnumDoc value="TERM" desc="TermLoan"/>
    <x:EnumDoc value="RVLV" desc="RevolverLoan"/>
    <x:EnumDoc value="RVLVTRM" desc="RevolverTermLoan"/>
    <x:EnumDoc value="BRIDGE" desc="BridgeLoan"/>
    <x:EnumDoc value="LOFC" desc="LetterOfCredit"/>
    <x:EnumDoc value="SWING" desc="SwingLineFacility"/>
    <x:EnumDoc value="DINP" desc="DebtorInPossession"/>
    <x:EnumDoc value="DEFLTED" desc="Defaulted"/>
    <x:EnumDoc value="WITHDRN" desc="Withdrawn"/>
    <x:EnumDoc value="REPLACD" desc="Replaced"/>
    <x:EnumDoc value="MATURED" desc="Matured"/>
    <x:EnumDoc value="AMENDED" desc="AmendedRestated"/>
    <x:EnumDoc value="RETIRED" desc="Retired"/>
    <x:EnumDoc value="BA" desc="BankersAcceptance"/>
    <x:EnumDoc value="BN" desc="BankNotes"/>
    <x:EnumDoc value="BOX" desc="BillOfExchanges"/>
    <x:EnumDoc value="CD" desc="CertificateOfDeposit"/>
    <x:EnumDoc value="CL" desc="CallLoans"/>
    <x:EnumDoc value="CP" desc="CommercialPaper"/>
    <x:EnumDoc value="DN" desc="DepositNotes"/>
    <x:EnumDoc value="EUCD" desc="EuroCertificateOfDeposit"/>
    <x:EnumDoc value="EUCP" desc="EuroCommercialPaper"/>
    <x:EnumDoc value="LQN" desc="LiquidityNote"/>
    <x:EnumDoc value="MTN" desc="MediumTermNotes"/>
    <x:EnumDoc value="ONITE" desc="Overnight"/>
    <x:EnumDoc value="PN" desc="PromissoryNote"/>
    <x:EnumDoc value="PZFJ" desc="PlazosFijos"/>
    <x:EnumDoc value="STN" desc="ShortTermLoanNote"/>
    <x:EnumDoc value="TD" desc="TimeDeposit"/>
    <x:EnumDoc value="XCN" desc="ExtendedCommNote"/>
    <x:EnumDoc value="YCD" desc="YankeeCertificateOfDeposit"/>
    <x:EnumDoc value="ABS" desc="AssetbackedSecurities"/>
    <x:EnumDoc value="CMBS" desc="CorpMortgagebackedSecurities"/>
    <x:EnumDoc value="CMO" desc="CollateralizedMortgageObligation"/>
    <x:EnumDoc value="IET" desc="IOETTEMortgage"/>
    <x:EnumDoc value="MBS" desc="MortgagebackedSecurities"/>
    <x:EnumDoc value="MIO" desc="MortgageInterestOnly"/>
    <x:EnumDoc value="MPO" desc="MortgagePrincipalOnly"/>
    <x:EnumDoc value="MPP" desc="MortgagePrivatePlacement"/>
    <x:EnumDoc value="MPT" desc="MiscellaneousPassthrough"/>
    <x:EnumDoc value="PFAND" desc="Pfandbriefe"/>
    <x:EnumDoc value="TBA" desc="ToBeAnnounced"/>
    <x:EnumDoc value="AN" desc="OtherAnticipationNotesBANGANEtc"/>
    <x:EnumDoc value="COFO" desc="CertificateOfObligation"/>
    <x:EnumDoc value="COFP" desc="CertificateOfParticipation"/>
    <x:EnumDoc value="GO" desc="GeneralObligationBonds"/>
    <x:EnumDoc value="MT" desc="MandatoryTender"/>
    <x:EnumDoc value="RAN" desc="RevenueAnticipationNote"/>
    <x:EnumDoc value="REV" desc="RevenueBonds"/>
    <x:EnumDoc value="SPCLA" desc="SpecialAssessment"/>
    <x:EnumDoc value="SPCLO" desc="SpecialObligation"/>
    <x:EnumDoc value="SPCLT" desc="SpecialTax"/>
    <x:EnumDoc value="TAN" desc="TaxAnticipationNote"/>
    <x:EnumDoc value="TAXA" desc="TaxAllocation"/>
    <x:EnumDoc value="TECP" desc="TaxExemptCommercialPaper"/>
    <x:EnumDoc value="TRAN" desc="TaxRevenueAnticipationNote"/>
    <x:EnumDoc value="VRDN" desc="VariableRateDemandNote"/>
    <x:EnumDoc value="WAR" desc="Warrant"/>
    <x:EnumDoc value="MF" desc="MutualFund"/>
    <x:EnumDoc value="MLEG" desc="MultilegInstrument"/>
    <x:EnumDoc value="NONE" desc="NoSecurityType"/>
    <x:EnumDoc value="WLD" desc="WildcardEntry"/>
    </xs:appinfo>
    Which parameter should I change in order to register the schema?
    Any help much appreciated!

    For example (code snippet)...
    declare
      V_FILENAME  VARCHAR2(700) := 'CMFXML.SWIFT.MT543.xsd';
      V_XMLSCHEMA XMLTYPE := xmltype(bfilename('XMLDIR',V_FILENAME),nls_charset_id('AL32UTF8'));
      -- res boolean;
    begin
      dbms_xmlschema_annotate.addXDBNamespace(V_XMLSCHEMA);
      dbms_xmlschema_annotate.setDefaultTable(V_XMLSCHEMA,'CMFXML','CMFXML_MT543_TABLE');
      dbms_xmlschema_annotate.DISABLEDEFAULTTABLECREATION(V_XMLSCHEMA);
      -- DEBUG generated xdb annotations via resource
      -- if (dbms_xdb.existsResource('/public/'||V_FILENAME)) then
      --     dbms_xdb.deleteResource('/public/'||V_FILENAME);
      -- end if;
      -- res := dbms_xdb.createResource('/public/'||V_FILENAME,V_XMLSCHEMA);
      dbms_xmlschema.registerSchema
        schemaurl       => V_FILENAME,
        schemadoc       => V_XMLSCHEMA.getClobVal(),
        local           => TRUE,
        genTypes        => TRUE,
        genBean         => FALSE,
        genTables       => TRUE,
        enablehierarchy => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE,
        owner           => user
    end;
    declare
      V_FILENAME  VARCHAR2(700) := 'CMFXML.SWIFT.MT544.xsd';
      V_XMLSCHEMA XMLTYPE := xmltype(bfilename('XMLDIR',V_FILENAME),nls_charset_id('AL32UTF8'));
      -- res boolean;
    begin
      dbms_xmlschema_annotate.addXDBNamespace(V_XMLSCHEMA);
      dbms_xmlschema_annotate.setDefaultTable(V_XMLSCHEMA,'CMFXML','CMFXML_MT544_TABLE');
      dbms_xmlschema_annotate.DISABLEDEFAULTTABLECREATION(V_XMLSCHEMA);
      select insertChildXML
         V_XMLSCHEMA,
         '//xsd:element[@type="TIndicator-22F-01"]',
         '@xdb:SQLInline',
         'false',
         'xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        into V_XMLSCHEMA
        from dual;
      select insertChildXML
         V_XMLSCHEMA,
         '//xsd:element[@type="TAmount-19A-01"]',
         '@xdb:SQLInline',
         'false',
         'xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        into V_XMLSCHEMA
        from dual;
      select insertChildXML
         V_XMLSCHEMA,
         '//xsd:element[@type="TDate-98A-01"]',
         '@xdb:SQLInline',
         'false',
         'xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        into V_XMLSCHEMA
        from dual;
      select insertChildXML
         V_XMLSCHEMA,
         '//xsd:element[@type="TRate-92A-01"]',
         '@xdb:SQLInline',
         'false',
         'xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        into V_XMLSCHEMA
        from dual;
      select insertChildXML
         V_XMLSCHEMA,
         '//xsd:element[@type="TFlag-17B-01"]',
         '@xdb:SQLInline',
         'false',
         'xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        into V_XMLSCHEMA
        from dual;
      select insertChildXML
         V_XMLSCHEMA,
         '//xsd:element[@type="TQuantityOfFinancialInstrument-36B-01"]',
         '@xdb:SQLInline',
         'false',
         'xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        into V_XMLSCHEMA
        from dual;
      select insertChildXML
         V_XMLSCHEMA,
         '//xsd:element[@type="TReference-20C-01"]',
         '@xdb:SQLInline',
         'false',
         'xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        into V_XMLSCHEMA
        from dual;
      select insertChildXML
         V_XMLSCHEMA,
         '//xsd:element[@type="TParty-95PQR-01"]',
         '@xdb:SQLInline',
         'false',
         'xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
        into V_XMLSCHEMA
        from dual;
      dbms_xmlschema_annotate.setOutOfLine(V_XMLSCHEMA,'element','ReceiveFreeConfirmationType','TwoLegTransactionDetails','MT544_TWO_LEG_TRANS_TABLE');
      dbms_xmlschema_annotate.setOutOfLine(V_XMLSCHEMA,'element','ReceiveFreeConfirmationType','TradeDetails','MT544_TRADE_DETAILS_TABLE');
      dbms_xmlschema_annotate.setOutOfLine(V_XMLSCHEMA,'complexType','TTradeDetails','FinancialInstrumentAttributes','MT544_FIN_INST_ATTRS_TABLE');
      -- DEBUG generated xdb annotations via resource
      -- if (dbms_xdb.existsResource('/public/'||V_FILENAME)) then
      --     dbms_xdb.deleteResource('/public/'||V_FILENAME);
      -- end if;
      -- res := dbms_xdb.createResource('/public/'||V_FILENAME,V_XMLSCHEMA);
      dbms_xmlschema.registerSchema
       schemaurl       => V_FILENAME,
        schemadoc       => V_XMLSCHEMA.getClobVal(),
        local           => TRUE,
        genTypes        => TRUE,
        genBean         => FALSE,
        genTables       => TRUE,
        enablehierarchy => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE,
        owner           => user
    end;
    --

  • ORA-30951: Element or attribute at Xpath exceeds maximum length ORA-06512:

    Hi there
    I am getting the error when trying to run this test block, this is code is to simulate the production error we are getting...The XML is attached.. Please Help
    NB: What confuses me to this is that once I format the XML and run the same query it runs fine....
    DECLARE
    g_xdoc XMLTYPE;
    g_trans_type CHAR (20) := NULL;
    BEGIN
    SELECT xmltype(c) -- column is a clob column
    INTO g_xdoc
    FROM test_gil
    WHERE a = '1';
    SELECT EXTRACT(VALUE (tt), '//transactionType').getstringval()
    INTO g_trans_type
    FROM TABLE (XMLSEQUENCE (EXTRACT (g_xdoc, '/'))) tt;
    DBMS_OUTPUT.put_line (g_trans_type);
    END;

    HI Guys
    As I said when I have formatted the XML and run the query it runs but when I run it unformulated it gives the error.. And I have compared the two version of XML formatted/unformulated they are exactly the same... I have attached a copy of the formatted XML at the bottom together with the version number of my database.
    SQL*Plus: Release 10.1.0.4.2 - Production on Tue Apr 30 11:34:15 2013
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    With the Partitioning option
    Oracle version 11.2.0.2.0 on host boa
    pdev (assuper)>
    <?xml version="1.0" encoding="UTF-8"?>
    <ClaimRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="NXS_CLAIM_REQ.XSD">
    <Claim>
    <transactionType>Request</transactionType>
    <testClaim>false</testClaim>
    <messageId>neAn0Q062010005</messageId>
    <schemeCode>BONITAS</schemeCode>
    <planCode>470</planCode>
    <providerBHF>7021291</providerBHF>
    <referringProviderBHF />
    <membershipNo>47000115594</membershipNo>
    <scriptNo>7021291-ARETHA</scriptNo>
    <authorisationNo />
    <inHospitalClaim>N</inHospitalClaim>
    <receiptAmount>0.00</receiptAmount>
    <providerSubmittedInd>N</providerSubmittedInd>
    <source>PPN</source>
    <benefitBooking>false</benefitBooking>
    <iphReferenceNo>0</iphReferenceNo>
    <altClaimNo>4673452</altClaimNo>
    <claimGross>1350.00</claimGross>
    <claimSchemeSurcharge>0.00</claimSchemeSurcharge>
    <numLines>4</numLines>
    <Line>
    <lineNo>1</lineNo>
    <lineType>S</lineType>
    <itemCodeType>nappi</itemCodeType>
    <beneficiaryInitials />
    <beneficiaryFirstName>PAUL NDONI</beneficiaryFirstName>
    <beneficiarySurname>MABUZA</beneficiarySurname>
    <beneficiaryDOB>1956-07-28</beneficiaryDOB>
    <beneficiaryGender>U</beneficiaryGender>
    <beneficiaryId>C456253</beneficiaryId>
    <dependantNo />
    <chargeableCode>62223</chargeableCode>
    <extendedCode />
    <chargeableDescription>PPN 2 BIFOCAL PLASTIC</chargeableDescription>
    <chargeableTreatmentDate>2013-02-02</chargeableTreatmentDate>
    <results />
    <chargeableQuantity>100.00</chargeableQuantity>
    <inHospitalInd>N</inHospitalInd>
    <grossAmount>400.00</grossAmount>
    <discountAmount>0.00</discountAmount>
    <packageNumber>0</packageNumber>
    <benefitCode>L</benefitCode>
    <labReferenceNo />
    <dispensingLocation>P</dispensingLocation>
    <mixtureSequence>0</mixtureSequence>
    <authorisationNo />
    <daysSupplied>0</daysSupplied>
    <referringProviderBHF />
    <payInstruction>P</payInstruction>
    <benefitAmount>400.00</benefitAmount>
    <altClaimLineNo />
    <treatingProviderBHF />
    <levy>0.00</levy>
    <schemeSurcharge>0.00</schemeSurcharge>
    <savingsSurcharge>0.00</savingsSurcharge>
    <referenceSurcharge>0.00</referenceSurcharge>
    <overchargeAmount>0.00</overchargeAmount>
    <numDiagnoses>3</numDiagnoses>
    <Diagnoses>
    <lineNo>1</lineNo>
    <code>H52.0</code>
    <qualifier>P</qualifier>
    </Diagnoses>
    <Diagnoses>
    <lineNo>1</lineNo>
    <code>H52.4</code>
    <qualifier>P</qualifier>
    </Diagnoses>
    <Diagnoses>
    <lineNo>1</lineNo>
    <code>Z97.3</code>
    <qualifier>P</qualifier>
    </Diagnoses>
    <OpticalReadings>
    <lineNo>1</lineNo>
    <eye>R</eye>
    <sphere>0.50</sphere>
    <cylinder>0.00</cylinder>
    <axis>0.00</axis>
    <addition>1.75</addition>
    <prism />
    <status />
    <opticalType />
    <opticalReference />
    <visualAcuityUnaided>6/6</visualAcuityUnaided>
    <visualAcuityCorrected />
    <inocularPressure>16</inocularPressure>
    <visualFieldInfo>FULL</visualFieldInfo>
    <nvsTagNumber />
    <labReference />
    <labOrderNumber />
    </OpticalReadings>
    <OpticalReadings>
    <lineNo>1</lineNo>
    <eye>L</eye>
    <sphere>0.75</sphere>
    <cylinder>0.00</cylinder>
    <axis>0.00</axis>
    <addition>1.75</addition>
    <prism />
    <status />
    <opticalType />
    <opticalReference />
    <visualAcuityUnaided>6/6</visualAcuityUnaided>
    <visualAcuityCorrected />
    <inocularPressure>15</inocularPressure>
    <visualFieldInfo>FULL</visualFieldInfo>
    <nvsTagNumber />
    <labReference />
    <labOrderNumber />
    </OpticalReadings>
    </Line>
    <Line>
    <lineNo>2</lineNo>
    <lineType>S</lineType>
    <itemCodeType>nappi</itemCodeType>
    <beneficiaryInitials />
    <beneficiaryFirstName>PAUL NDONI</beneficiaryFirstName>
    <beneficiarySurname>MABUZA</beneficiarySurname>
    <beneficiaryDOB>1956-07-28</beneficiaryDOB>
    <beneficiaryGender>U</beneficiaryGender>
    <beneficiaryId>C456253</beneficiaryId>
    <dependantNo />
    <chargeableCode>70406</chargeableCode>
    <extendedCode />
    <chargeableDescription>CREAYIVE CRP4</chargeableDescription>
    <chargeableTreatmentDate>2013-02-02</chargeableTreatmentDate>
    <results />
    <chargeableQuantity>100.00</chargeableQuantity>
    <inHospitalInd>N</inHospitalInd>
    <grossAmount>150.00</grossAmount>
    <discountAmount>0.00</discountAmount>
    <packageNumber>0</packageNumber>
    <benefitCode>F</benefitCode>
    <labReferenceNo />
    <dispensingLocation>P</dispensingLocation>
    <mixtureSequence>0</mixtureSequence>
    <authorisationNo />
    <daysSupplied>0</daysSupplied>
    <referringProviderBHF />
    <payInstruction>P</payInstruction>
    <benefitAmount>150.00</benefitAmount>
    <altClaimLineNo />
    <treatingProviderBHF />
    <levy>0.00</levy>
    <schemeSurcharge>0.00</schemeSurcharge>
    <savingsSurcharge>0.00</savingsSurcharge>
    <referenceSurcharge>0.00</referenceSurcharge>
    <overchargeAmount>0.00</overchargeAmount>
    <numDiagnoses>3</numDiagnoses>
    <Diagnoses>
    <lineNo>2</lineNo>
    <code>H52.0</code>
    <qualifier>P</qualifier>
    </Diagnoses>
    <Diagnoses>
    <lineNo>2</lineNo>
    <code>H52.4</code>
    <qualifier>P</qualifier>
    </Diagnoses>
    <Diagnoses>
    <lineNo>2</lineNo>
    <code>Z97.3</code>
    <qualifier>P</qualifier>
    </Diagnoses>
    <OpticalReadings>
    <lineNo>2</lineNo>
    <eye>R</eye>
    <sphere>0.50</sphere>
    <cylinder>0.00</cylinder>
    <axis>0.00</axis>
    <addition>1.75</addition>
    <prism />
    <status />
    <opticalType />
    <opticalReference />
    <visualAcuityUnaided>6/6</visualAcuityUnaided>
    <visualAcuityCorrected />
    <inocularPressure>16</inocularPressure>
    <visualFieldInfo>FULL</visualFieldInfo>
    <nvsTagNumber />
    <labReference />
    <labOrderNumber />
    </OpticalReadings>
    <OpticalReadings>
    <lineNo>2</lineNo>
    <eye>L</eye>
    <sphere>0.75</sphere>
    <cylinder>0.00</cylinder>
    <axis>0.00</axis>
    <addition>1.75</addition>
    <prism />
    <status />
    <opticalType />
    <opticalReference />
    <visualAcuityUnaided>6/6</visualAcuityUnaided>
    <visualAcuityCorrected />
    <inocularPressure>15</inocularPressure>
    <visualFieldInfo>FULL</visualFieldInfo>
    <nvsTagNumber />
    <labReference />
    <labOrderNumber />
    </OpticalReadings>
    </Line>
    <Line>
    <lineNo>3</lineNo>
    <lineType>S</lineType>
    <itemCodeType>nappi</itemCodeType>
    <beneficiaryInitials />
    <beneficiaryFirstName>PAUL NDONI</beneficiaryFirstName>
    <beneficiarySurname>MABUZA</beneficiarySurname>
    <beneficiaryDOB>1956-07-28</beneficiaryDOB>
    <beneficiaryGender>U</beneficiaryGender>
    <beneficiaryId>C456253</beneficiaryId>
    <dependantNo />
    <chargeableCode>70001</chargeableCode>
    <extendedCode />
    <chargeableDescription>PPN COMP EXAM</chargeableDescription>
    <chargeableTreatmentDate>2013-02-02</chargeableTreatmentDate>
    <results />
    <chargeableQuantity>100.00</chargeableQuantity>
    <inHospitalInd>N</inHospitalInd>
    <grossAmount>400.00</grossAmount>
    <discountAmount>0.00</discountAmount>
    <packageNumber>0</packageNumber>
    <benefitCode>E</benefitCode>
    <labReferenceNo />
    <dispensingLocation>P</dispensingLocation>
    <mixtureSequence>0</mixtureSequence>
    <authorisationNo />
    <daysSupplied>0</daysSupplied>
    <referringProviderBHF />
    <payInstruction>P</payInstruction>
    <benefitAmount>400.00</benefitAmount>
    <altClaimLineNo />
    <treatingProviderBHF />
    <levy>0.00</levy>
    <schemeSurcharge>0.00</schemeSurcharge>
    <savingsSurcharge>0.00</savingsSurcharge>
    <referenceSurcharge>0.00</referenceSurcharge>
    <overchargeAmount>0.00</overchargeAmount>
    <numDiagnoses>4</numDiagnoses>
    <Diagnoses>
    <lineNo>3</lineNo>
    <code>H52.4</code>
    <qualifier>P</qualifier>
    </Diagnoses>
    <Diagnoses>
    <lineNo>3</lineNo>
    <code>Z97.3</code>
    <qualifier>P</qualifier>
    </Diagnoses>
    <Diagnoses>
    <lineNo>3</lineNo>
    <code>Z01.0</code>
    <qualifier>P</qualifier>
    </Diagnoses>
    <Diagnoses>
    <lineNo>3</lineNo>
    <code>H52.0</code>
    <qualifier>P</qualifier>
    </Diagnoses>
    <OpticalReadings>
    <lineNo>3</lineNo>
    <eye>R</eye>
    <sphere>0.50</sphere>
    <cylinder>0.00</cylinder>
    <axis>0.00</axis>
    <addition>1.75</addition>
    <prism />
    <status />
    <opticalType />
    <opticalReference />
    <visualAcuityUnaided>6/6</visualAcuityUnaided>
    <visualAcuityCorrected />
    <inocularPressure>16</inocularPressure>
    <visualFieldInfo>FULL</visualFieldInfo>
    <nvsTagNumber />
    <labReference />
    <labOrderNumber />
    </OpticalReadings>
    <OpticalReadings>
    <lineNo>3</lineNo>
    <eye>L</eye>
    <sphere>0.75</sphere>
    <cylinder>0.00</cylinder>
    <axis>0.00</axis>
    <addition>1.75</addition>
    <prism />
    <status />
    <opticalType />
    <opticalReference />
    <visualAcuityUnaided>6/6</visualAcuityUnaided>
    <visualAcuityCorrected />
    <inocularPressure>15</inocularPressure>
    <visualFieldInfo>FULL</visualFieldInfo>
    <nvsTagNumber />
    <labReference />
    <labOrderNumber />
    </OpticalReadings>
    </Line>
    <Line>
    <lineNo>4</lineNo>
    <lineType>S</lineType>
    <itemCodeType>nappi</itemCodeType>
    <beneficiaryInitials />
    <beneficiaryFirstName>PAUL NDONI</beneficiaryFirstName>
    <beneficiarySurname>MABUZA</beneficiarySurname>
    <beneficiaryDOB>1956-07-28</beneficiaryDOB>
    <beneficiaryGender>U</beneficiaryGender>
    <beneficiaryId>C456253</beneficiaryId>
    <dependantNo />
    <chargeableCode>62223</chargeableCode>
    <extendedCode />
    <chargeableDescription>PPN 2 BIFOCAL PLASTIC</chargeableDescription>
    <chargeableTreatmentDate>2013-02-02</chargeableTreatmentDate>
    <results />
    <chargeableQuantity>100.00</chargeableQuantity>
    <inHospitalInd>N</inHospitalInd>
    <grossAmount>400.00</grossAmount>
    <discountAmount>0.00</discountAmount>
    <packageNumber>0</packageNumber>
    <benefitCode>L</benefitCode>
    <labReferenceNo />
    <dispensingLocation>P</dispensingLocation>
    <mixtureSequence>0</mixtureSequence>
    <authorisationNo />
    <daysSupplied>0</daysSupplied>
    <referringProviderBHF />
    <payInstruction>P</payInstruction>
    <benefitAmount>400.00</benefitAmount>
    <altClaimLineNo />
    <treatingProviderBHF />
    <levy>0.00</levy>
    <schemeSurcharge>0.00</schemeSurcharge>
    <savingsSurcharge>0.00</savingsSurcharge>
    <referenceSurcharge>0.00</referenceSurcharge>
    <overchargeAmount>0.00</overchargeAmount>
    <numDiagnoses>3</numDiagnoses>
    <Diagnoses>
    <lineNo>4</lineNo>
    <code>H52.0</code>
    <qualifier>P</qualifier>
    </Diagnoses>
    <Diagnoses>
    <lineNo>4</lineNo>
    <code>H52.4</code>
    <qualifier>P</qualifier>
    </Diagnoses>
    <Diagnoses>
    <lineNo>4</lineNo>
    <code>Z97.3</code>
    <qualifier>P</qualifier>
    </Diagnoses>
    <OpticalReadings>
    <lineNo>4</lineNo>
    <eye>R</eye>
    <sphere>0.50</sphere>
    <cylinder>0.00</cylinder>
    <axis>0.00</axis>
    <addition>1.75</addition>
    <prism />
    <status />
    <opticalType />
    <opticalReference />
    <visualAcuityUnaided>6/6</visualAcuityUnaided>
    <visualAcuityCorrected />
    <inocularPressure>16</inocularPressure>
    <visualFieldInfo>FULL</visualFieldInfo>
    <nvsTagNumber />
    <labReference />
    <labOrderNumber />
    </OpticalReadings>
    <OpticalReadings>
    <lineNo>4</lineNo>
    <eye>L</eye>
    <sphere>0.75</sphere>
    <cylinder>0.00</cylinder>
    <axis>0.00</axis>
    <addition>1.75</addition>
    <prism />
    <status />
    <opticalType />
    <opticalReference />
    <visualAcuityUnaided>6/6</visualAcuityUnaided>
    <visualAcuityCorrected />
    <inocularPressure>15</inocularPressure>
    <visualFieldInfo>FULL</visualFieldInfo>
    <nvsTagNumber />
    <labReference />
    <labOrderNumber />
    </OpticalReadings>
    </Line>
    </Claim>
    </ClaimRequest>

  • XML file too large or XML element too large

    I am attempting to import an xml file into the repository and have it shred into the object-relational tables. I registered a schema and it created object-relational xml_tables, triggers, and types. The full xml file is > 80MB. XDB created all the fields as VARCHAR2(4000).
    error code when importing the full XML file. This is what I need to ultimately fix.
    DECLARE
      res BOOLEAN;
    BEGIN
      res := DBMS_XDB.createResource('/home/pharma/drugbank.xml',
                    bfilename('XMLPHARMA', 'drugbank.xml'),
                    nls_charset_id('AL32UTF8'));
    END;
    COMMIT;
    XML file encounters errors on the import.
    An error was encountered performing the requested operation
    ORA-30951: Element or attribute at Xpath references exceeds maximum length
    ORA-06512 at "XDB.DBMS_XDB", line 315
    ORA-06512 at line 4
    30951.00000 - "Element or attribute at Xpath %x exceeds maximum length"
    *Cause: An attempt was made to insert a node of length exceeding the maximum length (specified by the maxLength facet) into an XML document.
    *Action: Do not attempt to add a node exceeding the maximum length to XML documents.
    Vendor code 30951Error at Line:18I would guess that some of the fields have max lengths > 4000. I plan to annotate the schema with SQLType="CLOB", but need to know which fields to change. I was able to copy the xml file and reduce that xml file to one record, which imported into the tables. My plan was to write a view over the bfile to get the lengths of certain fields, annotate the .xsd with CLOBS where needed, and then import again. In order to do that, I have a 1 record file imported into a table and as a bfile.
    Here is my code selecting length from a generated object-relational table of only one record.
    CREATE OR REPLACE VIEW pharma.drugs_vw AS
    SELECT d.*
    FROM drugs, XMLTABLE
      ('/drugs' PASSING OBJECT_VALUE COLUMNS
        drugbank_id        VARCHAR2(20)   PATH 'drug/drugbank-id',
        name               VARCHAR2(50)   PATH 'drug/name',
        description        VARCHAR2(4000) PATH 'drug/description'   
      ) d
    select max(length(drugbank_id)) as dbidlen,
          max(length(name)) as nmlen,
          max(length(description)) as desclen
    from drugs_vw;
            DBIDLEN           NMLEN         DESCLEN
                  7               9             229
    1 row selected.Here is the code for the bfile. Same results, but using deprecated functions. I read the whitepaper, Oracle XML DB: Best practices to get optimal performance out of XML Queries. It says that extract(), extractvalue(), Table(XMLSequence()), and XMLType() are deprecated in 11gr2.
    -- Note extractvalue is deprecated in 11gr2 replaced by W3C standard
    --                                          XMLCast(XMLQuery())
    -- TABLE(XMLSequence) is replaced by XMLTable
    -- XMLType() is replaced by XMLParse()
    SELECT max(length(extractvalue(column_value, '/drug/drugbank-id'))) dbidlen,
           max(length(extractvalue(column_value, '/drug/name'))) nmlen,
           max(length(extractvalue(column_value, '/drug/description'))) desclen
    FROM TABLE(XMLSequence(XMLTYPE(bfilename('XMLPHARMA',
    'db00001.xml'),nls_charset_id('AL32UTF8')).extract('/drugs/drug'))) d
    WHERE ROWNUM <= 5;
            DBIDLEN           NMLEN         DESCLEN
                  7               9             229Is this better code for getting the maximum length of xml fields from a bfile? Here is what I have so far. This works on a single drugbank-id.
    SELECT max(length(drugbank_id)) AS dbidlen,
           max(length(name)) AS nmlen,
           max(length(description)) AS desclen
    FROM (XMLTABLE('*'
                    PASSING (XMLType(bfilename('XMLPHARMA', 'db00001.xml'),nls_charset_id('AL32UTF8')))
                    COLUMNS
        drugbank_id        VARCHAR2(20)   PATH 'drug/drugbank-id',
        name               VARCHAR2(50)   PATH 'drug/name',
        description        VARCHAR2(4000) PATH 'drug/description'
    );I try to run it on the full file and get this error
    Error report:
    SQL Error: ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00007: unexpected end-of-file encountered
    31011. 00000 -  "XML parsing failed"
    *Cause:    XML parser returned an error while trying to parse the document.
    *Action:   Check if the document to be parsed is valid.The code to create schema and object-relational tables. This worked fine.
    set serveroutput on
    -- Create resource file for schema
    DECLARE
      res BOOLEAN;
    BEGIN
      res := DBMS_XDB.createResource('/home/pharma/drugbank.xsd',
                    bfilename('XMLPHARMA', 'drugbank.xsd'),
                    nls_charset_id('AL32UTF8'));
      COMMIT;
    END;
    -- optional debugging of create types and tables if you want a trace
    ALTER SESSION SET EVENTS = '31098 TRACE NAME CONTEXT FOREVER';
    BEGIN
      DBMS_XMLSCHEMA.registerSchema(
          SCHEMAURL => 'http://localhost:8080/home/pharma/drugbank.xsd',
          SCHEMADOC => bfilename('XMLPHARMA', 'drugbank.xsd'),
          CSID      => nls_charset_id('AL32UTF8'),
          LOCAL     => TRUE,
          GENTYPES  => TRUE,
          GENTABLES => TRUE,
          OWNER     => 'PHARMA');
      COMMIT;
    END;
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Release 11.2.0.2.0 - Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0      Production
    TNS for 32-bit Windows: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - ProductionThe xml schema follows. Sorry about the length, but I think I might break something if I snipped 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"
         >
         <!-- General type definitions -->
         <xs:simpleType name="DecimalOrEmptyType">
              <xs:union memberTypes="xs:decimal EmptyStringType"/>
         </xs:simpleType>
         <xs:simpleType name="EmptyStringType">
              <xs:restriction base="xs:string">
                   <xs:enumeration value=""/>
              </xs:restriction>
         </xs:simpleType>
         <!-- Element Definitions -->
         <!-- Drug secondary accession number definition begins -->
         <xs:element name="secondary-accession-numbers" xdb:defaultTable="SECONDARY_ACCESSION_NUMBERS">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element name="secondary-accession-number" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug secondary accession number definition ends -->
         <!-- Drug groups definition begins -->
         <xs:element name="groups" xdb:defaultTable="GROUPS">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element name="group">
                             <xs:simpleType>
                                  <xs:restriction base="xs:string">
                                       <xs:enumeration value="approved"/>
                                       <xs:enumeration value="illicit"/>
                                       <xs:enumeration value="experimental"/>
                                       <xs:enumeration value="withdrawn"/>
                                       <xs:enumeration value="nutraceutical"/>
                                  </xs:restriction>
                             </xs:simpleType>
                        </xs:element>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug groups definition ends -->
         <!-- Drug taxonomy definition begins -->
         <xs:element name="substructure">
              <xs:complexType>
                   <xs:simpleContent>
                        <xs:extension base="xs:string">
                             <xs:attribute name="class" type="xs:string" use="required"/>
                        </xs:extension>
                   </xs:simpleContent>
              </xs:complexType>
         </xs:element>
         <xs:element name="substructures" xdb:defaultTable="SUBSTRUCTURES">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element ref="substructure"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="taxonomy" xdb:defaultTable="TAXONOMY">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="kingdom" type="xs:string"/>
                        <xs:element ref="substructures"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug taxonomy definition ends -->
         <!-- Drug brands definition begins -->
         <xs:element name="brands" xdb:defaultTable="BRANDS">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element name="brand" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug brands definition ends -->
         <!-- Drug mixtures definition begins -->
         <xs:element name="mixture">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="name" type="xs:string"/>
                        <xs:element name="ingredients" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="mixtures" xdb:defaultTable="MIXTURES">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element ref="mixture"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug mixtures definition ends -->
         <!-- Drug packagers definition begins -->
         <xs:element name="packager">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="name" type="xs:string"/>
                        <xs:element name="url" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="packagers" xdb:defaultTable="PACKAGERS">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element ref="packager"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug packagers definition ends -->
         <!-- Drug manufacturers definition begins -->
         <xs:element name="manufacturer">
              <xs:complexType>
                   <xs:simpleContent>
                        <xs:extension base="xs:string">
                             <xs:attribute name="generic" type="xs:string" use="required"/>
                        </xs:extension>
                   </xs:simpleContent>
              </xs:complexType>
         </xs:element>
         <xs:element name="manufacturers" xdb:defaultTable="MANUFACTURERS">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element ref="manufacturer"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug manufactures definition ends -->
         <!-- Drug pricing definition begins -->
         <xs:element name="cost">
              <xs:complexType>
                   <xs:simpleContent>
                        <xs:extension base="xs:string">
                             <xs:attribute name="currency" type="xs:string" use="required"/>
                        </xs:extension>
                   </xs:simpleContent>
              </xs:complexType>
         </xs:element>
         <xs:element name="price">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="description" type="xs:string"/>
                        <xs:element ref="cost"/>
                        <xs:element name="unit" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="prices" xdb:defaultTable="PRICES">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element ref="price"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug pricing definition ends -->
         <!-- Drug categories definition begins -->
         <xs:element name="categories" xdb:defaultTable="CATEGORIES">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element name="category" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug categories definition ends -->
         <!-- Drug affected orgainsms definition begins -->
         <xs:element name="affected-organisms" xdb:defaultTable="AFFECTED_ORGANISMS">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element name="affected-organism" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug affected organisms definition ends -->
         <!-- Drug dosage definition begins -->
         <xs:element name="dosage">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="form" type="xs:string"/>
                        <xs:element name="route" type="xs:string"/>
                        <xs:element name="strength" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="dosages" xdb:defaultTable="DOSAGES">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element ref="dosage"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug dosages definition ends -->
         <!-- Drug ATC codes definition begins -->
         <xs:element name="atc-codes" xdb:defaultTable="ATC_CODES">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element name="atc-code" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug ATC codes definition ends -->
         <!-- Drug AHFS codes definition begins -->
         <xs:element name="ahfs-codes" xdb:defaultTable="AHFS_CODES">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element name="ahfs-code" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug AHFS codes definition ends -->
         <!-- Drug Patent definition begins -->
         <xs:element name="patent">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="number" type="xs:string"/>
                        <xs:element name="country" type="xs:string"/>
                        <xs:element name="approved" type="xs:string"/>
                        <xs:element name="expires" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="patents" xdb:defaultTable="PATENTS">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element ref="patent"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug patent definition ends -->
         <!-- Drug food interactions definition begins -->
         <xs:element name="food-interactions" xdb:defaultTable="FOOD_INTERACTIONS">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="food-interaction" type="xs:string" maxOccurs="unbounded" minOccurs="0"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug food interactions definition ends -->
         <!-- Drug drug interactions definition begins -->
         <xs:element name="drug-interaction">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="drug" type="xs:integer"/>
                        <xs:element name="description" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="drug-interactions" xdb:defaultTable="DRUG_INTERACTIONS">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element ref="drug-interaction"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug drug interactions definition ends -->
         <!-- Drug protein sequences (biotech) definition begins -->
         <xs:element name="protein-sequences" xdb:defaultTable="PROTEIN_SEQUENCES">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element name="protein-sequence" type="SequenceType"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug protein sequences (biotech) definition ends-->
         <!-- Drug external links definition begins -->
         <xs:element name="external-link">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="resource" type="xs:string"/>
                        <xs:element name="url" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="external-links" xdb:defaultTable="EXTERNAL_LINKS">
              <xs:complexType>
                   <xs:sequence maxOccurs="unbounded" minOccurs="0">
                        <xs:element ref="external-link"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug external links definition ends -->
         <!-- Drug targets definition begins -->
         <xs:element name="targets" xdb:defaultTable="TARGETS">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="target" type="TargetBondType" minOccurs="0" maxOccurs="unbounded"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug targets definition ends -->
         <!-- Drug enzymes definition begins -->
         <xs:element name="enzymes" xdb:defaultTable="ENZYMES">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="enzyme" type="BondType" minOccurs="0" maxOccurs="unbounded"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug enzmes definition ends -->
         <!-- Drug transporters definition begins -->
         <xs:element name="transporters" xdb:defaultTable="TRANSPORTERS">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="transporter" type="BondType" minOccurs="0" maxOccurs="unbounded"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug transporters definition ends -->
         <!-- Drug carriers definition begins -->
         <xs:element name="carriers" xdb:defaultTable="CARRIERS">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="carrier" type="BondType" minOccurs="0" maxOccurs="unbounded"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Drug carriers definition ends -->
         <!-- Partner  Pfams definition begins -->
         <xs:element name="pfam">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="identifier" type="xs:string"/>
                        <xs:element name="name" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="pfams" xdb:defaultTable="PFAMS">
              <xs:complexType>
                   <xs:sequence minOccurs="0" maxOccurs="unbounded">
                        <xs:element ref="pfam"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Partner  Pfams definition end -->
         <!-- Partner  GO Classification definition begins -->
         <xs:element name="go-classifier">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="category" type="xs:string"/>
                        <xs:element name="description" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="go-classifiers" xdb:defaultTable="GO_CLASSIFIERS">
              <xs:complexType>
                   <xs:sequence minOccurs="0" maxOccurs="unbounded">
                        <xs:element ref="go-classifier"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <!-- Partner  GO Classification definition ends -->
         <!-- Partner Essentiality definition begins -->
         <xs:element name="essentiality">
              <xs:simpleType>
                   <xs:restriction base="xs:string">
                        <xs:enumeration value="Essential"/>
                        <xs:enumeration value="Non-Essential"/>
                   </xs:restriction>
              </xs:simpleType>
         </xs:element>
         <!-- Partner Essentiality definition ends -->
         <!-- Complex Type Definitions -->
         <xs:complexType name="SequenceType">
              <xs:sequence>
                   <xs:element name="header" type="xs:string"/>
                   <xs:element name="chain" type="xs:string"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="PropertyType">
              <xs:sequence>
                   <xs:element name="kind">
                        <xs:simpleType>
                             <xs:restriction base="xs:string">
                                  <xs:enumeration value="logP"/>
                                  <xs:enumeration value="logS"/>
                                  <xs:enumeration value="logP/hydrophobicity"/>
                                  <xs:enumeration value="Water Solubility"/>
                                  <xs:enumeration value="caco2 Permeability"/>
                                  <xs:enumeration value="pKa"/>
                                  <xs:enumeration value="IUPAC Name"/>
                                  <xs:enumeration value="Molecular Weight"/>
                                  <xs:enumeration value="Monoisotopic Weight"/>
                                  <xs:enumeration value="SMILES"/>
                                  <xs:enumeration value="Molecular Formula"/>
                                  <xs:enumeration value="InChI"/>
                                  <xs:enumeration value="InChIKey"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:element>
                   <xs:element name="value" type="xs:string"/>
                   <xs:element name="source">
                        <xs:simpleType>
                             <xs:restriction base="xs:string">
                                  <xs:enumeration value="JChem"/>
                                  <xs:enumeration value="ALOGPS"/>
                                  <xs:enumeration value=""/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:element>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="PropertiesType">
              <xs:sequence>
                   <xs:element name="property" type="PropertyType" minOccurs="0" maxOccurs="unbounded"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="SynonymsType">
              <xs:sequence maxOccurs="unbounded" minOccurs="0">
                   <xs:element name="synonym" type="xs:string"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="IdentifiersType">
              <xs:sequence maxOccurs="unbounded" minOccurs="0">
                   <xs:element name="external-identifier">
                        <xs:complexType>
                             <xs:sequence>
                                  <xs:element name="resource" type="xs:string"/>
                                  <xs:element name="identifier" type="xs:string"/>
                             </xs:sequence>
                        </xs:complexType>
                   </xs:element>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="BondActionsType">
              <xs:sequence maxOccurs="unbounded" minOccurs="0">
                   <xs:element name="action" type="xs:string"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="BondType">
              <xs:sequence>
                   <xs:element name="actions" type="BondActionsType"/>
                   <xs:element name="references" type="xs:string"/>
              </xs:sequence>
              <xs:attribute name="position" type="xs:integer" use="optional"/>
              <xs:attribute name="partner" type="xs:integer"/>
         </xs:complexType>
         <xs:complexType name="TargetBondType">
              <xs:complexContent>
                   <xs:extension base="BondType">
                        <xs:sequence>
                             <xs:element name="known-action">
                                  <xs:simpleType>
                                       <xs:restriction base="xs:string">
                                            <xs:enumeration value="yes"/>
                                            <xs:enumeration value="no"/>
                                            <xs:enumeration value="unknown"/>
                                       </xs:restriction>
                                  </xs:simpleType>
                             </xs:element>
                        </xs:sequence>
                   </xs:extension>
              </xs:complexContent>
         </xs:complexType>
         <xs:complexType name="PartnerType">
              <xs:sequence>
                   <xs:element name="name" type="xs:string"/>
                   <xs:element name="general-function" type="xs:string"/>
                   <xs:element name="specific-function" type="xs:string"/>
                   <xs:element name="gene-name" type="xs:string"/>
                   <xs:element name="locus" type="xs:string"/>
                   <xs:element name="reaction" type="xs:string"/>
                   <xs:element name="signals" type="xs:string"/>
                   <xs:element name="cellular-location" type="xs:string"/>
                   <xs:element name="transmembrane-regions" type="xs:string"/>
                   <xs:element name="theoretical-pi" type="DecimalOrEmptyType"/>
                   <xs:element name="molecular-weight" type="DecimalOrEmptyType"/>
                   <xs:element name="chromosome" type="xs:string"/>
                   <xs:element ref="essentiality"/>
                   <xs:element name="references" type="xs:string"/>
                   <xs:element name="external-identifiers" type="IdentifiersType"/>
                   <xs:element name="synonyms" type="SynonymsType"/>
                   <xs:element name="protein-sequence" type="SequenceType" minOccurs="0"/>
                   <xs:element name="gene-sequence" type="SequenceType" minOccurs="0"/>
                   <xs:element ref="pfams"/>
                   <xs:element ref="go-classifiers"/>
              </xs:sequence>
              <xs:attribute name="id" type="xs:integer" use="required"/>
         </xs:complexType>
         <xs:complexType name="DrugType">
              <xs:sequence>
                   <xs:element name="drugbank-id" type="xs:string"/>
                   <xs:element name="name" type="xs:string"/>
                   <xs:element name="description" type="xs:string"/>
                   <xs:element name="cas-number" type="xs:string"/>
                   <xs:element name="general-references" type="xs:string"/>
                   <xs:element name="synthesis-reference" type="xs:string"/>
                   <xs:element name="indication" type="xs:string"/>
                   <xs:element name="pharmacology" type="xs:string"/>
                   <xs:element name="mechanism-of-action" type="xs:string"/>
                   <xs:element name="toxicity" type="xs:string"/>
                   <xs:element name="biotransformation" type="xs:string"/>
                   <xs:element name="absorption" type="xs:string"/>
                   <xs:element name="half-life" type="xs:string"/>
                   <xs:element name="protein-binding" type="xs:string"/>
                   <xs:element name="route-of-elimination" type="xs:string"/>
                   <xs:element name="volume-of-distribution" type="xs:string"/>
                   <xs:element name="clearance" type="xs:string"/>
                   <xs:element ref="secondary-accession-numbers"/>
                   <xs:element ref="groups"/>
                   <xs:element ref="taxonomy"/>
                   <xs:element name="synonyms" type="SynonymsType"/>
                   <xs:element ref="brands"/>
                   <xs:element ref="mixtures"/>
                   <xs:element ref="packagers"/>
                   <xs:element ref="manufacturers"/>
                   <xs:element ref="prices"/>
                   <xs:element ref="categories"/>
                   <xs:element ref="affected-organisms"/>
                   <xs:element ref="dosages"/>
                   <xs:element ref="atc-codes"/>
                   <xs:element ref="ahfs-codes"/>
                   <xs:element ref="patents"/>
                   <xs:element ref="food-interactions"/>
                   <xs:element ref="drug-interactions"/>
                   <xs:element ref="protein-sequences" minOccurs="0"/><!-- Only present for biotech drugs -->
                   <xs:element name="calculated-properties" type="PropertiesType" minOccurs="0"/><!-- Only present for small molecule drugs -->
                   <xs:element name="experimental-properties" type="PropertiesType"/>
                   <xs:element name="external-identifiers" type="IdentifiersType"/>
                   <xs:element ref="external-links"/>
                   <xs:element ref="targets"/>
                   <xs:element ref="enzymes"/>
                   <xs:element ref="transporters"/>
                   <xs:element ref="carriers"/>
              </xs:sequence>
              <xs:attribute name="type" use="required">
                   <xs:simpleType>
                        <xs:restriction base="xs:string">
                             <xs:enumeration value="small molecule"/>
                             <xs:enumeration value="biotech"/>
                        </xs:restriction>
                   </xs:simpleType>
              </xs:attribute>
              <xs:attribute name="updated" type="xs:string" use="required"/>
              <xs:attribute name="created" type="xs:string" use="required"/>
              <xs:attribute name="version" type="xs:decimal" use="required"/>
         </xs:complexType>
         <xs:element name="drugs"  xdb:defaultTable="DRUGS">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="drug" type="DrugType" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="partners">
                             <xs:complexType>
                                  <xs:sequence>
                                       <xs:element name="partner" type="PartnerType" minOccurs="0" maxOccurs="unbounded" />
                                  </xs:sequence>
                             </xs:complexType>
                        </xs:element>
                   </xs:sequence>
              </xs:complexType>
              <xs:keyref name="targetPartnerIdKeyRef" refer="partnerIdKey">
                   <xs:selector xpath="drug/targets/*"/>
                   <xs:field xpath="@partner"/>
              </xs:keyref>
              <xs:keyref name="enzymePartnerIdKeyRef" refer="partnerIdKey">
                   <xs:selector xpath="drug/enzymes/*"/>
                   <xs:field xpath="@partner"/>
              </xs:keyref>
              <xs:keyref name="transporterPartnerIdKeyRef" refer="partnerIdKey">
                   <xs:selector xpath="drug/transporters/*"/>
                   <xs:field xpath="@partner"/>
              </xs:keyref>
              <xs:keyref name="carrierPartnerIdKeyRef" refer="partnerIdKey">
                   <xs:selector xpath="drug/carriers/*"/>
                   <xs:field xpath="@partner"/>
              </xs:keyref>
              <xs:key name="partnerIdKey">
                   <xs:selector xpath=".//partner"/>
                   <xs:field xpath="@id"/>
              </xs:key>
         </xs:element>     
    </xs:schema>Query optimizing whitepaper
    http://www.oracle.com/technetwork/database/features/xmldb/xmlqueryoptimize11gr2-168036.pdf

    I attempted to insert the xml file into an xml table and into a relational table with an xml column both based on the schema. I get the same errors.
    -This creates an XML table based on the schema successfully
    CREATE TABLE pharma.drugs_xmltype OF XMLTYPE
    XMLSCHEMA "http://localhost:8080/home/pharma/drugbank.xsd"
    ELEMENT "drugs";
    Table created.
    Elapsed: 00:00:02.67
    SQL>desc pharma.drugs_xmltype
    Name                                                                          Null?    Type
    TABLE of SYS.XMLTYPE(XMLSchema "http://localhost:8080/home/pharma/drugbank.xsd" Element "drugs") STORAGE Object-relational TYPE "drugs1200_T"-- it refers to these types
    create or replace TYPE          "drugs1200_T" AS OBJECT ("SYS_XDBPD$" "XDB"."XDB$RAW_LIST_T","drug" "drug1201_COLL","partners" "partners1202_T")FINAL INSTANTIABLE
    create or replace TYPE          "drug1201_COLL" AS VARRAY(2147483647) OF "DrugType1121_T"
    create or replace TYPE          "partners1202_T" AS OBJECT ("SYS_XDBPD$" "XDB"."XDB$RAW_LIST_T","partner" "partner1203_COLL")FINAL INSTANTIABLE
    create or replace TYPE          "partner1203_COLL" AS VARRAY(2147483647) OF "PartnerType1190_T"
    create or replace TYPE          "DrugType1121_T" AS OBJECT ("SYS_XDBPD$" "XDB"."XDB$RAW_LIST_T","type" "XDB"."XDB$ENUM_T","updated" VARCHAR2(4000 CHAR),"created" VARCHAR2(4000 CHAR),"version" NUMBER,"drugbank-id" VARCHAR2(4000 CHAR),"name" VARCHAR2(4000 CHAR),"description" VARCHAR2(4000 CHAR),"cas-number" VARCHAR2(4000 CHAR),"general-references" VARCHAR2(4000 CHAR),"synthesis-reference" VARCHAR2(4000 CHAR),"indication" VARCHAR2(4000 CHAR),"pharmacology" VARCHAR2(4000 CHAR),"mechanism-of-action" VARCHAR2(4000 CHAR),"toxicity" VARCHAR2(4000 CHAR),"biotransformation" VARCHAR2(4000 CHAR),"absorption" VARCHAR2(4000 CHAR),"half-life" VARCHAR2(4000 CHAR),"protein-binding" VARCHAR2(4000 CHAR),"route-of-elimination" VARCHAR2(4000 CHAR),"volume-of-distribution" VARCHAR2(4000 CHAR),"clearance" VARCHAR2(4000 CHAR),"secondary-accession-numbers" "secondary-accession1122_T","groups" "groups1124_T","taxonomy" "taxonomy1126_T","synonyms" "SynonymsType1131_T","brands" "brands1132_T","mixtures" "mixtures1133_T","packagers" "packagers1137_T","manufacturers" "manufacturers1141_T","prices" "prices1145_T","categories" "categories1151_T","affected-organisms" "affected-organisms1152_T","dosages" "dosages1153_T","atc-codes" "atc-codes1157_T","ahfs-codes" "ahfs-codes1158_T","patents" "patents1159_T","food-interactions" "food-interactions1163_T","drug-interactions" "drug-interactions1164_T","protein-sequences" "protein-sequences1168_T","calculated-properties" "PropertiesType1171_T","experimental-properties" "PropertiesType1171_T","external-identifiers" "IdentifiersType1174_T","external-links" "external-links1177_T","targets" "targets1181_T","enzymes" "enzymes1186_T","transporters" "transporters1188_T","carriers" "carriers1189_T")NOT FINAL INSTANTIABLE -- drugs type
    PHARMA@scidev> desc "drugs1200_T"
    Name          Null?    Type
    SYS_XDBPD$             XDB.XDB$RAW_LIST_T
    drug                   drug1201_COLL
    partners               partners1202_T-- I planned to insert using a subselect and got the same error on the select.
    Error starting at line 1 in command:
    SELECT max(length(drugbank_id)) AS dbidlen
    FROM (XMLTABLE('*'
                    PASSING (XMLType(bfilename('XMLPHARMA', 'drugbank.xml'),nls_charset_id('AL32UTF8')))
                    COLUMNS
        drugbank_id        VARCHAR2(20)   PATH 'drug/drugbank-id'
    Error report:
    SQL Error: ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00007: unexpected end-of-file encountered
    31011. 00000 -  "XML parsing failed"
    *Cause:    XML parser returned an error while trying to parse the document.
    *Action:   Check if the document to be parsed is valid.--This creates a row in the xmltype table from a single drug file.
    INSERT INTO drugs_xmltype
    VALUES(XMLType(bfilename('XMLPHARMA', 'db00001.xml'),nls_charset_id('AL32UTF8')).CreateSchemaBasedXML(
        'http://localhost:8080/home/pharma/drugbank.xsd'))
    ;-- The create using the full xml file fails.
    INSERT INTO drugs_xmltype
    VALUES(XMLType(bfilename('XMLPHARMA', 'drugbank.xml'),nls_charset_id('AL32UTF8')).CreateSchemaBasedXML(
    'http://localhost:8080/home/pharma/drugbank.xsd'))
    VALUES(XMLType(bfilename('XMLPHARMA', 'drugbank.xml'),nls_charset_id('AL32UTF8')).CreateSchemaBasedXML(
    ERROR at line 2:
    ORA-30951: Element or attribute at Xpath references exceeds maximum length
    Elapsed: 00:01:17.90-- Then I tried the same using a relational table with an xml column
    -- Then I created a relational table with an xml column
    CREATE TABLE pharma.drugs_xmlcolumn_type (drug_xml XMLTYPE)
    XMLTYPE COLUMN drug_xml STORE AS OBJECT RELATIONAL
    XMLSCHEMA "http://localhost:8080/home/pharma/drugbank.xsd"
    ELEMENT "drugs";
    CREATE TABLE succeeded.--This command refers to the following types
    SYS.XMLTYPE(XMLSchema "http://localhost:8080/home/pharma/drugbank.xsd" Element "drugs" ) STORAGE Object-relational TYPE "drugs1200_T"-- This creates a row in the xmlcolumn table from a single drug file.
    INSERT INTO drugs_xmlcolumn_type
    VALUES(XMLType(bfilename('XMLPHARMA', 'db00001.xml'),nls_charset_id('AL32UTF8')).CreateSchemaBasedXML(
        'http://localhost:8080/home/pharma/drugbank.xsd'))
    ;--The create using the full xml file into a relational table with an xml column fails
    INSERT INTO drugs_xmlcolumn_type
    VALUES(XMLType(bfilename('XMLPHARMA', 'drugbank.xml'),nls_charset_id('AL32UTF8')).CreateSchemaBasedXML(
    'http://localhost:8080/home/pharma/drugbank.xsd'))
    VALUES(XMLType(bfilename('XMLPHARMA', 'drugbank.xml'),nls_charset_id('AL32UTF8')).CreateSchemaBasedXML(
    ERROR at line 2:
    ORA-30951: Element or attribute at Xpath references exceeds maximum length
    Elapsed: 00:01:06.74

  • Lax validation errors on schema import ('version' exceeds maximum length)

    I have a schema as per below. I'm trying to import it into Oracle 10.2.0.2.0. However, I'm getting the following lax validation error:
    Error loading ora_business_rule.xsd:ORA-30951: Element or attribute at Xpath /schema[@version] exceeds maximum length
    I can fix it by modifying the attribute and shortening it but I'd like to know why it's occuring. Insofar as I can tell there is no imposed limit on the size of schema attributes according to the W3C standard. Which then makes me wonder: does Oracle impose limits on the length of all attributes or is this specific to 'version' ? If there is a limit, what is the upper bound (in bytes) ? Where is this documented?
    Cheers,
    Daniel
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:br="http://foo.com/BusinessRule_PSG_V001" targetNamespace="http://foo.com/BusinessRule_PSG_V001" elementFormDefault="qualified" attributeFormDefault="unqualified" version="last committed on $LastChangedDate: 2006-05-19 11:00:52 +1000 (Fri, 19 May 2006) $">
         <xs:element name="edit">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="edit_id" type="xs:string"/>
                        <xs:element ref="br:business_rule"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="derivation">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="derivation_id" type="xs:string"/>
                        <xs:element ref="br:derivation_type"/>
                        <xs:element ref="br:business_rule"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="derivation_type">
              <xs:simpleType>
                   <xs:restriction base="xs:NMTOKENS">
                        <xs:enumeration value="complex"/>
                        <xs:enumeration value="format"/>
                        <xs:enumeration value="formula"/>
                        <xs:enumeration value="recode"/>
                        <xs:enumeration value="SAS code"/>
                        <xs:enumeration value="transfer"/>
                        <xs:enumeration value="count"/>
                        <xs:enumeration value="sum"/>
                        <xs:enumeration value="max"/>
                        <xs:enumeration value="min"/>
                   </xs:restriction>
              </xs:simpleType>
         </xs:element>
         <xs:element name="business_rule"></xs:element>
    </xs:schema>

    Opps -- Sorry it's a decision we took when looking at Version
    When we registered the Schema for Schemas during XDB bootstrap the Version attriubte was mapped to varchar2(12).
    SQL> desc xdb.xdb$schema_T
    Name                                      Null?    Type
    SCHEMA_URL                                         VARCHAR2(700)
    TARGET_NAMESPACE                                   VARCHAR2(2000)
    VERSION                                            VARCHAR2(12)
    NUM_PROPS                                          NUMBER(38)
    FINAL_DEFAULT                                      XDB.XDB$DERIVATIONCHOICE
    BLOCK_DEFAULT                                      XDB.XDB$DERIVATIONCHOICE
    ELEMENT_FORM_DFLT                                  XDB.XDB$FORMCHOICE
    ATTRIBUTE_FORM_DFLT                                XDB.XDB$FORMCHOICE
    ELEMENTS                                           XDB.XDB$XMLTYPE_REF_LIST_T
    SIMPLE_TYPE                                        XDB.XDB$XMLTYPE_REF_LIST_T
    COMPLEX_TYPES                                      XDB.XDB$XMLTYPE_REF_LIST_T
    ATTRIBUTES                                         XDB.XDB$XMLTYPE_REF_LIST_T
    IMPORTS                                            XDB.XDB$IMPORT_LIST_T
    INCLUDES                                           XDB.XDB$INCLUDE_LIST_T
    FLAGS                                              RAW(4)
    SYS_XDBPD$                                         XDB.XDB$RAW_LIST_T
    ANNOTATIONS                                        XDB.XDB$ANNOTATION_LIST_T
    MAP_TO_NCHAR                                       RAW(1)
    MAP_TO_LOB                                         RAW(1)
    GROUPS                                             XDB.XDB$XMLTYPE_REF_LIST_T
    ATTRGROUPS                                         XDB.XDB$XMLTYPE_REF_LIST_T
    ID                                                 VARCHAR2(256)
    VARRAY_AS_TAB                                      RAW(1)
    SCHEMA_OWNER                                       VARCHAR2(30)
    NOTATIONS                                          XDB.XDB$NOTATION_LIST_T
    LANG                                               VARCHAR2(4000)
    SQL>

  • How does XML DB handle XML Schema Validation ?

    In order to validate an XML document against an XML Schema using Oracle XML DB the XML Schema must first be registered with XML DB using the method registerSchema provided by the package DBMS_XMLSCHEMA.
    XDB provides two types of schema validation, 'Lax' Validation and 'Strict' Validation.
    'Lax' validation takes place whenever a schema based document is converted from it's textual representation into the XML DB internal object model. Errors caught by this validation will be prefixed with 'ORA'.
    'Stict' validation takes place when the XMLType methods schemaValidate() or isSchemaValid() are invoked.
    The schemaValidate() method throws an exception with an error message indicating what is wrong it encounteres an invalid document. The error message associated with the exception will be prefixed with LSX.
    The isSchemaValid() method returns true or false, depending on whether or not the document is valid. It cannot return any information about why the document is invalid.
    The reason for having both the Lax and Strict validation models is that Strict validation is much more expensive in terms of CPU and memory usage than Lax validation.

    Here are some examples of what is caught by Lax validation (ORA errors) and what is only caught by Strict validation (LSX errors).
    SQL> begin
      2     dbms_xmlschema.registerSchema('test',xmltype(
      3  '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.co
    eFormDefault="unqualified">
      4     <xs:complexType name="RootType">
      5             <xs:sequence>
      6                     <xs:element name="Mandatory"/>
      7                     <xs:element name="Enumeration">
      8                             <xs:simpleType>
      9                                     <xs:restriction base="xs:string">
    10                                             <xs:enumeration value="A"/>
    11                                             <xs:enumeration value="B"/>
    12                                             <xs:enumeration value="C"/>
    13                                     </xs:restriction>
    14                             </xs:simpleType>
    15                     </xs:element>
    16                     <xs:element name="MinLength">
    17                             <xs:simpleType>
    18                                     <xs:restriction base="xs:string">
    19                                             <xs:minLength value="4"/>
    20                                             <xs:maxLength value="20"/>
    21                                     </xs:restriction>
    22                             </xs:simpleType>
    23                     </xs:element>
    24                     <xs:element name="MaxLength">
    25                             <xs:simpleType>
    26                                     <xs:restriction base="xs:string">
    27                                             <xs:minLength value="1"/>
    28                                             <xs:maxLength value="4"/>
    29                                     </xs:restriction>
    30                             </xs:simpleType>
    31                     </xs:element>
    32                     <xs:element name="MaxOccurs" type="xs:string" maxOccurs="2"/>
    33                     <xs:element name="MinOccurs" minOccurs="2" maxOccurs="2"/>
    34                     <xs:element name="Optional" type="xs:string" minOccurs="0"/>
    35             </xs:sequence>
    36     </xs:complexType>
    37     <xs:element name="Root" type="RootType" xdb:defaultTable="ROOT_TABLE"/>
    38  </xs:schema>'));
    39  end;
    40  /
    PL/SQL procedure successfully completed.
    SQL> --
    SQL> -- Valid Document
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  /
    1 row created.
    SQL> --
    SQL> -- Undefined element 'Illegal'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Illegal>Hello World</Illegal>
      5     <Enumeration>A</Enumeration>
      6     <MinLength>ABCD</MinLength>
      7     <MaxLength>WXYZ</MaxLength>
      8     <MaxOccurs>1</MaxOccurs>
      9     <MaxOccurs>2</MaxOccurs>
    10     <MinOccurs>1</MinOccurs>
    11     <MinOccurs>2</MinOccurs>
    12     <Optional>Goodbye</Optional>
    13  </Root>'
    14  ))
    15  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30937: No schema definition for 'Illegal' (namespace '##local') in parent
    '/Root'
    SQL> --
    SQL> -- Multiple occurences of 'Optional'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12     <Optional>Goodbye</Optional>
    13  </Root>'
    14  ))
    15  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30936: Maximum number (1) of 'Optional' XML node elements exceeded
    SQL> --
    SQL> -- Missing element 'Manadatory'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Enumeration>A</Enumeration>
      4     <MinLength>ABCD</MinLength>
      5     <MaxLength>WXYZ</MaxLength>
      6     <MaxOccurs>1</MaxOccurs>
      7     <MaxOccurs>2</MaxOccurs>
      8     <MinOccurs>1</MinOccurs>
      9     <MinOccurs>2</MinOccurs>
    10     <Optional>Goodbye</Optional>
    11  </Root>'
    12  ))
    13  /
    1 row created.
    SQL> --
    SQL> -- Invalid Enumeration Value
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>Z</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-31038: Invalid enumeration value: "Z"
    SQL> --
    SQL> -- MinLength Violation
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABC</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  --
    15  -- MaxLength Violation
    16  --
    17  /
    1 row created.
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>VWXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30951: Element or attribute at Xpath /Root/MaxLength exceeds maximum length
    SQL> --
    SQL> -- Missing element Optional - Valid Document
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11  </Root>'
    12  ))
    13  /
    1 row created.
    SQL> --
    SQL> -- Too many instances of 'MaxOccurs'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MaxOccurs>3</MaxOccurs>
    10     <MinOccurs>1</MinOccurs>
    11     <MinOccurs>2</MinOccurs>
    12     <Optional>Goodbye</Optional>
    13  </Root>'
    14  ))
    15  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30936: Maximum number (2) of 'MaxOccurs' XML node elements exceeded
    SQL> --
    SQL> -- Too few instances of 'MinOccurs'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <Optional>Goodbye</Optional>
    11  </Root>'
    12  ))
    13  /
    1 row created.
    SQL> create trigger validateSchema
      2  before insert on ROOT_TABLE
      3  for each row
      4  begin
      5     :new.object_value.schemaValidate();
      6  end;
      7  /
    Trigger created.
    SQL> --
    SQL> -- Valid Document
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  /
    1 row created.
    SQL> --
    SQL> -- Undefined element 'Illegal'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Illegal>Hello World</Illegal>
      5     <Enumeration>A</Enumeration>
      6     <MinLength>ABCD</MinLength>
      7     <MaxLength>WXYZ</MaxLength>
      8     <MaxOccurs>1</MaxOccurs>
      9     <MaxOccurs>2</MaxOccurs>
    10     <MinOccurs>1</MinOccurs>
    11     <MinOccurs>2</MinOccurs>
    12     <Optional>Goodbye</Optional>
    13  </Root>'
    14  ))
    15  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30937: No schema definition for 'Illegal' (namespace '##local') in parent
    '/Root'
    SQL> --
    SQL> -- Multiple occurences of 'Optional'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12     <Optional>Goodbye</Optional>
    13  </Root>'
    14  ))
    15  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30936: Maximum number (1) of 'Optional' XML node elements exceeded
    SQL> --
    SQL> -- Missing element 'Manadatory'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Enumeration>A</Enumeration>
      4     <MinLength>ABCD</MinLength>
      5     <MaxLength>WXYZ</MaxLength>
      6     <MaxOccurs>1</MaxOccurs>
      7     <MaxOccurs>2</MaxOccurs>
      8     <MinOccurs>1</MinOccurs>
      9     <MinOccurs>2</MinOccurs>
    10     <Optional>Goodbye</Optional>
    11  </Root>'
    12  ))
    13  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-31154: invalid XML document
    ORA-19202: Error occurred in XML processing
    LSX-00213: only 0 occurrences of particle "Mandatory", minimum is 1
    ORA-06512: at "SYS.XMLTYPE", line 345
    ORA-06512: at "XDBTEST.VALIDATESCHEMA", line 2
    ORA-04088: error during execution of trigger 'XDBTEST.VALIDATESCHEMA'
    SQL> --
    SQL> -- Invalid Enumeration Value
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>Z</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-31038: Invalid enumeration value: "Z"
    SQL> --
    SQL> -- MinLength Violation
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABC</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  --
    15  -- MaxLength Violation
    16  --
    17  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-31154: invalid XML document
    ORA-19202: Error occurred in XML processing
    LSX-00221: "ABC" is too short (minimum length is 4)
    ORA-06512: at "SYS.XMLTYPE", line 345
    ORA-06512: at "XDBTEST.VALIDATESCHEMA", line 2
    ORA-04088: error during execution of trigger 'XDBTEST.VALIDATESCHEMA'
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>VWXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11     <Optional>Goodbye</Optional>
    12  </Root>'
    13  ))
    14  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30951: Element or attribute at Xpath /Root/MaxLength exceeds maximum length
    SQL> --
    SQL> -- Missing element Optional - Valid Document
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <MinOccurs>2</MinOccurs>
    11  </Root>'
    12  ))
    13  /
    1 row created.
    SQL> --
    SQL> -- Too many instances of 'MaxOccurs'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MaxOccurs>3</MaxOccurs>
    10     <MinOccurs>1</MinOccurs>
    11     <MinOccurs>2</MinOccurs>
    12     <Optional>Goodbye</Optional>
    13  </Root>'
    14  ))
    15  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-30936: Maximum number (2) of 'MaxOccurs' XML node elements exceeded
    SQL> --
    SQL> -- Too few instances of 'MinOccurs'
    SQL> --
    SQL> insert into ROOT_TABLE values (xmltype(
      2  '<Root>
      3     <Mandatory>Hello World</Mandatory>
      4     <Enumeration>A</Enumeration>
      5     <MinLength>ABCD</MinLength>
      6     <MaxLength>WXYZ</MaxLength>
      7     <MaxOccurs>1</MaxOccurs>
      8     <MaxOccurs>2</MaxOccurs>
      9     <MinOccurs>1</MinOccurs>
    10     <Optional>Goodbye</Optional>
    11  </Root>'
    12  ))
    13  /
    insert into ROOT_TABLE values (xmltype(
    ERROR at line 1:
    ORA-31154: invalid XML document
    ORA-19202: Error occurred in XML processing
    LSX-00213: only 1 occurrences of particle "MinOccurs", minimum is 2
    ORA-06512: at "SYS.XMLTYPE", line 345
    ORA-06512: at "XDBTEST.VALIDATESCHEMA", line 2
    ORA-04088: error during execution of trigger 'XDBTEST.VALIDATESCHEMA'
    SQL>

  • Xml attachements

    I've created a xmlschema and registered it. The xml documents load fine into the schema. I run validation via a trigger and I see the error reported when the trigger is fired for "Ora-22814: attribute or element value is larger than specified type" this is good, but I was wondering if there is a way to report exactly which element in the xsd/xmlschema is throwing the error and report it back to the pl/sql session or the ftp session. Additionally I want the user to have a error report of problems with their xml doc when loading, so I want to save any errors in a table or somewhere for other sessions to view what errors the xml doc produced and generate a report of the xml doc loading issues.
    Any documents or sample code you can point me to?
    TIA

    SQL> grant create any directory, drop any directory to scott
    2 /
    Grant succeeded.
    SQL> connect scott/tiger
    Connected.
    SQL> create or replace directory temp as 'c:\temp';
    Directory created.
    SQL> insert into purchaseorder values (xmltype(bfilename('TEMP','test.xml'),nls_charset_id('AL32UTF8')))
    2 /
    insert into purchaseorder values (xmltype(bfilename('TEMP','test.xml'),nls_charset_id('AL32UTF8')))
    ERROR at line 1:
    ORA-30951: Element or attribute at Xpath /PurchaseOrder/Reference exceeds
    maximum length

  • PL/SQL report errors: ORA-01422

    Hi all,
    (before i you read i would like to say i have searched the net for this error code but nothing shows up like this problem..)
    I am getting an error problem when i select certain Schemas from a list on an apex app. page, it only works for some schemas not all..
    When i select one schema, it is supposed to display one row.. when i select [ALL] it is supposed to show them all.
    It does work if i select '[ALL]' from the select list (p3_schema_name), just not for every single individual one.
    the error code:
    ORA-01422: exact fetch returns more than requested number of rows
    declare
      vSchema  varchar2(20);
      vStmt  varchar2(1000);
      vVersion number(5);
      vDBName  varchar2(20);
      vHostName varchar2(80);
      vStmt2  varchar2(1000);
      vVersion2 number(5);
      vDBName2  varchar2(20);
      vServer2 varchar2(80);
      vSchema2 varchar2(80);
      CURSOR c_schemas IS
        select owner from dba_tables@P3_DB_NAME.db_link where table_name = 'DDL_LOG' and num_rows > 0 order by owner;
    begin
      IF :P3_SCHEMA_NAME != '[ALL]' AND :P3_DB_NAME IS NOT NULL AND :P3_SERVER_NAME IS NOT NULL THEN
        vServer2 := :P3_SERVER_NAME;
        vSchema2 := :P3_SCHEMA_NAME;
          vStmt2 := 'select distinct DDH_DB_NM, max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from &P3_SCHEMA_NAME..ddl_log@&P3_DB_NAME.db_link GROUP BY DDH_DB_NM';
          Execute Immediate vStmt2 into vDBName2, vVersion2;
            htp.p('<br>');
            htp.p('<table border="1">');
            htp.p('<tr>');
            htp.p('<th bgcolor="#FFCC99">SERVER NAME</th>');
            htp.p('<th bgcolor="#FFCC99">DB NAME</th>');
            htp.p('<th bgcolor="#FFCC99">SCHEMA NAME</th>');
            htp.p('<th bgcolor="#FFCC99">PATCH</th>');
            htp.p('</tr>');
            htp.p('<tr>');
            htp.p('<td>');
            htp.p(vServer2);
            htp.p('</td>');
            htp.p('<td>');
            htp.p(vDBName2);
            htp.p('</td>');
            htp.p('<td>');
            htp.p(vSchema2);
            htp.p('</td>');
            htp.p('<td>');
            htp.p(vVersion2);
            htp.p('</td>');
            htp.p('<td>');
            htp.p('<BR>');
            htp.p('</td>');
            htp.p('</tr>');
            htp.p('</tr>');
            htp.p('</table>');
       ELSE IF :P3_SCHEMA_NAME = '[ALL]' AND :P3_DB_NAME IS NOT NULL AND :P3_SERVER_NAME IS NOT NULL THEN
       vHostName := :P3_SERVER_NAME;
       vDBName := :P3_DB_NAME;
         open c_schemas;
          htp.p('<br>');
          htp.p('<table border="1">');
          htp.p('<tr>');
          htp.p('<th bgcolor="#FFCC99">SERVER NAME</th>');
          htp.p('<th bgcolor="#FFCC99">DB NAME</th>');
          htp.p('<th bgcolor="#FFCC99">SCHEMA NAME</th>');
          htp.p('<th bgcolor="#FFCC99">PATCH</th>');
          htp.p('</tr>');
        LOOP
          FETCH c_schemas INTO vSchema;
          EXIT WHEN c_schemas%NOTFOUND;
          vStmt  := 'select max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from '||vSchema||'.ddl_log@&P3_DB_NAME.db_link where DDH_SCHEMA_NR = (select max(DDH_SCHEMA_NR) from '||vSchema||'.ddl_log@&P3_DB_NAME.db_link) and rownum < 2' ;
          Execute Immediate vStmt into vVersion  ;
          htp.p('<tr>');
          htp.p('<td>');
          htp.p(vHostName);
          htp.p('</td>');
          htp.p('<td>');
          htp.p(vDBName);
          htp.p('</td>');
          htp.p('<td>');
          htp.p(vSchema);
          htp.p('</td>');
          htp.p('<td>');
          htp.p(vVersion);
          htp.p('</td>');
          htp.p('<td>');
          htp.p('<BR>');
          htp.p('</td>');
          htp.p('</tr>');
        END LOOP;
          htp.p('</tr>');
          htp.p('</table>');  
      CLOSE c_schemas;
    END IF;
    END IF;
    END;I have checked the DDH_SCHEMA_NR for repeating entries of the highest number.. some of the ones that dont work do have repeating entries some don't.
    Sorry if this is confusing, i have tried to explain it as best as i can.
    Thanks in advance for any help.
    Ashleigh

    Hello Ashleigh,
    Based on your code, I'd start by running this piece of SQL via command-line (thru SQL Workshop, SQL*Plus, Toad, etc.), replacing &P3_SCHEMA_NAME. and &P3_DB_NAME. with values that are currently causing the routine to fail and see if it returns more than one row. I don't know your data, but DISTINCT and GROUP BY are typically used to return multiple (though grouped/summarized) rows. It appears to be the only statement that would cause the error your seeing (more than one row being returned into single variables).
    select distinct DDH_DB_NM, max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from &P3_SCHEMA_NAME..ddl_log@&P3_DB_NAME.db_link GROUP BY DDH_DB_NM;I'm actually surprised that the code runs at all. I didn't think 'execute immediate' would know what to do with substitutions indicated as "&something." (I've typically seen that when substituting in dynamic HTML/Javascript code but maybe I'm learning something new). But since you already have vServer2 and vSchema2, I'd be more apt to code it as:
    vStmt2 := 'select distinct DDH_DB_NM, max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from ' ||
    vSchema2 || '.ddl_log@' || vServer2 || '.db_link GROUP BY DDH_DB_NM';Hope this helps,
    John

  • Ora-00604 error and ora 01000 error while report generation.

    hi all,
    I am trying to generate the multiple reports of same template through a program.
    While this job is running, i get the following error at the BIP console and the reports don't get generated.
    [101711_044115578][][EXCEPTION] java.sql.SQLException: ORA-00604: error occurred
    at recursive SQL level 1
    ORA-01000: maximum open cursors exceeded
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01000: maximum open cursors exceeded
    ORA-01000: maximum open cursors exceeded
    Kindly help.
    Thanks.

    Lots of resources with a simple search to see what this is about, for example:
    http://www.orafaq.com/wiki/ORA-01000
    ORA-01000:     maximum open cursors exceeded
    Cause:     A host language program attempted to open too many cursors. The initialization parameter OPEN_CURSORS determines the maximum number of cursors per user.
    Action:     Modify the program to use fewer cursors. If this error occurs often, shut down Oracle, increase the value of OPEN_CURSORS, and then restart Oracle.
    open_cursors parameter
    http://download.oracle.com/docs/cd/E11882_01/server.112/e25513/initparams160.htm#REFRN10137
    Oracle support note:
    OERR: ORA-1000 maximum open cursors exceeded (Doc ID 18591.1)

  • EA2: ORA-01427 clicking on a view in the navigator

    SQLDev: 1.5.0.52.03
    Java: 1.6.0_04
    Oracle: 9.2.0.7.0
    I'm getting the following error when I click on a view in the navigator pane:
    An error was encountered performing the requested operation:
    ORA-01427: single-row subquery returns more than one row 01427. 00000 - "single-row subquery returns more than one row"I'm not seeing any errors in the shell window.
    After clicking on <OK> in the error dialog, the normal tabs (Columns, Data, Grants, Dependencies, Details, SQL) are displayed, but there is no content in the Columns tab.
    All the other tabs seem to function normally.
    Here is the DDL from the SQL tab
    CREATE OR REPLACE VIEW "SUBSCRIPTIONS"
        "ORDER_ID", "SUNBURST_ORDER_ID", "SIEBEL_ORDER_ID", "ACCOUNT_ID",
        "COMP_ID", "SUBACCOUNT_ID", "START_DATE", "END_DATE", "PULL_DATE",
        "SUBSCRIPTION_TYPE", "PRICE_CLASS", "DESCRIPTION", "SEAT_COUNT",
        "ORDER_DURATION", "CALLBACK_INTERVAL", "UPDATE_DATE", "UPDATE_USERNAME",
        "AFFILIATE"
    AS
        SELECT order_id,
            sunburst_order_id,
            siebel_order_id,
            account_id,
            comp_id,
            subaccount_id,
            start_date,
            end_date,
            pull_date,
            product_id,
            price_class,
            product_name,
            add_users,
            order_duration,
            callback_interval,
            last_mdfy_date,
            last_mdfy_emp,
            affiliate
        FROM csbcrossworlds.subscriptions;We have 15 views in this schema, 3 of them fail this way but the other 12 display the columns just fine. So far I am unable to detect any commonality.
    Any ideas?

    Ok, I think I found the problem. The view in question (SUBSCRIPTIONS) is owned by 'PHILC' and it references a table named 'SUBSCRIPTIONS' owned by 'CSBCROSSWORLDS'. There are two other development schemas that also own tables named 'SUBSCRIPTIONS'.
    I believe the 'Columns' tab is executing the query below. The subquery in this SQL tries to identify the primary key columns for the 'SUBSCRIPTIONS' view in my schema (PHILC):
    SELECT
        c.column_name,
        DECODE(
            data_type,
                'CHAR',      data_type||'('||c.data_length||')',
                'VARCHAR',   data_type||'('||c.data_length||')',
                'VARCHAR2',  data_type||'('||c.data_length||')',
                'NCHAR'   ,  data_type||'('||c.data_length||')',
                'NUMBER'  ,  DECODE(c.data_precision,null,'NUMBER', data_type||'('||c.data_precision||','||c.data_SCALE||')'),
                'NVARCHAR',  data_type||'('||c.data_length||')',
                'NVARCHAR2', data_type||'('||c.data_length||')',
                data_type) data_type,
        DECODE(nullable, 'Y', 'Yes', 'No') nullable,
        c.DATA_DEFAULT,
        column_id,
        com.comments,
        (SELECT 1 FROM all_constraints, all_cons_columns
          WHERE all_constraints.constraint_type = 'P' AND
                all_constraints.constraint_name = all_cons_columns.constraint_name AND
                all_constraints.owner = all_cons_columns.owner AND
                all_cons_columns.table_name = c.table_name AND
                c.column_name = all_cons_columns.column_name) Primary_Key,
        c_update.insertable,
        c_update.updatable,
        c_update.deletable
    FROM
        sys.all_tab_Columns c, sys.all_col_comments com, sys.user_updatable_columns c_update
    WHERE
        c.owner = :OBJECT_OWNER AND
        c.table_name = :OBJECT_NAME AND
        c.table_name = com.table_name AND
        c.owner = com.owner AND
        c.column_name = com.column_name AND
        c_update.column_name = com.column_name AND
        c_update.table_name = com.table_name
    ;Extracting the subquery into this:
    SELECT
        all_constraints.owner,
        all_constraints.table_name,
        all_constraints.constraint_name
    FROM all_constraints, all_cons_columns
    WHERE
        all_constraints.constraint_type = 'P' AND
        all_constraints.constraint_name = all_cons_columns.constraint_name AND
        all_constraints.owner = all_cons_columns.owner and
        all_cons_columns.table_name = 'SUBSCRIPTIONS' and
        'ORDER_ID' = all_cons_columns.column_name;I got this output:
       owner          table_name      constraint_name
    CUTOVER          SUBSCRIPTIONS    SUBSCRIPTIONS_PK
    CROSSWORLDS      SUBSCRIPTIONS    SUBSCRIPTIONS_PK
    CSBCROSSWORLDS   SUBSCRIPTIONS    SUBSCRIPTIONS_PKLooking at the DDL for the view, the row we really want is for owner 'CSBCROSSWORLDS'. Unfortunately, that means having to somehow parse the SQL text to extract the owner name...
    Phil

  • Using database-link in view to get around ORA-01031 error

    I have been granted select rights on a users table. I am therefore able to select from his table. If however I try create a view against his table I run into the ORA-01031 problem. I have worked around this problem by creating a database-link to myself and then adding that to the view creation and it works. What are the downsides of using the database-link in this way?

    The only down side I have been able to identify is that a extra session is created and that the CPU has a little extra work due to the LOOP BACK that takes place. I need to ensure the network is not unnessesarly used and therefore will need to ensure that 127.0.0.1 (local host) is used in the database connection discription. e.g.
    create database link my_db_link connect to scott identified by tiger using '(description=(address=(protocol=tcp)(host=127.0.0.1) (Port = 1521) ) (connect_data= (sid=ora10g)))';

Maybe you are looking for