Mapping XML data to relational database tables
I'm writing an application that has two parts: the client part generates XML documents and sends them across the network to a server part, which parses the XML, maps the XML to various RDBMS tables and stores the data in the RDBMS.
I've got everything working using SAX, but now any change I make to the XML schema and/or the RDBMS table structures in the future will mean some serious code changes.
Has anyone worked with this scenario and developed a better method of handling this mapping? All the previous efforts in this area seem to be RDBMS to XML, which is of no use to me.
If you had to do this this, how would you approach it? I'm using XML for ease of reading, as the client has code to allow for documents to be written to the disk if no connection to the server is available, and the server does the same if no database connection is available.
Thanks in advance ...
cheers,
mark
OK, to reply to my own posting for future reference, I've found an open source project called Osage at http://sourceforge.net that does what I need. I'm looking at it now and can't say if it's everything I want, but it seems likely to fit the bil.
cheers,
mark
Similar Messages
-
Load xml data to oracle database table
hi,
i am facing some problem in fetching from xml data into oracle . That if the table column name and xsl and xsd tag are equal then data is fetching .
if we we are changing column name in xsl and xsd then data is not fetching.
the soure is like that
XSD FILE
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
</xs:complexType>
<xs:complexType name="TRANSAC_Type">
<xs:all>
<xs:element name="NECRITUR" type="Char4_Type" minOccurs="0" nillable="false"/>
<xs:element name="NPTF_INT" type="Char2_Type" minOccurs="0" nillable="false"/>
</xs:all>
</xs:complexType>
<xs:simpleType name="Char1_Type">
<xs:restriction base="xs:string">
<xs:maxLength value="1"/>
</xs:restriction>
</xs:simpleType>
XSL FILE
<?xml version="1.0" encoding="UTF-8"?>
<xsl:output method="xml" indent="yes"/>
<!-- Treatment of fields for table -->
<xsl:template match="NECRITUR">
<NO_ECRIT_INT>
<xsl:value-of select="."/>
</NO_ECRIT_INT>
</xsl:template>
<xsl:template match="NPTF_INT">
<NPTF_INT>
<xsl:value-of select="."/>
</NPTF_INT>
</xsl:template>
</xsl:template>
</xsl:stylesheet>
Xml file
<File xmlns:xsi="http://www.’’’’’ ">
<Header>
<FileType>TRANSAC</FileType>
<FileName>TRANSAC.XML</FileName>
<CreationDate>2007-02-22</CreationDate>
<CreationTime>14:56:48</CreationTime>
</Header>
<Data>
<TRANSAC>
<NECRITUR>6</NECRITUR>
<NPTF_INT>MMMM</NPTF_INT>
</TRANSAC>
</Data>
</File>
Table Is
REP (NO_ECRIT_INT, NPTF_INT, CreationDate, CreationTime)
Regards
manu
Message was edited by:
user561683Hi Manu
Im not quite sure what your question is?
Are you trying to load data to the database or
Are you trying to retrieve data from the database ?
Either way this forum is meant for XML Publisher or BI Publisher issues not just XSL ... you might be better asking on the XML forum.
Regards, Tim -
Capture XML data payload into database table (Oracle EBS R12)
Hi All,
We have a XML Publisher report which generates output in PDF format. We want to capture the XML data payload generated by this report and put it into a DB table once the PDF is generated.
This report is generated through Oracle EBS R12 and XML Payload is stored by oracle by default in $APPLCSF/out directory.
Any pointers would be helpful
brCouple of options, this one is probably the easiest without knowing other requirements (e.g., do you have to store the output as XML, or do you just the data available so you can output in XML later?).
Capture the SQL statement that generates the output in the first place. If you have that statement, you can insert into some table using the select statement. Once you have the report data (and you can tag that particular set of data with a job ID, timestamp, whatever, in case you need to store it and distinguish it from other reports down the road), you can generate XML output using the PL/SQL built-in DBMS_XMLGEN.
Is that what you are looking for? -
How to load xml data into a database table....
Hi All,
Iam new to this forum.I have an xmldoc table of xmltype(datatype).Iam able to insert xml data to it.I have another table called new_books.sql:
CREATE TABLE NEW_BOOKS
TITLE VARCHAR2(255) NOT NULL,
LINK VARCHAR2(80) NULL,
PUBLISHER VARCHAR2(255) NULL,
SUBJECT VARCHAR2(80) NULL,
PUBDATE VARCHAR2(40) NULL,
DESCRIPTION VARCHAR2(4000) NULL,
AUTHOR VARCHAR2(80) NULL,
PRIMARY KEY(TITLE)
Now i want to copy the data in the xmldoc table into the table new_books.sql.Is there any procedure to do that in PL/SQL?
Given below is the xmlfile:
- <rdf>
- <item>
<title>Enterprise SOA: Designing IT for Business Innovation</title>
<link>http://safari.oreilly.com/0596102380?a=102682</link>
<publisher>O'Reilly</publisher>
<creator>Thomas Mattern</creator>
<creator>Dan Woods</creator>
<subject>IT Infrastructure</subject>
<date>April 2006</date>
</item>
</rdf>
Thanks in Advance,
Gita.Assuming the table xmldoc(of xmltype) has this XML
SQL> select * from xmldoc;
SYS_NC_ROWINFO$
<rdf>
<item>
<title>Enterprise SOA: Designing IT for Business Innovation</title>
<link>http://safari.oreilly.com/0596102380?a=102682</link>
<publisher>O'Reilly</publisher>
<creator>Thomas Mattern</creator>
<creator>Dan Woods</creator>
<subject>IT Infrastructure</subject>
<date>April 2006</date>
</item>
</rdf>
SQL> INSERT INTO NEW_BOOKS(TITLE, LINK, PUBLISHER, SUBJECT)
2 select extractvalue(value(x),'/rdf/item/title') as title,
3 extractvalue(value(x),'/rdf/item/link') as link,
4 extractvalue(value(x),'/rdf/item/publisher') as publisher,
5 extractvalue(value(x),'/rdf/item/subject') as subject
6 from xmldoc x
7 ;
1 row created. -
Fetch XML data stored in database table column dynamically
Hi All,
I am working as a SQL guy but never worked on XML in SQlbefore.
During some project work , we need to fetch value from xml stored in database column.
Problem is rowsof xml column arebit different and have different values.
Could anybody help me to build something dynamic to fetch all values from each row .
My data look like:
TEXT
<
RiskEndorsement><ExistingExposureSplitLimitsChange><NewRiskLimitSeq>536504</NewRiskLimitSeq><EffDate>11/1/2011</EffDate></ExistingExposureSplitLimitsChange></RiskEndorsement>
<
RiskEndorsement><MandatoryStateRateSplit><StateCode>NY</StateCode><EffDate>4/1/2011</EffDate></MandatoryStateRateSplit></RiskEndorsement>
<
RiskEndorsement><NonAnniversaryExModSplit><RiskBureauSeq>197608</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>0389463</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.890</ExModFactor><SplitDate>3/11/2012</SplitDate></NonAnniversaryExModSplit></RiskEndorsement>
<
RiskEndorsement><NonAnniversaryExModSplit><RiskBureauSeq>197613</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>0389463</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.970</ExModFactor><SplitDate>1/13/2013</SplitDate></NonAnniversaryExModSplit></RiskEndorsement>
<
RiskEndorsement><MandatoryStateRateSplit><StateCode>AL</StateCode><EffDate>7/1/2011</EffDate></MandatoryStateRateSplit></RiskEndorsement>
<
RiskEndorsement><AnniversaryRatingDateSplit><RiskBureauSeq>208975</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>230094357</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.8700</ExModFactor><SplitDate>1/1/2012</SplitDate></AnniversaryRatingDateSplit></RiskEndorsement>
<
RiskEndorsement><AnniversaryRatingDateSplit><RiskBureauSeq>213467</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>2431638</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.6800</ExModFactor><SplitDate>10/1/2013</SplitDate></AnniversaryRatingDateSplit></RiskEndorsement>
<
RiskEndorsement><NonAnniversaryExModSplit><RiskBureauSeq>213473</RiskBureauSeq><RiskIDStatusSeq>1615</RiskIDStatusSeq><RiskIDNbr>917661014</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.860</ExModFactor><SplitDate>10/1/2013</SplitDate></NonAnniversaryExModSplit></RiskEndorsement>
<
RiskEndorsement><AnniversaryRatingDateSplit><RiskBureauSeq>213497</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>1146456</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.830</ExModFactor><SplitDate>10/1/2013</SplitDate></AnniversaryRatingDateSplit></RiskEndorsement>
AndrewPlease post a concise and complete example. Include table DDL and sample data INSERT statements.
Cause the solution depends on your actual structure. Otherwise take a look at the
nodes() method.
E.g.
DECLARE @Sample TABLE
ID INT IDENTITY ,
Data XML
INSERT INTO @Sample
( Data )
VALUES ( '<RiskEndorsement><ExistingExposureSplitLimitsChange><NewRiskLimitSeq>536504</NewRiskLimitSeq><EffDate>11/1/2011</EffDate></ExistingExposureSplitLimitsChange></RiskEndorsement> ' ),
( '<RiskEndorsement><MandatoryStateRateSplit><StateCode>NY</StateCode><EffDate>4/1/2011</EffDate></MandatoryStateRateSplit></RiskEndorsement> ' ),
( '<RiskEndorsement><NonAnniversaryExModSplit><RiskBureauSeq>197608</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>0389463</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.890</ExModFactor><SplitDate>3/11/2012</SplitDate></NonAnniversaryExModSplit></RiskEndorsement> ' ),
( '<RiskEndorsement><NonAnniversaryExModSplit><RiskBureauSeq>197613</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>0389463</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.970</ExModFactor><SplitDate>1/13/2013</SplitDate></NonAnniversaryExModSplit></RiskEndorsement> ' ),
( '<RiskEndorsement><MandatoryStateRateSplit><StateCode>AL</StateCode><EffDate>7/1/2011</EffDate></MandatoryStateRateSplit></RiskEndorsement> ' ),
( '<RiskEndorsement><AnniversaryRatingDateSplit><RiskBureauSeq>208975</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>230094357</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.8700</ExModFactor><SplitDate>1/1/2012</SplitDate></AnniversaryRatingDateSplit></RiskEndorsement> ' ),
( '<RiskEndorsement><AnniversaryRatingDateSplit><RiskBureauSeq>213467</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>2431638</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.6800</ExModFactor><SplitDate>10/1/2013</SplitDate></AnniversaryRatingDateSplit></RiskEndorsement> ' ),
( '<RiskEndorsement><NonAnniversaryExModSplit><RiskBureauSeq>213473</RiskBureauSeq><RiskIDStatusSeq>1615</RiskIDStatusSeq><RiskIDNbr>917661014</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.860</ExModFactor><SplitDate>10/1/2013</SplitDate></NonAnniversaryExModSplit></RiskEndorsement> ' ),
( '<RiskEndorsement><AnniversaryRatingDateSplit><RiskBureauSeq>213497</RiskBureauSeq><RiskIDStatusSeq>1616</RiskIDStatusSeq><RiskIDNbr>1146456</RiskIDNbr><ExModStatusSeq>1607</ExModStatusSeq><ExModFactor>0.830</ExModFactor><SplitDate>10/1/2013</SplitDate></AnniversaryRatingDateSplit></RiskEndorsement> ' );
SELECT ID ,
ExistingExposureSplitLimitsChange.value('NewRiskLimitSeq[1]', 'INT') AS NewRiskLimitSeq ,
ExistingExposureSplitLimitsChange.value('EffDate[1]', 'DATE') AS EffDate
FROM @Sample S
CROSS APPLY S.Data.nodes('/RiskEndorsement/ExistingExposureSplitLimitsChange') A ( ExistingExposureSplitLimitsChange );
SELECT ID ,
MandatoryStateRateSplit.value('StateCode[1]', 'NVARCHAR(255)') AS StateCode ,
MandatoryStateRateSplit.value('EffDate[1]', 'DATE') AS EffDate
FROM @Sample S
CROSS APPLY S.Data.nodes('/RiskEndorsement/MandatoryStateRateSplit') A ( MandatoryStateRateSplit );
SELECT ID ,
NonAnniversaryExModSplit.value('RiskBureauSeq[1]', 'INT') AS RiskBureauSeq ,
NonAnniversaryExModSplit.value('RiskIDStatusSeq[1]', 'INT') AS RiskIDStatusSeq ,
NonAnniversaryExModSplit.value('RiskIDNbr[1]', 'INT') AS RiskIDNbr ,
NonAnniversaryExModSplit.value('ExModStatusSeq[1]', 'INT') AS ExModStatusSeq ,
NonAnniversaryExModSplit.value('ExModFactor[1]', 'FLOAT') AS ExModFactor ,
NonAnniversaryExModSplit.value('SplitDate[1]', 'NVARCHAR(255)') AS SplitDateText
FROM @Sample S
CROSS APPLY S.Data.nodes('/RiskEndorsement/NonAnniversaryExModSplit') A ( NonAnniversaryExModSplit );
SELECT ID ,
AnniversaryRatingDateSplit.value('RiskBureauSeq[1]', 'INT') AS RiskBureauSeq ,
AnniversaryRatingDateSplit.value('RiskIDStatusSeq[1]', 'INT') AS RiskIDStatusSeq ,
AnniversaryRatingDateSplit.value('RiskIDNbr[1]', 'INT') AS RiskIDNbr ,
AnniversaryRatingDateSplit.value('ExModStatusSeq[1]', 'INT') AS ExModStatusSeq ,
AnniversaryRatingDateSplit.value('ExModFactor[1]', 'FLOAT') AS ExModFactor ,
AnniversaryRatingDateSplit.value('SplitDate[1]', 'NVARCHAR(255)') AS SplitDateText
FROM @Sample S
CROSS APPLY S.Data.nodes('/RiskEndorsement/AnniversaryRatingDateSplit') A ( AnniversaryRatingDateSplit ); -
Insert XML file into Relational database model without using XMLTYPE tables
Dear all,
How can I store a known complex XML file into an existing relational database WITHOUT using xmltypes in the database ?
I read the article on DBMS_XMLSTORE. DBMS_XMLSTORE indeed partially bridges the gap between XML and RDBMS to a certain extent, namely for simply structured XML (canonical structure) and simple tables.
However, when the XML structure will become arbitrary and rapidly evolving, surely there must be a way to map XML to a relational model more flexibly.
We work in a java/Oracle10 environment that receives very large XML documents from an independent data management source. These files comply with an XML schema. That is all we know. Still, all these data must be inserted/updated daily in an existing relational model. Quite an assignment isn't it ?
The database does and will not contain XMLTYPES, only plain RDBMS tables.
Are you aware of a framework/product or tool to do what DBMS_XMLSTORE does but with any format of XML file ? If not, I am doomed.
Constraints : Input via XML files defined by third party
Storage : relational database model with hundreds of tables and thousands of existing queries that can not be touched. The model must not be altered.
Target : get this XML into the database on a daily basis via an automated process.
Cheers.
Luc.Luc,
your Doomed !
If you would try something like DBMS_XMLSTORE, you probably would be into serious performance problems in your case, very fast, and it would be very difficult to manage.
If you would use a little bit of XMLType stuff, you would be able to shred the data into the relational model very fast and controlable. Take it from me, I am one of those old geezers like Mr. Tom Kyte way beyond 40 years (still joking). No seriously. I started out as a classical PL/SQL, Forms Guy that switched after two years to become a "DBA 1.0" and Mr Codd and Mr Date were for years my biggest hero's. I have the utmost respect for Mr. Tom Kyte for all his efforts for bringing the concepts manual into the development world. Just to name some off the names that influenced me. But you will have to work with UNSTRUCTURED data (as Mr Date would call it). 80% of the data out there exists off it. Stuff like XMLTABLE and XML VIEWs bridge the gap between that unstructured world and the relational world. It is very doable to drag and drop an XML file into the XMLDB database into a XMLtype table and or for instance via FTP. From that point on it is in the database. From there you could move into relational tables via XMLTABLE methods or XML Views.
You could see the described method as a filtering option so XML can be transformed into relational data. If you don't want any XML in your current database, then create an small Oracle database with XML DB installed (if doable 11.1.0.7 regarding the best performance --> all the new fast optimizer stuff etc). Use that database as a staging area that does all the XML shredding for you into relational components and ship the end result via database links and or materialized views or other probably known methodes into your relational database that isn't allowed to have XMLType.
This way you would keep your realtional Oracle database clean and have the Oracle XML DB staging database do all the filtering and shredding into relational components.
Throwing the XML DB option out off the window beforehand would be like replacing your Mercedes with a bicycle. With both you will be able to travel the distance from Paris to Rome, but it will take you a hell of lot longer.
:-) -
When / why use XML to store data instead of database table ?
Hi All,
I still not use XML much in applications and don't know much about its utilization.
I read here and there about storing data as XML instead of into database tables.
- could any body please tell me when / why use XML to store data instead of database table ?
e.g : store inventory per warehouse in XML format. ?
- What is the other cases or reasons of extracting database records into XML or vice versa ?
- is there any good pdf on this ?
Thank you for your help,
xtantoIt depends entirely what you want to accomplish with the 'XML in the database'. There are basically 3 independent methods: As CLOB, as XMLType views or as native XMLType 'columns'
Each method has advantages and disadvantages, especially in the performance vs purpose tradeoff.
The Oracled Press book "Oracle Database 10g XML & SQL Design, Build, & Manage XML Applications in Java, C, C++, & PL/SQL" is highly recommended for anyone interested in Oracle and XML. http://books.mcgraw-hill.com/getbook.php?isbn=0072229527&template=oraclepress -
Insert XML file into Relational database model - no XMLTYPE!
Dear all,
How can I store a known complex XML file into an existing relational database WITHOUT using xmltypes in the database ?
I read the article on DBMS_XMLSTORE. DBMS_XMLSTORE indeed partially bridges the gap between XML and RDBMS to a certain extent, namely for simply structured XML (canonical structure) and simple tables.
However, when the XML structure will become arbitrary and rapidly evolving, surely there must be a way to map XML to a relational model more flexibly.
We work in a java/Oracle10 environment that receives very large XML documents from an independent data management source. These files comply with an XML schema. That is all we know. Still, all these data must be inserted/updated daily in an existing relational model. Quite an assignment isn't it ?
The database does and will not contain XMLTYPES, only plain RDBMS tables.
Are you aware of a framework/product or tool to do what DBMS_XMLSTORE does but with any format of XML file ? If not, I am doomed.
Cheers.
Luc.
Edited by: user6693852 on Jan 13, 2009 7:02 AMIn case you decide to follow my advice, here's a simple example showing how to do this.. (Note the XMLTable syntax is the preferred approach in 10gr2 and later..
SQL> spool testase.log
SQL> --
SQL> connect / as sysdba
Connected.
SQL> --
SQL> set define on
SQL> set timing on
SQL> --
SQL> define USERNAME = XDBTEST
SQL> --
SQL> def PASSWORD = XDBTEST
SQL> --
SQL> def USER_TABLESPACE = USERS
SQL> --
SQL> def TEMP_TABLESPACE = TEMP
SQL> --
SQL> drop user &USERNAME cascade
2 /
old 1: drop user &USERNAME cascade
new 1: drop user XDBTEST cascade
User dropped.
Elapsed: 00:00:00.59
SQL> grant create any directory, drop any directory, connect, resource, alter session, create view to &USERNAME identified by &PASS
ORD
2 /
old 1: grant create any directory, drop any directory, connect, resource, alter session, create view to &USERNAME identified by &
ASSWORD
new 1: grant create any directory, drop any directory, connect, resource, alter session, create view to XDBTEST identified by XDB
EST
Grant succeeded.
Elapsed: 00:00:00.01
SQL> alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
2 /
old 1: alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
new 1: alter user XDBTEST default tablespace USERS temporary tablespace TEMP
User altered.
Elapsed: 00:00:00.00
SQL> connect &USERNAME/&PASSWORD
Connected.
SQL> --
SQL> var SCHEMAURL varchar2(256)
SQL> var XMLSCHEMA CLOB
SQL> --
SQL> set define off
SQL> --
SQL> begin
2 :SCHEMAURL := 'http://xmlns.example.com/askTom/TransactionList.xsd';
3 :XMLSCHEMA :=
4 '<?xml version="1.0" encoding="UTF-8"?>
5 <!--W3C Schema generated by XMLSpy v2008 rel. 2 sp2 (http://www.altova.com)-->
6 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
7 <xs:element name="TransactionList" type="transactionListType" xdb:defaultTable="LOCAL_TABLE"/>
8 <xs:complexType name="transactionListType" xdb:maintainDOM="false" xdb:SQLType="TRANSACTION_LIST_T">
9 <xs:sequence>
10 <xs:element name="Transaction" type="transactionType" maxOccurs="unbounded" xdb:SQLCollType="TRANSACTION_V"
>
11 </xs:sequence>
12 </xs:complexType>
13 <xs:complexType name="transactionType" xdb:maintainDOM="false" xdb:SQLType="TRANSACTION_T">
14 <xs:sequence>
15 <xs:element name="TradeVersion" type="xs:integer"/>
16 <xs:element name="TransactionId" type="xs:integer"/>
17 <xs:element name="Leg" type="legType" maxOccurs="unbounded" xdb:SQLCollType="LEG_V"/>
18 </xs:sequence>
19 <xs:attribute name="id" type="xs:integer" use="required"/>
20 </xs:complexType>
21 <xs:complexType name="paymentType" xdb:maintainDOM="false" xdb:SQLType="PAYMENT_T">
22 <xs:sequence>
23 <xs:element name="StartDate" type="xs:date"/>
24 <xs:element name="Value" type="xs:integer"/>
25 </xs:sequence>
26 <xs:attribute name="id" type="xs:integer" use="required"/>
27 </xs:complexType>
28 <xs:complexType name="legType" xdb:maintainDOM="false" xdb:SQLType="LEG_T">
29 <xs:sequence>
30 <xs:element name="LegNumber" type="xs:integer"/>
31 <xs:element name="Basis" type="xs:integer"/>
32 <xs:element name="FixedRate" type="xs:integer"/>
33 <xs:element name="Payment" type="paymentType" maxOccurs="unbounded" xdb:SQLCollType="PAYMENT_V"/>
34 </xs:sequence>
35 <xs:attribute name="id" type="xs:integer" use="required"/>
36 </xs:complexType>
37 </xs:schema>';
38 end;
39 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.00
SQL> set define on
SQL> --
SQL> declare
2 res boolean;
3 xmlSchema xmlType := xmlType(:XMLSCHEMA);
4 begin
5 dbms_xmlschema.registerSchema
6 (
7 schemaurl => :schemaURL,
8 schemadoc => xmlSchema,
9 local => TRUE,
10 genTypes => TRUE,
11 genBean => FALSE,
12 genTables => TRUE,
13 ENABLEHIERARCHY => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
14 );
15 end;
16 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.26
SQL> desc LOCAL_TABLE
Name Null? Type
TABLE of SYS.XMLTYPE(XMLSchema "http://xmlns.example.com/askTom/TransactionList.xsd" Element "TransactionList") STORAGE Object-rela
ional TYPE "TRANSACTION_LIST_T"
SQL> --
SQL> create or replace VIEW TRAN_VIEW
2 as
3 select
4 extractvalue(x.column_value,'/Transaction/TradeVersion/text()') tradeversion,
5 extractvalue(x.column_value,'/Transaction//text()') transactionid
6 from
7 local_table,
8 table(xmlsequence(extract(OBJECT_VALUE,'/TransactionList/Transaction'))) x
9 /
View created.
Elapsed: 00:00:00.01
SQL> create or replace VIEW TRAN_LEG_VIEW
2 as
3 select
4 extractvalue(x.column_value,'/Transaction/TransactionId/text()') transactionid,
5 extractvalue(y.column_value,'/Leg/Basis/text()') leg_basis,
6 extractValue(y.column_value,'/Leg/FixedRate/text()') leg_fixedrate
7 from
8 local_table,
9 table(xmlsequence(extract(OBJECT_VALUE,'/TransactionList/Transaction'))) x,
10 table(xmlsequence(extract(x.column_value,'/Transaction/Leg'))) y
11 /
View created.
Elapsed: 00:00:00.01
SQL> create or replace VIEW TRAN_LEG_PAY_VIEW
2 as
3 select
4 extractvalue(x.column_value,'/Transaction/TransactionId/text()') transactionid,
5 extractvalue(y.column_value,'/Leg/LegNumber/text()') leg_legnumber,
6 extractvalue(z.column_value,'/Payment/StartDate/text()') pay_startdate,
7 extractValue(z.column_value,'/Payment/Value/text()') pay_value
8 from
9 local_table,
10 table(xmlsequence(extract(OBJECT_VALUE,'/TransactionList/Transaction'))) x,
11 table(xmlsequence(extract(x.column_value,'/Transaction/Leg'))) y,
12 table(xmlsequence(extract(y.column_value,'/Leg/Payment'))) z
13 /
View created.
Elapsed: 00:00:00.03
SQL> desc TRAN_VIEW
Name Null? Type
TRADEVERSION NUMBER(38)
TRANSACTIONID VARCHAR2(4000)
SQL> --
SQL> desc TRAN_LEG_VIEW
Name Null? Type
TRANSACTIONID NUMBER(38)
LEG_BASIS NUMBER(38)
LEG_FIXEDRATE NUMBER(38)
SQL> --
SQL> desc TRAN_LEG_PAY_VIEW
Name Null? Type
TRANSACTIONID NUMBER(38)
LEG_LEGNUMBER NUMBER(38)
PAY_STARTDATE DATE
PAY_VALUE NUMBER(38)
SQL> --
SQL> create or replace VIEW TRAN_VIEW_XMLTABLE
2 as
3 select t.*
4 from LOCAL_TABLE,
5 XMLTable
6 (
7 '/TransactionList/Transaction'
8 passing OBJECT_VALUE
9 columns
10 TRADE_VERSION NUMBER(4) path 'TradeVersion/text()',
11 TRANSACTION_ID NUMBER(4) path 'TransactionId/text()'
12 ) t
13 /
View created.
Elapsed: 00:00:00.01
SQL> create or replace VIEW TRAN_LEG_VIEW_XMLTABLE
2 as
3 select t.TRANSACTION_ID, L.*
4 from LOCAL_TABLE,
5 XMLTable
6 (
7 '/TransactionList/Transaction'
8 passing OBJECT_VALUE
9 columns
10 TRANSACTION_ID NUMBER(4) path 'TransactionId/text()',
11 LEG XMLType path 'Leg'
12 ) t,
13 XMLTABLE
14 (
15 '/Leg'
16 passing LEG
17 columns
18 LEG_NUMBER NUMBER(4) path 'LegNumber/text()',
19 LEG_BASIS NUMBER(4) path 'Basis/text()',
20 LEG_FIXED_RATE NUMBER(4) path 'FixedRate/text()'
21 ) l
22 /
View created.
Elapsed: 00:00:00.01
SQL> create or replace VIEW TRAN_LEG_PAY_VIEW_XMLTABLE
2 as
3 select TRANSACTION_ID, L.LEG_NUMBER, P.*
4 from LOCAL_TABLE,
5 XMLTable
6 (
7 '/TransactionList/Transaction'
8 passing OBJECT_VALUE
9 columns
10 TRANSACTION_ID NUMBER(4) path 'TransactionId/text()',
11 LEG XMLType path 'Leg'
12 ) t,
13 XMLTABLE
14 (
15 '/Leg'
16 passing LEG
17 columns
18 LEG_NUMBER NUMBER(4) path 'LegNumber/text()',
19 PAYMENT XMLType path 'Payment'
20 ) L,
21 XMLTABLE
22 (
23 '/Payment'
24 passing PAYMENT
25 columns
26 PAY_START_DATE DATE path 'StartDate/text()',
27 PAY_VALUE NUMBER(4) path 'Value/text()'
28 ) p
29 /
View created.
Elapsed: 00:00:00.03
SQL> desc TRAN_VIEW_XMLTABLE
Name Null? Type
TRADE_VERSION NUMBER(4)
TRANSACTION_ID NUMBER(4)
SQL> --
SQL> desc TRAN_LEG_VIEW_XMLTABLE
Name Null? Type
TRANSACTION_ID NUMBER(4)
LEG_NUMBER NUMBER(4)
LEG_BASIS NUMBER(4)
LEG_FIXED_RATE NUMBER(4)
SQL> --
SQL> desc TRAN_LEG_PAY_VIEW_XMLTABLE
Name Null? Type
TRANSACTION_ID NUMBER(4)
LEG_NUMBER NUMBER(4)
PAY_START_DATE DATE
PAY_VALUE NUMBER(4)
SQL> --
SQL> set long 10000 pages 100 lines 128
SQL> set timing on
SQL> set autotrace on explain
SQL> set heading on feedback on
SQL> --
SQL> VAR DOC1 CLOB
SQL> VAR DOC2 CLOB
SQL> --
SQL> begin
2 :DOC1 :=
3 '<TransactionList>
4 <Transaction id="1">
5 <TradeVersion>1</TradeVersion>
6 <TransactionId>1</TransactionId>
7 <Leg id="1">
8 <LegNumber>1</LegNumber>
9 <Basis>1</Basis>
10 <FixedRate>1</FixedRate>
11 <Payment id="1">
12 <StartDate>2000-01-01</StartDate>
13 <Value>1</Value>
14 </Payment>
15 <Payment id="2">
16 <StartDate>2000-01-02</StartDate>
17 <Value>2</Value>
18 </Payment>
19 </Leg>
20 <Leg id="2">
21 <LegNumber>2</LegNumber>
22 <Basis>2</Basis>
23 <FixedRate>2</FixedRate>
24 <Payment id="1">
25 <StartDate>2000-02-01</StartDate>
26 <Value>10</Value>
27 </Payment>
28 <Payment id="2">
29 <StartDate>2000-02-02</StartDate>
30 <Value>20</Value>
31 </Payment>
32 </Leg>
33 </Transaction>
34 <Transaction id="2">
35 <TradeVersion>2</TradeVersion>
36 <TransactionId>2</TransactionId>
37 <Leg id="1">
38 <LegNumber>21</LegNumber>
39 <Basis>21</Basis>
40 <FixedRate>21</FixedRate>
41 <Payment id="1">
42 <StartDate>2002-01-01</StartDate>
43 <Value>21</Value>
44 </Payment>
45 <Payment id="2">
46 <StartDate>2002-01-02</StartDate>
47 <Value>22</Value>
48 </Payment>
49 </Leg>
50 <Leg id="22">
51 <LegNumber>22</LegNumber>
52 <Basis>22</Basis>
53 <FixedRate>22</FixedRate>
54 <Payment id="21">
55 <StartDate>2002-02-01</StartDate>
56 <Value>210</Value>
57 </Payment>
58 <Payment id="22">
59 <StartDate>2002-02-02</StartDate>
60 <Value>220</Value>
61 </Payment>
62 </Leg>
63 </Transaction>
64 </TransactionList>';
65 :DOC2 :=
66 '<TransactionList>
67 <Transaction id="31">
68 <TradeVersion>31</TradeVersion>
69 <TransactionId>31</TransactionId>
70 <Leg id="31">
71 <LegNumber>31</LegNumber>
72 <Basis>31</Basis>
73 <FixedRate>31</FixedRate>
74 <Payment id="31">
75 <StartDate>3000-01-01</StartDate>
76 <Value>31</Value>
77 </Payment>
78 </Leg>
79 </Transaction>
80 </TransactionList>';
81 end;
82 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01
SQL> insert into LOCAL_TABLE values ( xmltype(:DOC1))
2 /
1 row created.
Elapsed: 00:00:00.01
Execution Plan
Plan hash value: 1
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | INSERT STATEMENT | | 1 | 100 | 1 (0)| 00:00:01 |
| 1 | LOAD TABLE CONVENTIONAL | LOCAL_TABLE | | | | |
SQL> insert into LOCAL_TABLE values ( xmltype(:DOC2))
2 /
1 row created.
Elapsed: 00:00:00.01
Execution Plan
Plan hash value: 1
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | INSERT STATEMENT | | 1 | 100 | 1 (0)| 00:00:01 |
| 1 | LOAD TABLE CONVENTIONAL | LOCAL_TABLE | | | | |
SQL> select * from TRAN_VIEW_XMLTABLE
2 /
TRADE_VERSION TRANSACTION_ID
1 1
2 2
31 31
3 rows selected.
Elapsed: 00:00:00.03
Execution Plan
Plan hash value: 650975545
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 3 | 168 | 3 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 3 | 168 | 3 (0)| 00:00:01 |
|* 2 | TABLE ACCESS FULL| SYS_NTGgl+TKyhQnWoFRSrCxeX9g== | 3 | 138 | 3 (0)| 00:00:01 |
|* 3 | INDEX UNIQUE SCAN| SYS_C0010174 | 1 | 10 | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter("SYS_NC_TYPEID$" IS NOT NULL)
3 - access("NESTED_TABLE_ID"="LOCAL_TABLE"."SYS_NC0000800009$")
Note
- dynamic sampling used for this statement
SQL> select * from TRAN_LEG_VIEW_XMLTABLE
2 /
TRANSACTION_ID LEG_NUMBER LEG_BASIS LEG_FIXED_RATE
1 1 1 1
1 2 2 2
2 21 21 21
2 22 22 22
31 31 31 31
5 rows selected.
Elapsed: 00:00:00.04
Execution Plan
Plan hash value: 1273661583
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5 | 560 | 7 (15)| 00:00:01 |
|* 1 | HASH JOIN | | 5 | 560 | 7 (15)| 00:00:01 |
| 2 | NESTED LOOPS | | 3 | 159 | 3 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL| SYS_NTGgl+TKyhQnWoFRSrCxeX9g== | 3 | 129 | 3 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN| SYS_C0010174 | 1 | 10 | 0 (0)| 00:00:01 |
|* 5 | TABLE ACCESS FULL | SYS_NTUmyermF/S721C/2UXo40Uw== | 5 | 295 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - access("SYS_ALIAS_1"."NESTED_TABLE_ID"="SYS_ALIAS_0"."SYS_NC0000800009$")
3 - filter("SYS_NC_TYPEID$" IS NOT NULL)
4 - access("NESTED_TABLE_ID"="LOCAL_TABLE"."SYS_NC0000800009$")
5 - filter("SYS_NC_TYPEID$" IS NOT NULL)
Note
- dynamic sampling used for this statement
SQL> select * from TRAN_LEG_PAY_VIEW_XMLTABLE
2 /
TRANSACTION_ID LEG_NUMBER PAY_START PAY_VALUE
1 1 01-JAN-00 1
1 1 02-JAN-00 2
1 2 01-FEB-00 10
1 2 02-FEB-00 20
2 21 01-JAN-02 21
2 21 02-JAN-02 22
2 22 01-FEB-02 210
2 22 02-FEB-02 220
31 31 01-JAN-00 31
9 rows selected.
Elapsed: 00:00:00.07
Execution Plan
Plan hash value: 4004907785
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 9 | 1242 | 10 (10)| 00:00:01 |
|* 1 | HASH JOIN | | 9 | 1242 | 10 (10)| 00:00:01 |
|* 2 | HASH JOIN | | 5 | 480 | 7 (15)| 00:00:01 |
| 3 | NESTED LOOPS | | 3 | 159 | 3 (0)| 00:00:01 |
|* 4 | TABLE ACCESS FULL| SYS_NTGgl+TKyhQnWoFRSrCxeX9g== | 3 | 129 | 3 (0)| 00:00:01 |
|* 5 | INDEX UNIQUE SCAN| SYS_C0010174 | 1 | 10 | 0 (0)| 00:00:01 |
|* 6 | TABLE ACCESS FULL | SYS_NTUmyermF/S721C/2UXo40Uw== | 5 | 215 | 3 (0)| 00:00:01 |
|* 7 | TABLE ACCESS FULL | SYS_NTelW4ZRtKS+WKqCaXhsHnNQ== | 9 | 378 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - access("NESTED_TABLE_ID"="SYS_ALIAS_1"."SYS_NC0000900010$")
2 - access("SYS_ALIAS_1"."NESTED_TABLE_ID"="SYS_ALIAS_0"."SYS_NC0000800009$")
4 - filter("SYS_NC_TYPEID$" IS NOT NULL)
5 - access("NESTED_TABLE_ID"="LOCAL_TABLE"."SYS_NC0000800009$")
6 - filter("SYS_NC_TYPEID$" IS NOT NULL)
7 - filter("SYS_NC_TYPEID$" IS NOT NULL)
Note
- dynamic sampling used for this statement
SQL>Out of interest why are you so against using XMLType...
Edited by: mdrake on Jan 13, 2009 8:25 AM -
How to mapping Entity beans to existing database tables.
dear all
how can i mapping Entity beans to existing database tables and not to create new table in Orion.
thanks for any input.
seabin* You define the name of the table that an Entity EJB maps to in orion-ejb-jar.xml. For eg:<entity-deployment name="MyEntityEJB" data-source="MyDS" table="MY_DB_TABLE" ...>* If you don't want to let Orion create the tables for your EJBs, have the following entry in either of the files given below:<orion-application autocreate-tables="false" ...>1) <orion-home>/j2ee/home/config/application.xml (global effect)
2) orion-application.xml file of that particular application (application specific)
HTH. -
Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.The Oracle documentation has a good overview of the options available
Generating XML Data from the Database
Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
You can also find some information in XML DB FAQ -
How to input data in a database table without knowing in advance table and column configurations
Hi,
I have a problem using LabVIEW for input data (manually) in a SQL database. I have about 40 tables in the database, each of them is related to a specific engine component. I need to create a user interface (maybe visualizing the table with a table control) where the users can insert data in the database table fields. Could someone give me some suggestion on how to do it?
Using the DB tools insert data.vi I need to know in advance the column configuration of the table, but in my database each table has its own structure! So do I have to create 40 different masks, one for every different table?
Thanks in advance.
MichelaI have not actually used the LV SQL Toolkit, but I will try and offer high level ideas :-)
when you have retrieved the construction data for a table, you should be able to use array and cluster indexing to aquire the names of the fieds, enough to create a labelled table on the LV Front panel.
After completing a new entry you can INSERT the entry into the database using the same data.
Is the SQL toolkit an additional purchase, or included in newer versions as standard? If you post a sample of the cluster/array that you retrieve, I could give you a sample VI to give you some pointers in creating the User Interface table
- Cheers, Ed -
Returning XML Data from a database
Ok, just got the new DW CS3 and really want to begin using
the built in Spry capabilitites. All of the examples I've seen for
populating the datasets with XML data are based on referencing a
static XML file. I want to query my database and return XML data to
a Spry Table. How do I accomplish this? I know how to perform the
query and retrun the data in an XML format (ColdFusion) but I can't
tell the spry dataset to use this. HELP!!Well, that's the trick... I can't point to a testing server
(i.e. Application interface) because we aren't permitted to have
the RDS login where I work. (They haven't bothered to configure the
CF server for restricting access) I have to manually create all
connections and queries. I'm currenlty using the exact format in
the example page you provided to return the data in an XML format
but when I point to that file as my datasource I get nothing
displayed on the page. The file that performs the query and returns
the data is in a separate file from the one I'm trying to use the
Spry table in. When I use this same query file for an Ajax call to,
say, populate a listbox or pulldown menu it works fine, but I can't
get it to work with the Spry dataset. -
Create a data source and database tables using WSAD
Hi, guys:
the following is from a tutorial:
http://www-106.ibm.com/developerworks/websphere/techjournal/0306_wosnick/wosnick.html
"To create the data source and Cloudscape database tables automatically, right click on the HelloWorldServer in the Servers view, and select the Create tables and data sources menu item. A dialog will then display showing that the data source and database tables were created successfully (Figure 5)."
I am using WSAD 5.0 trial version. I cannot find Create tables and data sources menu item if I right click on the HelloWorldServer in the Servers view. I am wondering if this is because trial version does not have this feature?
regardsThis question is a little off topic but you may get a reply. Please note this forum is about Sun's J2EE SDK and its related technologies. You may have better luck posting your question to an IBM specific resource.
-
A query while importing an XML file into a Database Table
Hi,
I am Creating an ODI Project to import an XML file into a Database Table.With the help of the following link
http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/odi/odi_11g/odi_project_xml-to-table/odi_project_xml-to-table.htm
I am facing a problem while creating Physical Schema for the XML Source Model.
For the
Schema(Schema)
and
Schema(Work Schema) field they have selected GEO_D.
What is GEO_D here??
or
What I have to select here?
1) schema of the xml file (NB:-I havn't created any .xsd or .dtd file for my .xml file)
or
2)my target servers schema
Please tell me what I'll do??
Thanksand
Schema(Work Schema) field they have selected GEO_D.
What is GEO_D here??This is the schema name which is specified in the XML file .
What I have to select here?
1) schema of the xml file (NB:-I havn't created any .xsd or .dtd file for my .xml file)Yes
2)my target servers schema
Please tell me what I'll do??
Thanks -
Problem in mapping xml data with header details from IPM 11g to BPEL
Hi,
I want to map xml data as a supporting content from IPM application to BPEL.
My xml is
<?xml version="1.0" encoding="utf-8"?>
<DocumentFile xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/Document.xsd">
<Document DocumentType="Invoice">
<DocumentImage>
<Filename>\\10.205.0.209\Img\10883212.TIF</Filename>
</DocumentImage>
</DocumentFile>
If I remove header details from root element <DocumentFile> i.e. modified xml is
<DocumentFile>
<Document DocumentType="Invoice">
<DocumentImage>
<Filename>\\10.205.0.209\Img\10883212.TIF</Filename>
</DocumentImage>
</DocumentFile>
it works fine but i need to pass header details as well.
Please suggest.
Thanks,
PriyaHi Naveen,
In sxmb_moni the content transmitted to the adapter(RFC)is as follows
<?xml version="1.0" encoding="UTF-8" ?>
- <ns:ZRFID_EQUIP xmlns:ns="urn:sap-com:document:sap:rfc:functions">
- <RECORDS>
- <item>
<FLOC>f1-01-01</FLOC>
<RFID_NO>I006</RFID_NO>
</item>
- <item>
<FLOC>f1-01-02</FLOC>
<RFID_NO>I002</RFID_NO>
</item>
- <item>
<FLOC>f1-01-03</FLOC>
<RFID_NO>I003</RFID_NO>
</item>
- <item>
<FLOC>f1-01-04</FLOC>
<RFID_NO>I004</RFID_NO>
</item>
- <item>
<FLOC>f1-01-05</FLOC>
<RFID_NO>I005</RFID_NO>
</item>
- <item>
<FLOC>f1-01-06</FLOC>
<RFID_NO>I001</RFID_NO>
</item>
</RECORDS>
</ns:ZRFID_EQUIP>
At r/3 side the field floc and rfid_no gets mapped to floc which is of char30
eg floc=f1-01-01I006
rfid_no=
Maybe you are looking for
-
Photoshop closes when I try to open a file
I have CS5 and Photoshop opens fine. However, when I try to open a file, photoshop closes immediately. I re-installed photoshop and the same thing happens. How do I fix this?
-
What do I do after forced restart does nothing. Still can not use Ipad 2
I have ipad 2 running the latest update on 8. I was able to briefly turn on ipad last night, and then when I tried to use it , it would not do anything, nothing would open, therefore I forced closed. I have not been able to do a tyhing. I see apple
-
Master & slide title or object linking?
greetings, i've been using keynote for a few years. i'm using keynote version 5.0.4, which is the current version. i compiled a presentation recently by copying slides from older presentations. i've made a newer master and have reassigned the master
-
Where to maintain storage type in SAP
Hello guys do you have any idea of where exacly the storage type in MM01 or 02 is maintained. I need complete detail in which view and where to maintain storage type in that view also the database table to check the Storage type for any material
-
Previously I had a blackberry, if I wanted to add a song, all i had to to was drop and drag it to the device. Is there a way to just ADD a song and not have to sync the whole library? My daughter and husband and I all share music, but I don't want