Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Dhananjaya.

Asked: June 01, 2001 - 4:56 pm UTC

Last updated: November 26, 2006 - 7:49 pm UTC

Version: 8i (8.1.6)

Viewed 10K+ times! This question is

You Asked

Hi Tim,

Can you give me brief discription about loading data to oracle table when the data is given in XML files.



and Tom said...

Well there are quite a few ways to do it.

</code> http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:1405403846139

shows how to load the XML straight in


You could also read the XML in using a BFILE and use either java or plsql to parse it and insert it.  See
http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:441019930865 <code>


search for XML on my site and you'll see a couple more examples/questions.



Rating

  (18 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

reading files with attributes and just frontslash (/) as the element terminator

Nihal singh, June 01, 2002 - 6:56 am UTC

Hi tom,
can u give an example or a link to the example where in a xml file with elements and Attributes is read.
for eg lets say i have the following xml file ,i can view it through I.E. but loading it through a normal stored procedure gives error i guess it because of the attributes and just frontslash (/) as the terminator,
now i need to load it without any change to the way xml file has been generated.
---------------
- <Common>
<Client ClientID="98092" ClientName="DEBORAH WALL AGENCY" IRDNumber="26-969-212" DOB="00/00/0000" TactAccountNo="TACT1" />
<Client ClientID="405631" ClientName="MR MURRAY JOHN HAYTERIAN B And THELMA M HAYTER AS TRUSTEES" IRDNumber="13-449-187" DOB="00/00/0000" TactAccountNo="405631" />
<Client ClientID="417186" ClientName="VALDA SPIERS" IRDNumber="19-040-763" DOB="00/00/0000" TactAccountNo="417186" />
</Common>

-------------------------------------------------
I based my stored procedure on the eg given where in u can load the xml into clob and then into the table, but that didnt work.


Thanks

Nihal Singh

Tom Kyte
June 03, 2002 - 12:47 pm UTC

I asked Sean Dillon, our local XML guru, to take a look at this and here's what he had to say:
--

If you want to use the XML SQL Utility to "auto-load" your XML into relational tables, you need to transform your XML into Oracle's "canonical XML format". The XML you have listed above isn't valid in unto itself, you need an XML prolog, i.e.:

<?xml version="1.0">

Using XSLT in the database, you need to convert the XML document you store in your CLOB column:


<?xml version="1.0"?>
<Common>
<Client ClientID="98092"
ClientName="DEBORAH WALL AGENCY"
IRDNumber="26-969-212"
DOB="00/00/0000"
TactAccountNo="TACT1" />
<Client ClientID="405631"
ClientName="MR MURRAY JOHN HAYTERIAN B And THELMA M HAYTER AS TRUSTEES"
IRDNumber="13-449-187"
DOB="00/00/0000"
TactAccountNo="405631" />
<Client ClientID="417186"
ClientName="VALDA SPIERS"
IRDNumber="19-040-763"
DOB="00/00/0000"
TactAccountNo="417186" />
</Common>

...into Oracle's canonical XML format:

<?xml version="1.0"?>
<ROWSET>
<ROW>
<ClientID>"98092"</ClientID>
<ClientName>"DEBORAH WALL AGENCY"</ClientName>
<IRDNumber>="26-969-212"</IRDNumber>
<DOB>="00/00/0000"</DOB>
<TactAccountNo>"TACT1"</TactAccountNo>
</ROW>
<ROW>
<ClientID>"405631"</ClientID>
<ClientName>"MR MURRAY JOHN HAYTERIAN B And THELMA M HAYTER AS TRUSTEES"</ClientName>
<IRDNumber>="13-449-187"</IRDNumber>
<DOB>"00/00/0000"</DOB>
<TactAccountNo>="405631"</TactAccountNo>
</ROW>
<ROW>
<ClientID>"417186"</ClientID>
<ClientName>"VALDA SPIERS"</ClientName>
<IRDNumber>"19-040-763"</IRDNumber>
<DOB>"00/00/0000"</DOB>
<TactAccountNo>"417186"</TactAccountNo>
</ROW>
</ROWSET>

This can be done using an XSLT stylesheet like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="</code> http://www.w3.org/1999/XSL/Transform"
xmlns:fo="
http://www.w3.org/1999/XSL/Format" >
  <xsl:template match="Common">
    <ROWSET>
      <xsl:for-each select="Client">
        <ROW>
          <CLIENTID><xsl:value-of select="@ClientID"/></CLIENTID>
          <CLIENTNAME><xsl:value-of select="@ClientName"/></CLIENTNAME>
          <IRDNUMBER><xsl:value-of select="@IRDNumber"/></IRDNUMBER>
          <DOB><xsl:value-of select="@DOB"/></DOB>
          <TACTACCOUNTNO><xsl:value-of select="@TactAccountNo"/></TACTACCOUNTNO>
        </ROW>
      </xsl:for-each>
    </ROWSET>
  </xsl:template>
</xsl:stylesheet>

For an example of transforming XML using XSLT inside the database, see:  
http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:1827993798549

Once the original document is converted into the canonical XML format, it can then be inserted into a table using the XML SQL Utility.  For an example of doing this, see:  
http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:4061080732051

Hope that helps!

_____________________________________________________________________
Sean Dillon - Senior Technologist, Oracle Corporation
Author "Beginning Oracle Programming" 
http://www.amazon.com/exec/obidos/ASIN/186100690X <code>

Open Protocol Support

Sean Dillon, July 27, 2002 - 7:27 am UTC

Another way I'd mention that's NOT presented here is loading XML into the XML Repository via Oracle's new open protocol support in 9i Release 2. HTTP, FTP and WebDAV are all available protocols for browsing and interacting with the database.

For instance, I might load an XML Schema into the database for my CD collection. The XML Schema can use Oracle's object-relational storage capabilities to designate how XML files should be stored under the covers. Then, I can use any WebDAV or FTP tool to insert XML documents into my database.

So yes, instead of using a PL/SQL or Java proc, I simply open up my handy-dandy FTP tool and drag over my 250,000 xml documents into the database. Now you can get to that data using open protocols, SQL, PL/SQL, Java, etc.

Oh and also, you can use SQL*Loader to load XMLType columns now in 9iR2 :-). Good luck w/ your XML endeavors!

Suggestion

A reader, October 08, 2003 - 2:26 am UTC

Hi, i have went through many of the documents given in the OTN and also in this site. But could not really get the exact answer related to my problem as i am new to this topic. so can you kinldy help me out.

Here is my xml DTD.

<!------------------------ Start DTD----------------------->

<!ELEMENT MEPOutput (XMLInputOrder?,General?, MEPInputData?, MEPOutputData?)>
<!ELEMENT XMLInputOrder (OrderID)>

<!ELEMENT General (General.Column+)>

<!ELEMENT MEPInputData (UsedDatas,UsedDevices)>


<!-- UsedDatas -->
<!ELEMENT UsedDatas (UsedData)*>
<!ELEMENT UsedData (UsedInpDatum+)>
<!-- UsedDatas -->

<!-- UsedDevices -->
<!ELEMENT UsedDevices (Device)*>
<!ELEMENT Device (Name?,ViewName?,Konfiguration?)>
<!ELEMENT Konfiguration (KonfigFile*)>
<!-- UsedDevices -->

<!ELEMENT MEPOutputData (Sequences?)>
<!-- MEPOutputData hat Typaten und Sequences Daten -->

<!-- Sequences -->
<!ELEMENT Sequences (Sequence*)>
<!-- Eine Mess Sequence hat STDUP und Messpunkte (Lastpunkte) -->
<!ELEMENT Sequence (Name,ViewName? , (MeasPoint? | STDUP?)*)>
<!-- Sequences -->

<!-- STDUP -->
<!ELEMENT STDUP (Name?,ViewName?,STDUPSequenceData?, STDUPMeasData)*>
<!ELEMENT STDUPMeasData (STDUPMeasData.Column*)>
<!ELEMENT STDUPSequenceData (STDUPSequenceData.Column*)>
<!-- STDUP -->

<!-- MeasPoint -->

<!ELEMENT MeasPoint (Name?,ViewName?,MeasPointSteps*)>
<!ELEMENT MeasPointSteps (MeasPointStep)*>

<!ELEMENT MeasPointStep (Name?,ViewName?,StatusSequence?, StepGeneral?,StepGeneralMeas?,SetPhase?,WaitPhase?,MeasPhase?)>
<!ELEMENT StepGeneral (StepGeneral.Column)*>
<!ELEMENT StepGeneralMeas (StepGeneralMeas.Column)*>

<!ELEMENT SetPhase (Beginphase, SetVar+)>
<!ELEMENT SetVar (Name?,ViewName?, VarDescription?, VarDevice?, DisplayFormat?, ValueTransform?, VarSequData?,VarSetValues+)>
<!ELEMENT VarSequData (VarSequData.Column)*>


<!ELEMENT VarSetValues (VarSetValue)*>
<!ELEMENT VarSetValue (VarSet ,VarMeas?)>

<!ELEMENT MeasPhase (Beginphase, MeasVar+)>
<!ELEMENT MeasVar (Name?,ViewName?, VarDescription?,VarDevice?,DisplayFormat?, ValueTransform?, VarSequData?,VarMeasValues+)>

<!ELEMENT VarMeasValues (VarMeasValue)*>
<!ELEMENT VarMeasValue (VarMeas+)>

<!ELEMENT WaitPhase (Beginphase, WaitVar+)>
<!ELEMENT WaitVar (Name?,ViewName?, VarDescription?,VarDevice?, DisplayFormat?, ValueTransform?,VarSequData?,VarMeasValues+)>


<!ELEMENT VarSet ((SetValue? | ExtSetFile? ) ,SetState?,SetTime?)*>
<!ELEMENT VarMeas ((MeasValue? |ExtMeasFile? ),MeasState?,MeasTime?)*>
<!ELEMENT ValueTransform ( FourPoint | Straight )>

<!-- MeasPoint -->

<!-- einzelne Elemente -->


<!ELEMENT OrderID (#PCDATA)>
<!ELEMENT UsedInpDatum (#PCDATA)>
<!ELEMENT Name (#PCDATA)>
<!ELEMENT ViewName (#PCDATA)>
<!ELEMENT KonfigFile (#PCDATA)>

<!ELEMENT SetValue (#PCDATA)>
<!ELEMENT MeasValue (#PCDATA)>
<!ELEMENT ExtMeasFile (#PCDATA)>
<!ELEMENT ExtSetFile (#PCDATA)>
<!ELEMENT MeasState (#PCDATA)>
<!ELEMENT SetState (#PCDATA)>
<!ELEMENT SetTime (#PCDATA)>
<!ELEMENT MeasTime (#PCDATA)>
<!ELEMENT StatusSequence (#PCDATA)>
<!ELEMENT VarDevice (#PCDATA)>
<!ELEMENT STDUPSequenceData.Column (#PCDATA)>
<!ELEMENT STDUPMeasData.Column (#PCDATA)>
<!ELEMENT General.Column (#PCDATA)>
<!ELEMENT StepGeneralMeas.Column (#PCDATA)>
<!ELEMENT StepGeneral.Column (#PCDATA)>
<!ELEMENT VarSequData.Column (#PCDATA)>
<!ELEMENT Beginphase (#PCDATA)>
<!ELEMENT VarDescription (#PCDATA)>
<!ELEMENT DisplayFormat (#PCDATA)>

<!ELEMENT FourPoint (#PCDATA)>
<!ELEMENT Straight (#PCDATA)>

<!-- einzelne Elemente -->

<!-- Hier kommen die Attribute und ENTITies-->
<!ENTITY % ColumnAttributes "
id CDATA #REQUIRED
View CDATA #IMPLIED
Unit CDATA #IMPLIED
DataType (double | integer | text | KonfigFile) 'double'
Format CDATA #IMPLIED
ViewValue CDATA #IMPLIED
">

<!ENTITY % VarAttributes "
id CDATA #REQUIRED
Unit CDATA #IMPLIED
DataType (double | integer | text) 'double'
">

<!ENTITY % VarTime "
TimeBase (msec | sec ) #IMPLIED
TimeTrigger (BeginSetPhase|BeginMeasPhase) #IMPLIED
">

<!ENTITY % MEPDataVersionid " Model CDATA #IMPLIED
Version CDATA #IMPLIED
">

<!ENTITY % UsedDataTypes " (Typdata |Sequdata | ExtSequSetValue |RegistryKonfig) #REQUIRED">

<!ENTITY % MeasMeasQuality "(Last | Average | Single | ExternFile) #IMPLIED">

<!ENTITY % KonfigFileTyp "(ISO-CAN|Newport|DDE-Loaddatei|LeCroy|Inca-Descr|Inca-Hex|ASAP-Konf|MEPRegler) #REQUIRED ">

<!-- comments -->

<!ATTLIST STDUP id ID #REQUIRED>
<!ATTLIST MeasPoint id ID #REQUIRED
Typ (Normal | Steps | Revolution) #IMPLIED>

<!ATTLIST MeasPointStep id CDATA #REQUIRED
Nr CDATA #IMPLIED >

<!ATTLIST Section.Column %ColumnAttributes; >
<!ATTLIST STDUPSequenceData.Column %ColumnAttributes; >
<!ATTLIST STDUPMeasData.Column %ColumnAttributes; >
<!ATTLIST StepGeneral.Column %ColumnAttributes; >
<!ATTLIST StepGeneralMeas.Column %ColumnAttributes; >
<!ATTLIST VarSequData.Column %ColumnAttributes; >


<!ATTLIST SetVar %VarAttributes; >
<!ATTLIST MeasVar %VarAttributes; >
<!ATTLIST WaitVar %VarAttributes; >


<!ATTLIST MeasTime %VarTime; >
<!ATTLIST SetTime %VarTime; >

<!ATTLIST MEPOutput Version CDATA #IMPLIED>

<!ATTLIST Sequence id ID #IMPLIED>
<!ATTLIST General.Column id CDATA #REQUIRED>
<!ATTLIST Device DeviceID ID #REQUIRED
Version CDATA #IMPLIED
>

<!ATTLIST KonfigFile Typ %KonfigFileTyp;
Version CDATA #IMPLIED
>

<!ATTLIST MEPInputData %MEPDataVersionid; >
<!ATTLIST MEPOutputData %MEPDataVersionid; >

<!ATTLIST UsedData UsedDataType %UsedDataTypes; >

<!ATTLIST UsedInpDatum Typ %UsedDataTypes;
Version CDATA #IMPLIED
LastUpdate CDATA #IMPLIED
LastTimeStamp CDATA #IMPLIED
>

<!ATTLIST VarSetValue Step CDATA #IMPLIED>
<!ATTLIST VarSetValues SetTyp (Unique|Steps) #IMPLIED
MeasQuality %MeasMeasQuality;
>


<!ATTLIST VarMeasValue Step CDATA #IMPLIED>
<!ATTLIST VarMeasValues MeasTyp (Unique|Steps) #IMPLIED
MeasQuality %MeasMeasQuality;
>
<!ATTLIST VarMeas Name CDATA #IMPLIED
Typ (ExternFile) #IMPLIED>

<!ATTLIST VarSet Name CDATA #IMPLIED
Typ (ExternFile) #IMPLIED>

<!ATTLIST ValueTransform Typ (FourPoint | Straight) #REQUIRED >

<!ATTLIST FourPoint X0 CDATA #REQUIRED
X1 CDATA #REQUIRED
Y0 CDATA #REQUIRED
Y1 CDATA #REQUIRED
>
<!ATTLIST Straight Gradient CDATA #REQUIRED
Offset CDATA #REQUIRED
>

<!--------------------- END DTD---------------------------->

If i have such a DTD and i need to load the XML file into the database, what would be the method i should use.

After the file is loaded i should be able to display the information to the user and also allow the user to query on it.
I am using 9iR2 database and my GUI application will be in Forms9i.
Also i 8i i tried parsing the XML files in pl/sql using XMLDOM parser but it gives error when the size of the document is too large. So is this problem still exists in 9iR2.

you response will be greatly appreciated.


Tom Kyte
October 08, 2003 - 11:56 am UTC

I asked Sean Dillon, our local XML Technologist, to take a look at this and here's what he had to say:
--

DTD's are what I like to call "the old". XML Schemas are "the new". In Oracle8i and Oracle9i, we have support for DTD validation and generation. In Oracle9iR2, we introduced new functionality called XML DB, which is an XML Schema-based approach to storing, querying, manipulating, securing, accessing, etc. your XML documents. The first question I would ask you would be... can you upgrade to an XML Schema from the above listed DTD? There are tools that help do this (Oracle doesn't offer them, they're 3d party) if converting was an issue. With an XML Schema as your documents validation point, Oracle's abilities become exponentially better.

That being said... you can certainly store and query DTD-based XML documents. Since you're using 9iR2, you would use the XMLType to store and query those docs. XMLType is a new datatype introduced in Oracle9iR1. What you want to do is familiarize yourself with using XMLType columns or tables. There are a couple of ways to do this, ideally you'd use the documentation and Oracle's OTN. A few URLS:
</code> http://otn.oracle.com/tech/xml/index.html http://otn.oracle.com/tech/xml/learner.html http://otn.oracle.com/tech/xml/htdocs/XDBDemo1.html <code>

The last one, the XDBDemo1.html, is going to give you practical examples of what you are looking for.

I can't tell you how to do this all through Forms9i, I don't really use our Developer Suite. One question for you, are you looking to display the XML document or the contents of the XML document? This is the difference between stuff like:

<employee id="21342">
<fname>Sean</fname>
<lname>Dillon</lname>
<hobby>SQL</hobby>
</employee>

...and...

Employee#: 21342
First Name: Sean
Last Name: Dillon
Hobby: SQL

(just an example)

On the OTN site above, you will find *many* XMLDOM and DBMS_XMLDOM (the db supplied package you SHOULD be using w/ 9i+ databases) code examples. Without the error you received due to a "too large" document, I'd like to see the error itself.

I hope that helps!

Raghu, October 08, 2003 - 12:45 pm UTC

Hi Sean,

Thanks for the fast response.
I can shift to XML Schema based implementation by converting the DTD's to Schemas.

The data i want to display to the user is the second way as mentioned by you. I want to store the data from the xml files and display to the end user in relational way.

I tried to access the demo link without success. some problem with the link.

I am familiar with XMLTYPE column datatype of 9iR2.
Can you please give me an example with schema based approach w.r.t to my problem.

Your response will be highly appreciated.

Tom Kyte
October 09, 2003 - 3:41 pm UTC

Your example, EXACTLY, can be found HERE: </code> http://otn.oracle.com/tech/xml/xmldb/index.html <code>

If you can't get to that page, you need to register an account on OTN (free registration). Once you've got a registered account, go to that page and click on the "Oracle XML DB Downloadable Demonstration Source" link. This is a download for a good sized demo that shows you all the basics of XML DB use... This is a list of just some of the things you do in the demonstration:

- Load an XML schema into Oracle XML DB
- Register the schema with the database
- FTP a few hundred XML documents into the database (via the XML Repository)
- Query an object/relational (the PURCHASEORDERS) table, see a few hundred records (the loaded xml docs)
- Create views that looks like a relational query against the xml documents
- Query those views, do joins on those views, etc.

Hope that helps!

_smd_

External files in xmltype-table with sqlldr

Ralf, December 10, 2003 - 8:34 am UTC

Hi, Tom

I'm looking for a way to fill a xmltype-table (create table t of xmltype) with external xml-files via sqlldr. I found a way to do it, if it is a normal table with xmltype-column, but this solved not my problem. 9iR2

Thanks for your help

Ralf

loading xml into multiple tables with obj relational view

reader, January 14, 2004 - 11:16 am UTC

Tom/Sean,

The docs describe the capability to load an xml document into multiple relational tables using an object relational view over the top of the relational tables.

There are other approaches described as well, but can you show a simple example of this, or point me to an example from documentation where this might be accomplished.



Tom Kyte
January 15, 2004 - 11:20 am UTC

Hi, Sean here...

There are a couple ways to do this. First and foremost, I'd look to Oracle XML DB in 9iR2 and beyond (10g, eventually) to do this for you. XML DB will use an XML Schema (mandatory) and will create an object-relational table (or multiple object-relational tables, depending on how you tell Oracle to store the data) to store the scalar values within the XML documents you load into the database. This is a GREAT way to do it, and I'd say Oracle's #1 recommendation for "breaking down" XML into tables. (See pointers to Oracle doc and samples about these concepts, below)

Pro's:
- Oracle manages all the tables, the shredding of the XML upon load, the reconstitution of the XML when you select the entire document.
- No programming necessary. You don't have to learn the DOM or SAX parser to read your document manually and load values into tables.
- You can load/query the documents via the standard channels such as SQL, PL/SQL, Java, C, etc. You can also use FTP, WebDAV and HTTP through the new Open Internet Protocol support in Oracle's Net Services layer.
- You can control the object/relational table structure through XML Schema annotations (See pointers to documentation, below)
Con's:
- You can't use your own tables. Oracle MUST create and maintain them "behind the scenes".
- You MUST use an XML Schema for Oracle to do the shredding.

Another way of accomplishing this is by using the Oracle XML Developer's Kits, specifically the XML SQL Utility. Using this approach, you provide the XML in a particular format, and Oracle will automatically insert the XML into a object/relational table for you. There are examples and a full explanation of this approach in another AskTom question, here:
</code> http://asktom.oracle.com/pls/asktom_admin/f?p=4950:8:::::F4950_P8_DISPLAYID:4980337843276

Pro's:
- Custom object/relational tables
- Very little programming
- Oracle does the loading for you automatically (and can generate the same documents using the same facility, the XML SQL Utility)
Con's:
- XML Schemas and DTDs have nothing at all to do with this, so although it's not a deviation from the standards... if you have data based on some XSD or DTD... you will most likely have to transform the XML into Oracle's format using XSLT (again, see the AskTom bookmark, above)
- There is no notion of XML storage with this approach.  You will have to use a programming layer to generate XML if you want to expose your data as XML documents later.  
- There is no way to use the XML Repository with this approach (see below for pointers to documentation about the XML Repository)

Lastly, the third approach is the most programming centric.  It would consist of you parsing each XML document received into the database programmatically, and then determining in your code where to insert the data.  You would be using the XML Developer's Kits or the supplied packages with the database (DBMS_XML*)... available languages are basically PL/SQL, Java or C (there are also some JavaBeans created to automate repetitive tasks...).
Pro's:
- Greatest degree of flexibility
- Can code in any business logic into the loading process as you see fit
Con's:
- This approach requires a thorough understanding of the XML parser APIs.
- You're writing lots of code
- Oracle does nothing for you automatically
- No availability to the XML Repository

Given those approaches and your skillset/desires, it should be relatively easy to determine your desired direction.  Instead of me writing drawn out examples, I'll point you to documentation, OTN sites and/or AskTom questions that show these concepts for you:

DOC REFERENCES:
XML DB Storage Architecture:  
http://docs.oracle.com/docs/cd/B10501_01/appdev.920/a96620/xdb01int.htm#1047568
XML DB Structured Mapping and Annotations: 
http://docs.oracle.com/docs/cd/B10501_01/appdev.920/a96620/xdb01int.htm#1047568
XML DB Repository: 
http://docs.oracle.com/docs/cd/B10501_01/appdev.920/a96620/whatsnew.htm#973015
XML Developer's Kits: 
http://docs.oracle.com/docs/cd/B10501_01/appdev.920/a96621/toc.htm
SQL XML Utility:  
http://docs.oracle.com/docs/cd/B10501_01/appdev.920/a96621/adx08xsu.htm#1000433
PL/SQL DOM Parser (see DBMS_XMLDOM): 
http://docs.oracle.com/docs/cd/B10501_01/appdev.920/a96612/toc.htm
Java Supplied Packages: 
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96609/arjavpart2xdk.htm#435787 <code>

There are lots of examples based on the approach you take. Make sure you search through AskTom for XML and see those examples, there have been MANY posted.

Hope that helps!

_smd_

Problem creating table based on xml schema

Raghu, February 07, 2004 - 5:59 am UTC

Hi Tom,
I have register a XML schema succefully in this way.
/*register the schema*/
BEGIN
DBMS_XMLSCHEMA.REGISTERSCHEMA
('</code> http://www.w3.org/2001/XMLSchema/XMLResultMep2000.xsd'
   , BFILENAME('DIR_TEMP', 'XMLResultMep2000.xsd')
   ,TRUE         /*local schema*/
   ,TRUE         /*generate sql object types*/
   ,FALSE        /*do no generate java bean*/
   ,TRUE         /*generate tables*/
   ,TRUE        /*generate error if schema is invalid*/
   ,USER);       /*owner of the schema*/
END;
/

Now i try to create a table based on the schema using this .
CREATE TABLE result
(
   id  NUMBER,
   data  SYS.XMLType
  )
XMLTYPE COLUMN data
STORE AS OBJECT RELATIONAL
XMLSCHEMA "
http://www.w3.org/2001/XMLSchema/XMLResultMep2000.xsd"
ELEMENT "MEPOUTPUT"
/

and i get this error.

CREATE TABLE result
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [qmtcolcb_nomatch], [VarSequData],
[VarSequData], [], [], [], [], []

.But at the same time i can create the sample PurchaseOrder table based on PurchaseOrder schema provided in Oracle documentation.

Can you please let me know the problem. 

Background Information:
-----------------------
This schema is generated from DTD using XMLSPY 5.0. I decided to convert the DTD to XML Schema based on suggestion provided by Sean as mentioned above. The DTD is also given above as i have already asked question before.

Here is the XML schema .

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="
http://www.w3.org/2001/XMLSchema" >
    <xsd:element name="VarSequData">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="VarSequData.Column" minOccurs="0" axOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="WaitPhase">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="Beginphase" minOccurs="0"/>
                <xsd:element ref="WaitVar" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="STDUPSequenceData.Column">
        <xsd:complexType>
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="Unit" type="xsd:string" use="optional"/>
                    <xsd:attribute name="View" type="xsd:string" use="optional"/>
                    <xsd:attribute name="Format" type="xsd:string" use="optional"/>
                    <xsd:attribute name="DataType" type="STDUPSequenceData.ColumnDataTypetype" use="optional" default="double"/>
                    <xsd:attribute name="id" type="xsd:string" use="required"/>
                    <xsd:attribute name="ViewValue" type="xsd:string" use="optional"/>
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="General">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="General.Column" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="Beginphase">
        <xsd:complexType>
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="TimeBase" type="BeginphaseTimeBasetype" use="optional"/>
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="STDUPSequenceData">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="STDUPSequenceData.Column" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="VarSet">
        <xsd:complexType>
            <xsd:choice>
                <xsd:sequence>
                    <xsd:element ref="SetValue"/>
                    <xsd:element ref="SetState" minOccurs="0"/>
                    <xsd:element ref="SetTime" minOccurs="0"/>
                </xsd:sequence>
                <xsd:sequence>
                    <xsd:element ref="ExtSetFile"/>
                    <xsd:element ref="SetState" minOccurs="0"/>
                    <xsd:element ref="SetTime" minOccurs="0"/>
                </xsd:sequence>
                <xsd:sequence>
                    <xsd:element ref="VarName"/>
                    <xsd:element ref="SetValue"/>
                    <xsd:element ref="SetState" minOccurs="0"/>
                    <xsd:element ref="SetTime" minOccurs="0"/>
                </xsd:sequence>
            </xsd:choice>
            <xsd:attribute name="Typ" type="VarSetTyptype" use="optional" default="STDARD"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="ValueTransform">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="FourPoint"/>
            </xsd:sequence>
            <xsd:attribute name="Typ" type="ValueTransformTyptype" use="required"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="General.Column">
        <xsd:complexType>
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="id" type="xsd:string" use="required"/>
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="UsedData">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="UsedInpDatum" maxOccurs="unbounded"/>
            </xsd:sequence>
            <xsd:attribute name="UsedDataType" type="UsedDataUsedDataTypetype" use="required"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="Sequence">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="Name"/>
                <xsd:element ref="ViewName" minOccurs="0"/>
                <xsd:choice minOccurs="0" maxOccurs="unbounded">
                    <xsd:element ref="MeasPoint" minOccurs="0"/>
                    <xsd:element ref="STDUP" minOccurs="0"/>
                </xsd:choice>
            </xsd:sequence>
            <xsd:attribute name="id" type="xsd:ID" use="optional"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="STDUP">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="Name" minOccurs="0"/>
                <xsd:element ref="ViewName" minOccurs="0"/>
                <xsd:element ref="STDUPSequenceData" minOccurs="0"/>
                <xsd:element ref="STDUPMeasData"/>
            </xsd:sequence>
            <xsd:attribute name="id" type="xsd:ID" use="required"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="MeasPointSteps">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="MeasPointStep" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="StepGeneralMeas">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="StepGeneralMeas.Column" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="VarMeasValues">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="VarMeasValue" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
            <xsd:attribute name="MeasQuality" type="VarMeasValuesMeasQualitytype" use="optional"/>
            <xsd:attribute name="MeasTyp" type="VarMeasValuesMeasTyptype" use="optional"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="VarMeasValue">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="VarMeas" maxOccurs="unbounded"/>
            </xsd:sequence>
            <xsd:attribute name="Step" type="xsd:string" use="optional"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="UsedInpDatum">
        <xsd:complexType>
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="Typ" type="UsedInpDatumTyptype" use="required"/>
                    <xsd:attribute name="LastTimeStamp" type="xsd:string" use="optional"/>
                    <xsd:attribute name="Version" type="xsd:string" use="optional"/>
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="UsedDevices">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="Device" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="ExtMeasFile">
        <xsd:complexType>
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="Typ" type="ExtMeasFileTyptype" use="required"/>
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="KonfigFile">
        <xsd:complexType>
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="Typ" type="KonfigFileTyptype" use="required"/>
                    <xsd:attribute name="Version" type="xsd:string" use="optional"/>
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="MEPInputData">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="UsedDatas"/>
                <xsd:element ref="UsedDevices"/>
            </xsd:sequence>
            <xsd:attribute name="Model" type="xsd:string" use="optional"/>
            <xsd:attribute name="Version" type="xsd:string" use="optional"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="STDUPMeasData">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="STDUPMeasData.Column" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="StepGeneral">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="StepGeneral.Column" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="SetPhase">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="Beginphase" minOccurs="0"/>
                <xsd:element ref="SetVar" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="MeasPoint">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="Name" minOccurs="0"/>
                <xsd:element ref="ViewName" minOccurs="0"/>
                <xsd:element ref="MeasPointSteps" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
            <xsd:attribute name="Typ" type="MeasPointTyptype" use="optional"/>
            <xsd:attribute name="id" type="xsd:ID" use="required"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="Device">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="ViewName" minOccurs="0"/>
                <xsd:element ref="Konfiguration" minOccurs="0"/>
            </xsd:sequence>
            <xsd:attribute name="DeviceID" type="xsd:ID" use="required"/>
            <xsd:attribute name="Version" type="xsd:string" use="optional"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="SetVar">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="Name"/>
                <xsd:element ref="ViewName" minOccurs="0"/>
                <xsd:element ref="VarDescription" minOccurs="0"/>
                <xsd:element ref="VarDevice" minOccurs="0"/>
                <xsd:element ref="VarDeviceReadBack" minOccurs="0"/>
                <xsd:element ref="DisplayFormat" minOccurs="0"/>
                <xsd:element ref="ValueTransform" minOccurs="0"/>
                <xsd:element ref="VarSequData" minOccurs="0"/>
                <xsd:element ref="VarSetValues"/>
            </xsd:sequence>
            <xsd:attribute name="Unit" type="xsd:string" use="optional"/>
            <xsd:attribute name="DataType" type="SetVarDataTypetype" use="optional" default="double"/>
            <xsd:attribute name="id" type="xsd:string" use="required"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="MEPOutput">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="XMLInputOrder" minOccurs="0"/>
                <xsd:element ref="General" minOccurs="0"/>
                <xsd:element ref="MEPInputData" minOccurs="0"/>
                <xsd:element ref="MEPOutputData" minOccurs="0"/>
            </xsd:sequence>
            <xsd:attribute name="Version" type="xsd:string" use="optional"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="Konfiguration">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="KonfigFile" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="UsedDatas">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="UsedData" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="MEPOutputData">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="Sequences" minOccurs="0"/>
            </xsd:sequence>
            <xsd:attribute name="Model" type="xsd:string" use="optional"/>
            <xsd:attribute name="Version" type="xsd:string" use="optional"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="MeasPointStep">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="Name" minOccurs="0"/>
                <xsd:element ref="ViewName" minOccurs="0"/>
                <xsd:element ref="StatusSequence" minOccurs="0"/>
                <xsd:element ref="StepGeneral" minOccurs="0"/>
                <xsd:element ref="StepGeneralMeas" minOccurs="0"/>
                <xsd:element ref="SetPhase" minOccurs="0"/>
                <xsd:element ref="WaitPhase" minOccurs="0"/>
                <xsd:element ref="MeasPhase" minOccurs="0"/>
            </xsd:sequence>
            <xsd:attribute name="Nr" type="xsd:string" use="optional"/>
            <xsd:attribute name="id" type="xsd:string" use="required"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="VarSetValues">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="VarSetValue" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
            <xsd:attribute name="MeasQuality" type="VarSetValuesMeasQualitytype" use="optional"/>
            <xsd:attribute name="SetTyp" type="VarSetValuesSetTyptype" use="optional"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="WaitVar">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="Name"/>
                <xsd:element ref="ViewName" minOccurs="0"/>
                <xsd:element ref="VarDescription" minOccurs="0"/>
                <xsd:element ref="VarDevice" minOccurs="0"/>
                <xsd:element ref="DisplayFormat" minOccurs="0"/>
                <xsd:element ref="ValueTransform" minOccurs="0"/>
                <xsd:element ref="VarSequData" minOccurs="0"/>
                <xsd:element ref="VarMeasValues"/>
            </xsd:sequence>
            <xsd:attribute name="Unit" type="xsd:string" use="optional"/>
            <xsd:attribute name="DataType" type="WaitVarDataTypetype" use="optional" default="double"/>
            <xsd:attribute name="id" type="xsd:string" use="required"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="ExtSetFile">
        <xsd:complexType>
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="Typ" type="ExtSetFileTyptype" use="optional"/>
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="STDUPMeasData.Column">
        <xsd:complexType>
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="Unit" type="xsd:string" use="optional"/>
                    <xsd:attribute name="View" type="xsd:string" use="optional"/>
                    <xsd:attribute name="Format" type="xsd:string" use="optional"/>
                    <xsd:attribute name="DataType" type="STDUPMeasData.ColumnDataTypetype" use="optional" default="double"/>
                    <xsd:attribute name="id" type="xsd:string" use="required"/>
                    <xsd:attribute name="ViewValue" type="xsd:string" use="optional"/>
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="StepGeneralMeas.Column">
        <xsd:complexType>
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="Unit" type="xsd:string" use="optional"/>
                    <xsd:attribute name="View" type="xsd:string" use="optional"/>
                    <xsd:attribute name="Format" type="xsd:string" use="optional"/>
                    <xsd:attribute name="DataType" type="StepGeneralMeas.ColumnDataTypetype" use="optional" default="double"/>
                    <xsd:attribute name="id" type="xsd:string" use="required"/>
                    <xsd:attribute name="ViewValue" type="xsd:string" use="optional"/>
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="StepGeneral.Column">
        <xsd:complexType>
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="Unit" type="xsd:string" use="optional"/>
                    <xsd:attribute name="View" type="xsd:string" use="optional"/>
                    <xsd:attribute name="Format" type="xsd:string" use="optional"/>
                    <xsd:attribute name="DataType" type="StepGeneral.ColumnDataTypetype" use="optional" default="double"/>
                    <xsd:attribute name="id" type="xsd:string" use="required"/>
                    <xsd:attribute name="ViewValue" type="xsd:string" use="optional"/>
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="FourPoint">
        <xsd:complexType>
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="Y0" type="xsd:string" use="required"/>
                    <xsd:attribute name="X0" type="xsd:string" use="required"/>
                    <xsd:attribute name="Y1" type="xsd:string" use="required"/>
                    <xsd:attribute name="X1" type="xsd:string" use="required"/>
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="XMLInputOrder">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="OrderID"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="MeasVar">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="Name"/>
                <xsd:element ref="ViewName" minOccurs="0"/>
                <xsd:element ref="VarDescription" minOccurs="0"/>
                <xsd:element ref="VarDevice" minOccurs="0"/>
                <xsd:element ref="DisplayFormat" minOccurs="0"/>
                <xsd:element ref="ValueTransform" minOccurs="0"/>
                <xsd:element ref="VarSequData" minOccurs="0"/>
                <xsd:element ref="VarMeasValues"/>
            </xsd:sequence>
            <xsd:attribute name="Unit" type="xsd:string" use="optional"/>
            <xsd:attribute name="DataType" type="MeasVarDataTypetype" use="optional" default="double"/>
            <xsd:attribute name="id" type="xsd:string" use="required"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="MeasPhase">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="Beginphase" minOccurs="0"/>
                <xsd:element ref="MeasVar" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="Sequences">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="Sequence" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="VarSetValue">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="VarSet"/>
                <xsd:element ref="VarMeas" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
            <xsd:attribute name="Step" type="xsd:string" use="optional"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="VarSequData.Column">
        <xsd:complexType>
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="Unit" type="xsd:string" use="optional"/>
                    <xsd:attribute name="View" type="xsd:string" use="optional"/>
                    <xsd:attribute name="Format" type="xsd:string" use="optional"/>
                    <xsd:attribute name="DataType" type="VarSequData.ColumnDataTypetype" use="optional" default="double"/>
                    <xsd:attribute name="id" type="xsd:string" use="required"/>
                    <xsd:attribute name="ViewValue" type="xsd:string" use="optional"/>
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="VarMeas">
        <xsd:complexType>
            <xsd:choice minOccurs="0" maxOccurs="unbounded">
                <xsd:sequence>
                    <xsd:element ref="MeasValue"/>
                    <xsd:element ref="MeasState" minOccurs="0"/>
                    <xsd:element ref="MeasTime" minOccurs="0"/>
                </xsd:sequence>
                <xsd:sequence>
                    <xsd:element ref="ExtMeasFile"/>
                    <xsd:element ref="MeasState" minOccurs="0"/>
                    <xsd:element ref="MeasTime" minOccurs="0"/>
                </xsd:sequence>
                <xsd:sequence>
                    <xsd:element ref="VarName"/>
                    <xsd:element ref=&qu
>
Tom Kyte
February 07, 2004 - 3:06 pm UTC

for internal errors like that, please -- please -- open a tar with support. they equate to "bug"

Bug with Oracle XMLDB

Raghu, February 09, 2004 - 7:49 am UTC

Thanks Tom,

you are right. It's bug with oracle XMLDB.
If an Element Name inside the xmlschema contains dot then you get such error .
I removed all the dots from the element name from the schema and i was able to register the schema and create table based on the schema.
Another option incase you do not want to remove the dots is to use annotations for the element name using xdb:SQLName. and the value provided with xdb:SQLName should not contain dots.

SQL*Loader-418

Charlie, June 29, 2004 - 5:33 pm UTC

Hi Tom,

I try to invoke the SQL-Loader to import a XML file into a Table-Column of XMLTYPE under Oracle 9.2.0.4.  
But I got the following error:   

SQL*Loader-418: Bad datafile datatype for column XMLDOC 


SQL> desc tbl_xmlwork; 
Name Null? Type 
-----------------------------------------
DOCID NUMBER(38) 
XMLDOC XMLTYPE 


Control file: 

load data 
infile * 
replace 
into table tbl_xmlwork 
fields terminated by ',' 
( 
docid integer, 
lob_file FILLER char(40), 
xmldoc LOBFILE(lob_file) TERMINATED BY EOF 
) 
begindata 
1,'tbl_claims.xml' 



Xml document 'tbl_claims.xml': 
<A> 
  <b>123</b> 
</A> 

Could you please help?

thanks, 

Tom Kyte
June 29, 2004 - 7:31 pm UTC

create tbl_xmlwork( docid number, xmldoc SYS.xmltype );


it is an issue with sqlldr in 9ir2 with the SYNONYM for xmltype -- it got "confused"

it was corrected in 10g


THANKS!

Charlie, June 29, 2004 - 10:38 pm UTC


dtd

phil, November 23, 2004 - 4:20 pm UTC

in a question above Sean gives a link to </code> http://otn.oracle.com/tech/xml/htdocs/XDBDemo1.html <code>, do you know where I can get this example from now?

My Issue...

A request xml has an associated dtd, which I do not care about as the xml will be valid. A request in xml is made and based on the values in the xml a response is sent out.

I do not want to store the request xml just query it.

the problem I have is when recive the xml put it into an xmltype I get an ORA-31001 Invalid resource handle or path name "/PR.dtd". Once in the xmltype I would query the values.


declare
l_req xmlType := xmlType('<?xml version=''1.0'' encoding=''UTF-8''?>'||
'<!DOCTYPE PRInt:HandleRequest SYSTEM ''PR.dtd''>'||
....
....



Sean implies that the link above may help, but it is a year old!

cheers


to add to my dtd question

phil, November 23, 2004 - 4:44 pm UTC

continuation from above...

I am hoping that I can just receive the xml and retreive values from it without storing the xml in a table

I was expecting to use the xmltype object and query the values from it using the methods such as extractValue

eg
SELECT
extractValue(l_xmltype, '/element1/element2')
FROM dual;


your thoughts as always much appreciated

We are not impressed with XMLTYPE views.

Michael Friedman, March 05, 2006 - 12:02 pm UTC

We're trying to load data into Oracle 10G Release 1, Patch 5 using XMLTYPE views, and I have to say we're not impressed.

It looks like Oracle never bothered testing this functionality before releasing it.

create table product (
id varchar2(10) primary key,
name varchar2(100),
tag char(1) default '0');

create type p_t as object (
id varchar2(10),
name varchar2(100)
);


BEGIN
DBMS_XMLSCHEMA.registerSchema('</code> http://www.oracle.com/ptype.xsd',
'<?xml version="1.0"?>
<xsd:schema xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:xdb="
http://xmlns.oracle.com/xdb"
xsi:schemaLocation="
http://xmlns.oracle.com/xdb http://xmlns.oracle.com/xdb/XDBSchema.xsd" >
<xsd:element name="product" xdb:SQLType="P_T" >
<xsd:complexType xdb:SQLType="P_T">
<xsd:sequence>
<xsd:element name="id" xdb:SQLName="ID" xdb:SQLType="VARCHAR2"/>
<xsd:element name="name" xdb:SQLName="NAME" xdb:SQLType="VARCHAR2"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>', 
TRUE, 
false, 
FALSE);
END;
/

create or replace view p_type_v 
of xmltype 
XMLSCHEMA "
http://www.oracle.com/ptype.xsd"
ELEMENT "product"
WITH OBJECT ID (extract(object_value,'/product/pid/text()').getnumberval())
as
SELECT P_T(d.id,d.name) 
From product d;

Insert Into p_type_v Values (Xmltype.createXML('<product 

xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"

xsi:noNamespaceSchemaLocation="
http://www.oracle.com/ptype.xsd" > <code>
<id>3</id><name>yfl</name></product>'));

ID NAME
<id>3</id> <name>yfl</name>

IT INCLUDED THE TAGS IN THE DATA!!!!

If we make ID a number as it is supposed to be in our system it's even worse - Oracle crashes, presumably when it tries to put "<id>3</id>" into a number column!

If we try to use object views so we can modularize our system and make instead of triggers at the object level instead of at the XMLTYPE view level to support more complex XML / relational structures Oracle also crashes.

Tom Kyte
March 05, 2006 - 1:51 pm UTC

sorry? stopped reading sort of after the initial paragraphs.



Sorry about the formatting

Mike Friedman, March 05, 2006 - 7:40 pm UTC

Well, I can see that the formatting made it hard to read.

Unfortunately, the followup screen does not explain your markup language - it's obviously not pure HTML - and I don't know how to escape out the strings in XML that are messing it up.

Sorry.

Anyway, I think the fact that inserting into an XMLTYPE view gives you data that includes the XML tags

ID NAME
<id>3</id> <name>yfl</name>

is pretty obviously wrong.

It's disappointing and frustrating since this mechanism would almost support declarative round trip XML import / export from relational tables if it worked.

Tom Kyte
March 06, 2006 - 8:33 am UTC

Had nothing to do with the formatting.

OK`

A reader, March 09, 2006 - 12:51 pm UTC

Hi Tom,
I have a directory having some hundreds of XML files.
I want to load those files into a table having a column of xmltype.
How to do that??

Please specify some simple ways to do that.
Bye!

Tom Kyte
March 09, 2006 - 3:41 pm UTC

sqlldr can be used.

dbms_lob.loadfromfile can be used

a custom written program that does "insert" can be used.




Best ways

Kumar, November 01, 2006 - 12:00 am UTC

Hi Tom,
I am going to poll(Every 30 mts) a feed service provider folder to get the news for 60 companies.The news will be in the xml format.That folder may contain around 50-100 XML files on an average size of 500-700 KB.

Bcos of our requirement we ended up in storing that information in our database.But every 30 Mts this table will be populated with new news information.

From the UI users will be searching for the news for a specifiecd company.

My first idea is to store the content in relational format.But the problem is every 30 mts we have to load and parse lot of XML and store the values in the DB tables.



My Second idea is ,Instead of storing the data in relational way,store each individual XML file in XMLTYPE column and use the extract function to get the value back.
This will avoid lot of XML parsing during the load time.

I would like to know will there be any problem with my second approach.

Database version:9i R2
OS:Unix



Tom Kyte
November 01, 2006 - 8:42 am UTC

bcos?

parse me now
or
parse me later

have you benchmarked the "load and shred" approach to see if it is faster than fast enough, or are you guessing that "wow, it sounds like a lot of work, it must be slow"?

I'd prefer to load and extract the relevant information ONCE rather than have to extract over and over - wouldn't you?

How to load XML files

Eduardo, November 06, 2006 - 1:03 pm UTC

Hi Tom,

I´m looking for information about how to load data from XML files. We have 2 server, one of them is the IIS server and the other is the database server.

Do you know how to load data?

P.D.: any idea will be welcome.



Load file that contains multiple XML documents via SQL Loader

A reader, November 26, 2006 - 5:15 pm UTC

Hi Tom,

We use Siebel CRM application where we transfer opportunity data to our parent company. Sales rep at our parent company work on those leads and update opportunity status and send data back to us in XML format.

We get all XML documents in one file. XML documents are seperated by "@@@" characters. In one file we can get n (100, 10000 etc...) numbers of documents.

My goal is to load these documents in Oracle table via SQL*Loader. Also, we would like to validate each XML document through XSD.

Is these possible?

We are using Oracle 9iR2

Thanks

Tom Kyte
November 26, 2006 - 7:49 pm UTC

probably, you'd be looking at the "continueif" statement to assemble one big logical record out the the physical records you are receiving.

neat how they took a "standard" like XML and broke it that way. Or did @@@ sort of get into the standard :)

More to Explore

CLOB/BLOB/etc

Complete documentation on Securefiles and Large Objects here