Mapping XSD to a relational table
Hi
I jdeveloper how do i go about mapping a XSD file to a relational table ?
I know some tools like xml spy ca do these can jdeveloper do this ?
regards
When using the DATAEXPORT command to export data for direct insertion into a relational database:
● The table to which the data is to be written must exist prior to data export
● Table and column names cannot contain spaces
Check with the below syntax.
SET DATAEXPORTOPTIONS
DATAEXPORTDECIMAL 1;
DataExportLevel "LEVEL0";
DATAEXPORTCOLHEADER "Periods";
FIX("FY2011","Budget","Version1",FixedAssets,"Amount","622185","3011","BU_None" ,@LEVMBRS(Periods,0) AND @DESCENDANTS(Annual,0),@LEVMBRS(Currencies,0));
DATAEXPORT "DSN" "bfp" "ClaritydataCS.dbo.BEAM_Output_Budget" "bfpcssql" "pBaUsDsGwEoTrd123";
ENDFIX;
Similar Messages
-
Mapping with xml-schema XML-data to relational tables
Hello,
is it possible to map data from xml documents to relational tables with xml-schema?
I mean not in nested tables but in relational tables with primary and foreign keys!
With SQL Server 2005 it is very easy, I dont believe that Oracle couldn't do this!
I searched but i cant find anything about that!
Thx
user445232indeed, oracle does this for xml schema based xmltype data, however, these underlying tables are not accessable to the application. Maybe It should for next version, so folks who like to use relational model can use it without mapping it manually.
Actually, nested tables, are the same, their underlying tables (segments) are indeed relational tables, oracle manages them internally and not visiable to the application. You can find them in the user_segments, user_objects views though. -
XML file validation with XSD and loading to database relational table
Hi all,
I have some xml files coming to my unix directory. I will be having an XSD for those. My task is to validate those xml against given xsd and load the corresponding data into oracle relational tables with sqlloader only.
Please help me to accomplish. and let me know the contents of control file ( for SQLLOADER) if i want to load the xml directly to database.
Unix and/or PLSQL suggestions both are welcome.My problem area is loading the XML to Oracle relational tables using sqlloader.
suppose, the xml is <?xml version="1.0"?>
<Customers>
<Customer>
<CustID>1</CustID>
<Company>Bell South</Company>
<City>New York</City>
</Customer>
<Customer>
<CustID>2</CustID>
<Company>Barnes & Noble</Company>
<City>New York</City>
</Customer>
<Customer>
<CustID>3</CustID>
<Company>Comp USA</Company>
<City>Tampa</City>
</Customer>
<Customer>
<CustID>4</CustID>
<Company>Borders</Company>
<City>Charlotte</City>
</Customer>
</Customers>
and I have a relational table
CREATE TABLE CUSTOMERS
CUSTID NUMBER,
COMPANY VARCHAR2(100 BYTE),
CITY VARCHAR2(100 BYTE)
how to insert the xml data into the table???
please help..
Edited by: nuon on Oct 25, 2010 6:25 AM -
We are new to Oracle OLAP and AWM.
These are the questions we have :
1. Is there a way to map to external files rather than RDBMS for populating the cubes ? If so, how in AWM ?
2. If i want to have the cubes populated every day for 1 year time, should the RDBMS also (that maps the cube) should have one year data ?.
Once the cube is populated for yesterday from RDMS, can i not remove the yesterday's data from RDMS and load only the new data in RDBMS.
In such a case, the cube should have yesterdays data and the newly added data from today.
The intent is that, the RDBMS should have just 1 day or 1 week data but the cube should have 1 year data...1. Is there a way to map to external files rather than RDBMS for populating the cubes ? If so, how in AWM ?Define an RDBMS external table that maps to the external files and then map the cube to this table. See http://docs.oracle.com/cd/E11882_01/server.112/e22490/et_concepts.htm for more details.
2. If i want to have the cubes populated every day for 1 year time, should the RDBMS also (that maps the cube) should have one year data ?.
Once the cube is populated for yesterday from RDMS, can i not remove the yesterday's data from RDMS and load only the new data in RDBMS.
In such a case, the cube should have yesterdays data and the newly added data from today.
The intent is that, the RDBMS should have just 1 day or 1 week data but the cube should have 1 year data...The default behaviour of cubes defined in AWM is to add new data during each cube build and keep existing data (unless it is overridden in a cell). So if you build once a day from a fact table that contain only one day of data, then eventually the cube will contain a year of data. This is controlled by the "default cube script" for the cube. You need a cube script without a CLEAR command.
Given this setup, you should think about using the LOAD SERIAL option in the DBMS_CUBE.BUILD script. For example
exec DBMS_CUBE.BUILD('MY_CUBE USING (LOAD SERIAL, SOLVE)')This will cause the server to access the external table only once instead of once per partition. The per partition load makes sense if there are indexes on the fact table, but this is not going to be true in your case. It also make sense (in all cases) if you plan to partition the cube by DAY. -
How to create XML from relational tables based on an XML Schema ?
There is no automated way in Oracle XML DB to define an automatic mapping between a set of columns in some existing relational tables and the elements and attributres defined by an XML Schema.
However it is easy solve this problem by using the SQL/XML operators (XMLAGG, XMLELEMENT, XMLFOREST, XMLATTRIBUTES, etc) to generate XML documents that are compliant with an XML Schema directly from a SQL statement.
If the XML Schema is registered with Oracle XML DB and the appropraite Schema Location information is added into the generated document using XMLAttributes then it becomes very easy to ensure that the generated documents are valid.
The following example show an easy way to do this by creating an XML View that contains the documents to be validated.
SQL> drop table PURCHASEORDER_LINEITEM
2 /
Table dropped.
SQL> drop table PURCHASEORDER_REJECTION
2 /
Table dropped.
SQL> drop table PURCHASEORDER_SHIPPING
2 /
Table dropped.
SQL> drop TABLE PURCHASEORDER_ACTION
2 /
Table dropped.
SQL> drop TABLE PURCHASEORDER_TABLE
2 /
Table dropped.
SQL> create table PURCHASEORDER_TABLE
2 (
3 REFERENCE VARCHAR2(28),
4 PRIMARY KEY ("REFERENCE"),
5 REQUESTER VARCHAR2(48),
6 USERID VARCHAR2(32),
7 COSTCENTER VARCHAR2(3),
8 SPECIALINSTRUCTIONS VARCHAR2(2048)
9 )
10 /
Table created.
SQL> create table PURCHASEORDER_ACTION
2 (
3 REFERENCE,
4 FOREIGN KEY ("REFERENCE") REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
5 ACTIONEDBY VARCHAR2(32),
6 DATEACTIONED DATE
7 )
8 /
Table created.
SQL> create table PURCHASEORDER_SHIPPING
2 (
3 REFERENCE,
4 FOREIGN KEY ("REFERENCE") REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
5 PRIMARY KEY ("REFERENCE"),
6 SHIPTONAME VARCHAR2(48),
7 ADDRESS VARCHAR2(512),
8 PHONE VARCHAR2(32)
9 )
10 /
Table created.
SQL> create table PURCHASEORDER_REJECTION
2 (
3 REFERENCE,
4 FOREIGN KEY ("REFERENCE") REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
5 PRIMARY KEY ("REFERENCE"),
6 REJECTEDBY VARCHAR2(32),
7 DATEREJECTED DATE,
8 COMMENTS VARCHAR2(2048)
9 )
10 /
Table created.
SQL> create table PURCHASEORDER_LINEITEM
2 (
3 REFERENCE,
4 FOREIGN KEY ("REFERENCE") REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
5 LINENO NUMBER(10),
6 PRIMARY KEY ("REFERENCE","LINENO"),
7 UPC VARCHAR2(14),
8 DESCRIPTION VARCHAR2(128),
9 QUANTITY NUMBER(10),
10 UNITPRICE NUMBER(12,2)
11 )
12 /
Table created.
SQL> insert into PURCHASEORDER_TABLE values ('SMCCAIN-20030109123335470PDT','Samuel B. McCain','SMCCAIN','A10','Courier')
2 /
1 row created.
SQL> insert into PURCHASEORDER_ACTION values ('SMCCAIN-20030109123335470PDT','SVOLLMAN',NULL)
2 /
1 row created.
SQL> insert into PURCHASEORDER_SHIPPING values ('SMCCAIN-20030109123335470PDT','Samuel B. McCain','800 Bridge Parkway,Redwood Shores,CA,9406
5,USA','650 506 7800')
2 /
1 row created.
SQL> insert into PURCHASEORDER_REJECTION values ('SMCCAIN-20030109123335470PDT',null,null,null)
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','1','715515010320','Life of Brian - Monty Python''s','2','39.
95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','2','37429145227','The Night Porter','2','29.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','3','37429128121','Oliver Twist','1','39.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','4','715515012720','Notorious','4','39.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','5','715515012928','In the Mood for Love','3','39.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','6','37429130926','Alphaville','2','29.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','7','37429166529','General Idi Amin Dada','4','29.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','8','715515012928','In the Mood for Love','3','39.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','9','715515009423','Flesh for Frankenstein','3','39.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','10','715515008976','The Killer','1','39.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','11','37429167922','Ballad of a Soldier','2','29.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','12','37429158623','Ordet','2','0')
2 /
1 row created.
SQL> var schemaPath varchar2(256)
SQL> --
SQL> begin
2 :schemaURL := 'http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd';
3 :schemaPath := '/public/purchaseOrder.xsd';
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> call dbms_xmlSchema.deleteSchema(:schemaURL,4)
2 /
Call completed.
SQL> declare
2 res boolean;
3 xmlSchema xmlType := xmlType(
4 '<!-- edited with XML Spy v4.0 U (http://www.xmlspy.com) by Mark (Drake) -->
5 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" version="1.0" xdb:storeVarrayAsTable="tr
ue">
6 <xs:element name="PurchaseOrder" type="PurchaseOrderType" xdb:defaultTable="PURCHASEORDER"/>
7 <xs:complexType name="PurchaseOrderType" xdb:SQLType="PURCHASEORDER_T" xdb:maintainDOM="false">
8 <xs:sequence>
9 <xs:element name="Reference" type="ReferenceType" xdb:SQLName="REFERENCE"/>
10 <xs:element name="Actions" type="ActionsType" xdb:SQLName="ACTIONS"/>
11 <xs:element name="Reject" type="RejectionType" minOccurs="0" xdb:SQLName="REJECTION"/>
12 <xs:element name="Requestor" type="RequestorType" xdb:SQLName="REQUESTOR"/>
13 <xs:element name="User" type="UserType" xdb:SQLName="USERID"/>
14 <xs:element name="CostCenter" type="CostCenterType" xdb:SQLName="COST_CENTER"/>
15 <xs:element name="ShippingInstructions" type="ShippingInstructionsType" xdb:SQLName="SHIPPING_INSTRUCTIONS"/>
16 <xs:element name="SpecialInstructions" type="SpecialInstructionsType" xdb:SQLName="SPECIAL_INSTRUCTIONS"/>
17 <xs:element name="LineItems" type="LineItemsType" xdb:SQLName="LINEITEMS"/>
18 </xs:sequence>
19 </xs:complexType>
20 <xs:complexType name="LineItemsType" xdb:SQLType="LINEITEMS_T" xdb:maintainDOM="false">
21 <xs:sequence>
22 <xs:element name="LineItem" type="LineItemType" maxOccurs="unbounded" xdb:SQLName="LINEITEM" xdb:SQLCollType="L
INEITEM_V"/>
23 </xs:sequence>
24 </xs:complexType>
25 <xs:complexType name="LineItemType" xdb:SQLType="LINEITEM_T" xdb:maintainDOM="false">
26 <xs:sequence>
27 <xs:element name="Description" type="DescriptionType" xdb:SQLName="DESRIPTION"/>
28 <xs:element name="Part" type="PartType" xdb:SQLName="PART"/>
29 </xs:sequence>
30 <xs:attribute name="ItemNumber" type="xs:integer" xdb:SQLName="ITEMNUMBER" xdb:SQLType="NUMBER"/>
31 </xs:complexType>
32 <xs:complexType name="PartType" xdb:SQLType="PART_T" xdb:maintainDOM="false">
33 <xs:attribute name="Id" xdb:SQLName="PART_NUMBER" xdb:SQLType="VARCHAR2">
34 <xs:simpleType>
35 <xs:restriction base="xs:string">
36 <xs:minLength value="10"/>
37 <xs:maxLength value="14"/>
38 </xs:restriction>
39 </xs:simpleType>
40 </xs:attribute>
41 <xs:attribute name="Quantity" type="moneyType" xdb:SQLName="QUANTITY"/>
42 <xs:attribute name="UnitPrice" type="quantityType" xdb:SQLName="UNITPRICE"/>
43 </xs:complexType>
44 <xs:simpleType name="ReferenceType">
45 <xs:restriction base="xs:string">
46 <xs:minLength value="18"/>
47 <xs:maxLength value="30"/>
48 </xs:restriction>
49 </xs:simpleType>
50 <xs:complexType name="ActionsType" xdb:SQLType="ACTIONS_T" xdb:maintainDOM="false">
51 <xs:sequence>
52 <xs:element name="Action" maxOccurs="4" xdb:SQLName="ACTION" xdb:SQLCollType="ACTION_V">
53 <xs:complexType xdb:SQLType="ACTION_T" xdb:maintainDOM="false">
54 <xs:sequence>
55 <xs:element name="User" type="UserType" xdb:SQLName="ACTIONED_BY"/>
56 <xs:element name="Date" type="DateType" minOccurs="0" xdb:SQLName="DATE_ACTIONED"/>
57 </xs:sequence>
58 </xs:complexType>
59 </xs:element>
60 </xs:sequence>
61 </xs:complexType>
62 <xs:complexType name="RejectionType" xdb:SQLType="REJECTION_T" xdb:maintainDOM="false">
63 <xs:all>
64 <xs:element name="User" type="UserType" minOccurs="0" xdb:SQLName="REJECTED_BY"/>
65 <xs:element name="Date" type="DateType" minOccurs="0" xdb:SQLName="DATE_REJECTED"/>
66 <xs:element name="Comments" type="CommentsType" minOccurs="0" xdb:SQLName="REASON_REJECTED"/>
67 </xs:all>
68 </xs:complexType>
69 <xs:complexType name="ShippingInstructionsType" xdb:SQLType="SHIPPING_INSTRUCTIONS_T" xdb:maintainDOM="false">
70 <xs:sequence>
71 <xs:element name="name" type="NameType" minOccurs="0" xdb:SQLName="SHIP_TO_NAME"/>
72 <xs:element name="address" type="AddressType" minOccurs="0" xdb:SQLName="SHIP_TO_ADDRESS"/>
73 <xs:element name="telephone" type="TelephoneType" minOccurs="0" xdb:SQLName="SHIP_TO_PHONE"/>
74 </xs:sequence>
75 </xs:complexType>
76 <xs:simpleType name="moneyType">
77 <xs:restriction base="xs:decimal">
78 <xs:fractionDigits value="2"/>
79 <xs:totalDigits value="12"/>
80 </xs:restriction>
81 </xs:simpleType>
82 <xs:simpleType name="quantityType">
83 <xs:restriction base="xs:decimal">
84 <xs:fractionDigits value="4"/>
85 <xs:totalDigits value="8"/>
86 </xs:restriction>
87 </xs:simpleType>
88 <xs:simpleType name="UserType">
89 <xs:restriction base="xs:string">
90 <xs:minLength value="1"/>
91 <xs:maxLength value="10"/>
92 </xs:restriction>
93 </xs:simpleType>
94 <xs:simpleType name="RequestorType">
95 <xs:restriction base="xs:string">
96 <xs:minLength value="0"/>
97 <xs:maxLength value="128"/>
98 </xs:restriction>
99 </xs:simpleType>
100 <xs:simpleType name="CostCenterType">
101 <xs:restriction base="xs:string">
102 <xs:minLength value="1"/>
103 <xs:maxLength value="4"/>
104 </xs:restriction>
105 </xs:simpleType>
106 <xs:simpleType name="VendorType">
107 <xs:restriction base="xs:string">
108 <xs:minLength value="0"/>
109 <xs:maxLength value="20"/>
110 </xs:restriction>
111 </xs:simpleType>
112 <xs:simpleType name="PurchaseOrderNumberType">
113 <xs:restriction base="xs:integer"/>
114 </xs:simpleType>
115 <xs:simpleType name="SpecialInstructionsType">
116 <xs:restriction base="xs:string">
117 <xs:minLength value="0"/>
118 <xs:maxLength value="2048"/>
119 </xs:restriction>
120 </xs:simpleType>
121 <xs:simpleType name="NameType">
122 <xs:restriction base="xs:string">
123 <xs:minLength value="1"/>
124 <xs:maxLength value="20"/>
125 </xs:restriction>
126 </xs:simpleType>
127 <xs:simpleType name="AddressType">
128 <xs:restriction base="xs:string">
129 <xs:minLength value="1"/>
130 <xs:maxLength value="256"/>
131 </xs:restriction>
132 </xs:simpleType>
133 <xs:simpleType name="TelephoneType">
134 <xs:restriction base="xs:string">
135 <xs:minLength value="1"/>
136 <xs:maxLength value="24"/>
137 </xs:restriction>
138 </xs:simpleType>
139 <xs:simpleType name="DateType">
140 <xs:restriction base="xs:date"/>
141 </xs:simpleType>
142 <xs:simpleType name="CommentsType">
143 <xs:restriction base="xs:string">
144 <xs:minLength value="1"/>
145 <xs:maxLength value="2048"/>
146 </xs:restriction>
147 </xs:simpleType>
148 <xs:simpleType name="DescriptionType">
149 <xs:restriction base="xs:string">
150 <xs:minLength value="1"/>
151 <xs:maxLength value="256"/>
152 </xs:restriction>
153 </xs:simpleType>
154 </xs:schema>
155 ');
156 begin
157 if (dbms_xdb.existsResource(:schemaPath)) then
158 dbms_xdb.deleteResource(:schemaPath);
159 end if;
160 res := dbms_xdb.createResource(:schemaPath,xmlSchema);
161 end;
162 /
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_xmlschema.registerSchema
3 (
4 :schemaURL,
5 xdbURIType(:schemaPath).getClob(),
6 TRUE,TRUE,FALSE,FALSE
7 );
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> create or replace view PURCHASEORDER_XML
2 of xmltype
3 xmlSCHEMA "http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd" Element "PurchaseOrder"
4 with object id
5 (
6 substr(extractValue(object_value,'/PurchaseOrder/Reference'),1,32)
7 )
8 as
9 select xmlElement
10 (
11 "PurchaseOrder",
12 xmlAttributes
13 (
14 'http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd' as "xsi:noNamespaceSchemaLocation",
15 'http://www.w3.org/2001/XMLSchema-instance' as "xmlns:xsi"
16 ),
17 xmlElement("Reference",p.REFERENCE),
18 xmlElement
19 (
20 "Actions",
21 ( select xmlAgg
22 (
23 xmlElement
24 (
25 "Action",
26 xmlElement("User",ACTIONEDBY),
27 case
28 when DATEACTIONED is not null
29 then xmlElement("Date",DATEACTIONED)
30 end
31 )
32 )
33 from PURCHASEORDER_ACTION a
34 where a.REFERENCE = p.REFERENCE
35 )
36 ),
37 xmlElement
38 (
39 "Reject",
40 xmlForest
41 (
42 REJECTEDBY as "User",
43 DATEREJECTED as "Date",
44 COMMENTS as "Comments"
45 )
46 ),
47 xmlElement("Requestor",REQUESTER),
48 xmlElement("User",USERID),
49 xmlElement("CostCenter",COSTCENTER),
50 xmlElement
51 (
52 "ShippingInstructions",
53 xmlElement("name",SHIPTONAME),
54 xmlElement("address",ADDRESS),
55 xmlElement("telephone",PHONE)
56 ),
57 xmlElement("SpecialInstructions",SPECIALINSTRUCTIONS),
58 xmlElement
59 (
60 "LineItems",
61 ( select xmlAgg
62 (
63 xmlElement
64 (
65 "LineItem",
66 xmlAttributes(LINENO as "ItemNumber"),
67 xmlElement("Description",DESCRIPTION),
68 xmlElement
69 (
70 "Part",
71 xmlAttributes
72 (
73 UPC as "Id",
74 QUANTITY as "Quantity",
75 UNITPRICE as "UnitPrice"
76 )
77 )
78 )
79 )
80 from PURCHASEORDER_LINEITEM l
81 where l.REFERENCE = p.REFERENCE
82 )
83 )
84 )
85 from PURCHASEORDER_TABLE p, PURCHASEORDER_REJECTION r, PURCHASEORDER_SHIPPING s
86 where r.REFERENCE = p.REFERENCE
87 and s.REFERENCE = p.REFERENCE
88 /
View created.
SQL> set long 10000 pages 0 lines 140
SQL> --
SQL> select x.object_value.extract('/*')
2 from PURCHASEORDER_XML x
3 /
<PurchaseOrder xsi:noNamespaceSchemaLocation="http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Reference>SMCCAIN-20030109123335470PDT</Reference>
<Actions>
<Action>
<User>SVOLLMAN</User>
</Action>
</Actions>
<Reject/>
<Requestor>Samuel B. McCain</Requestor>
<User>SMCCAIN</User>
<CostCenter>A10</CostCenter>
<ShippingInstructions>
<name>Samuel B. McCain</name>
<address>800 Bridge Parkway,Redwood Shores,CA,94065,USA</address>
<telephone>650 506 7800</telephone>
</ShippingInstructions>
<SpecialInstructions>Courier</SpecialInstructions>
<LineItems>
<LineItem ItemNumber="1">
<Description>Life of Brian - Monty Python's</Description>
<Part Id="715515010320" Quantity="2" UnitPrice="39.95"/>
</LineItem>
<LineItem ItemNumber="2">
<Description>The Night Porter</Description>
<Part Id="37429145227" Quantity="2" UnitPrice="29.95"/>
</LineItem>
<LineItem ItemNumber="3">
<Description>Oliver Twist</Description>
<Part Id="37429128121" Quantity="1" UnitPrice="39.95"/>
</LineItem>
<LineItem ItemNumber="4">
<Description>Notorious</Description>
<Part Id="715515012720" Quantity="4" UnitPrice="39.95"/>
</LineItem>
<LineItem ItemNumber="5">
<Description>In the Mood for Love</Description>
<Part Id="715515012928" Quantity="3" UnitPrice="39.95"/>
</LineItem>
<LineItem ItemNumber="6">
<Description>Alphaville</Description>
<Part Id="37429130926" Quantity="2" UnitPrice="29.95"/>
</LineItem>
<LineItem ItemNumber="7">
<Description>General Idi Amin Dada</Description>
<Part Id="37429166529" Quantity="4" UnitPrice="29.95"/>
</LineItem>
<LineItem ItemNumber="8">
<Description>In the Mood for Love</Description>
<Part Id="715515012928" Quantity="3" UnitPrice="39.95"/>
</LineItem>
<LineItem ItemNumber="9">
<Description>Flesh for Frankenstein</Description>
<Part Id="715515009423" Quantity="3" UnitPrice="39.95"/>
</LineItem>
<LineItem ItemNumber="10">
<Description>The Killer</Description>
<Part Id="715515008976" Quantity="1" UnitPrice="39.95"/>
</LineItem>
<LineItem ItemNumber="11">
<Description>Ballad of a Soldier</Description>
<Part Id="37429167922" Quantity="2" UnitPrice="29.95"/>
</LineItem>
<LineItem ItemNumber="12">
<Description>Ordet</Description>
<Part Id="37429158623" Quantity="2" UnitPrice="0"/>
</LineItem>
</LineItems>
</PurchaseOrder>
SQL> begin
2 for x in (select object_value from PURCHASEORDER_XML) loop
3 x.object_value.schemaValidate();
4 end loop;
5 end;
6 /
PL/SQL procedure successfully completed.
SQL>There is no automated way in Oracle XML DB to define an automatic mapping between a set of columns in some existing relational tables and the elements and attributres defined by an XML Schema.
However it is easy solve this problem by using the SQL/XML operators (XMLAGG, XMLELEMENT, XMLFOREST, XMLATTRIBUTES, etc) to generate XML documents that are compliant with an XML Schema directly from a SQL statement.
If the XML Schema is registered with Oracle XML DB and the appropraite Schema Location information is added into the generated document using XMLAttributes then it becomes very easy to ensure that the generated documents are valid.
The following example show an easy way to do this by creating an XML View that contains the documents to be validated.
SQL> drop table PURCHASEORDER_LINEITEM
2 /
Table dropped.
SQL> drop table PURCHASEORDER_REJECTION
2 /
Table dropped.
SQL> drop table PURCHASEORDER_SHIPPING
2 /
Table dropped.
SQL> drop TABLE PURCHASEORDER_ACTION
2 /
Table dropped.
SQL> drop TABLE PURCHASEORDER_TABLE
2 /
Table dropped.
SQL> create table PURCHASEORDER_TABLE
2 (
3 REFERENCE VARCHAR2(28),
4 PRIMARY KEY ("REFERENCE"),
5 REQUESTER VARCHAR2(48),
6 USERID VARCHAR2(32),
7 COSTCENTER VARCHAR2(3),
8 SPECIALINSTRUCTIONS VARCHAR2(2048)
9 )
10 /
Table created.
SQL> create table PURCHASEORDER_ACTION
2 (
3 REFERENCE,
4 FOREIGN KEY ("REFERENCE") REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
5 ACTIONEDBY VARCHAR2(32),
6 DATEACTIONED DATE
7 )
8 /
Table created.
SQL> create table PURCHASEORDER_SHIPPING
2 (
3 REFERENCE,
4 FOREIGN KEY ("REFERENCE") REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
5 PRIMARY KEY ("REFERENCE"),
6 SHIPTONAME VARCHAR2(48),
7 ADDRESS VARCHAR2(512),
8 PHONE VARCHAR2(32)
9 )
10 /
Table created.
SQL> create table PURCHASEORDER_REJECTION
2 (
3 REFERENCE,
4 FOREIGN KEY ("REFERENCE") REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
5 PRIMARY KEY ("REFERENCE"),
6 REJECTEDBY VARCHAR2(32),
7 DATEREJECTED DATE,
8 COMMENTS VARCHAR2(2048)
9 )
10 /
Table created.
SQL> create table PURCHASEORDER_LINEITEM
2 (
3 REFERENCE,
4 FOREIGN KEY ("REFERENCE") REFERENCES "PURCHASEORDER_TABLE" ("REFERENCE") ON DELETE CASCADE,
5 LINENO NUMBER(10),
6 PRIMARY KEY ("REFERENCE","LINENO"),
7 UPC VARCHAR2(14),
8 DESCRIPTION VARCHAR2(128),
9 QUANTITY NUMBER(10),
10 UNITPRICE NUMBER(12,2)
11 )
12 /
Table created.
SQL> insert into PURCHASEORDER_TABLE values ('SMCCAIN-20030109123335470PDT','Samuel B. McCain','SMCCAIN','A10','Courier')
2 /
1 row created.
SQL> insert into PURCHASEORDER_ACTION values ('SMCCAIN-20030109123335470PDT','SVOLLMAN',NULL)
2 /
1 row created.
SQL> insert into PURCHASEORDER_SHIPPING values ('SMCCAIN-20030109123335470PDT','Samuel B. McCain','800 Bridge Parkway,Redwood Shores,CA,9406
5,USA','650 506 7800')
2 /
1 row created.
SQL> insert into PURCHASEORDER_REJECTION values ('SMCCAIN-20030109123335470PDT',null,null,null)
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','1','715515010320','Life of Brian - Monty Python''s','2','39.
95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','2','37429145227','The Night Porter','2','29.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','3','37429128121','Oliver Twist','1','39.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','4','715515012720','Notorious','4','39.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','5','715515012928','In the Mood for Love','3','39.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','6','37429130926','Alphaville','2','29.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','7','37429166529','General Idi Amin Dada','4','29.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','8','715515012928','In the Mood for Love','3','39.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','9','715515009423','Flesh for Frankenstein','3','39.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','10','715515008976','The Killer','1','39.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','11','37429167922','Ballad of a Soldier','2','29.95')
2 /
1 row created.
SQL> insert into PURCHASEORDER_LINEITEM values ('SMCCAIN-20030109123335470PDT','12','37429158623','Ordet','2','0')
2 /
1 row created.
SQL> var schemaPath varchar2(256)
SQL> --
SQL> begin
2 :schemaURL := 'http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd';
3 :schemaPath := '/public/purchaseOrder.xsd';
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> call dbms_xmlSchema.deleteSchema(:schemaURL,4)
2 /
Call completed.
SQL> declare
2 res boolean;
3 xmlSchema xmlType := xmlType(
4 '<!-- edited with XML Spy v4.0 U (http://www.xmlspy.com) by Mark (Drake) -->
5 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" version="1.0" xdb:storeVarrayAsTable="tr
ue">
6 <xs:element name="PurchaseOrder" type="PurchaseOrderType" xdb:defaultTable="PURCHASEORDER"/>
7 <xs:complexType name="PurchaseOrderType" xdb:SQLType="PURCHASEORDER_T" xdb:maintainDOM="false">
8 <xs:sequence>
9 <xs:element name="Reference" type="ReferenceType" xdb:SQLName="REFERENCE"/>
10 <xs:element name="Actions" type="ActionsType" xdb:SQLName="ACTIONS"/>
11 <xs:element name="Reject" type="RejectionType" minOccurs="0" xdb:SQLName="REJECTION"/>
12 <xs:element name="Requestor" type="RequestorType" xdb:SQLName="REQUESTOR"/>
13 <xs:element name="User" type="UserType" xdb:SQLName="USERID"/>
14 <xs:element name="CostCenter" type="CostCenterType" xdb:SQLName="COST_CENTER"/>
15 <xs:element name="ShippingInstructions" type="ShippingInstructionsType" xdb:SQLName="SHIPPING_INSTRUCTIONS"/>
16 <xs:element name="SpecialInstructions" type="SpecialInstructionsType" xdb:SQLName="SPECIAL_INSTRUCTIONS"/>
17 <xs:element name="LineItems" type="LineItemsType" xdb:SQLName="LINEITEMS"/>
18 </xs:sequence>
19 </xs:complexType>
20 <xs:complexType name="LineItemsType" xdb:SQLType="LINEITEMS_T" xdb:maintainDOM="false">
21 <xs:sequence>
22 <xs:element name="LineItem" type="LineItemType" maxOccurs="unbounded" xdb:SQLName="LINEITEM" xdb:SQLCollType="L
INEITEM_V"/>
23 </xs:sequence>
24 </xs:complexType>
25 <xs:complexType name="LineItemType" xdb:SQLType="LINEITEM_T" xdb:maintainDOM="false">
26 <xs:sequence>
27 <xs:element name="Description" type="DescriptionType" xdb:SQLName="DESRIPTION"/>
28 <xs:element name="Part" type="PartType" xdb:SQLName="PART"/>
29 </xs:sequence>
30 <xs:attribute name="ItemNumber" type="xs:integer" xdb:SQLName="ITEMNUMBER" xdb:SQLType="NUMBER"/>
31 </xs:complexType>
32 <xs:complexType name="PartType" xdb:SQLType="PART_T" xdb:maintainDOM="false">
33 <xs:attribute name="Id" xdb:SQLName="PART_NUMBER" xdb:SQLType="VARCHAR2">
34 <xs:simpleType>
35 <xs:restriction base="xs:string">
36 <xs:minLength value="10"/>
37 <xs:maxLength value="14"/>
38 </xs:restriction>
39 </xs:simpleType>
40 </xs:attribute>
41 <xs:attribute name="Quantity" type="moneyType" xdb:SQLName="QUANTITY"/>
42 <xs:attribute name="UnitPrice" type="quantityType" xdb:SQLName="UNITPRICE"/>
43 </xs:complexType>
44 <xs:simpleType name="ReferenceType">
45 <xs:restriction base="xs:string">
46 <xs:minLength value="18"/>
47 <xs:maxLength value="30"/>
48 </xs:restriction>
49 </xs:simpleType>
50 <xs:complexType name="ActionsType" xdb:SQLType="ACTIONS_T" xdb:maintainDOM="false">
51 <xs:sequence>
52 <xs:element name="Action" maxOccurs="4" xdb:SQLName="ACTION" xdb:SQLCollType="ACTION_V">
53 <xs:complexType xdb:SQLType="ACTION_T" xdb:maintainDOM="false">
54 <xs:sequence>
55 <xs:element name="User" type="UserType" xdb:SQLName="ACTIONED_BY"/>
56 <xs:element name="Date" type="DateType" minOccurs="0" xdb:SQLName="DATE_ACTIONED"/>
57 </xs:sequence>
58 </xs:complexType>
59 </xs:element>
60 </xs:sequence>
61 </xs:complexType>
62 <xs:complexType name="RejectionType" xdb:SQLType="REJECTION_T" xdb:maintainDOM="false">
63 <xs:all>
64 <xs:element name="User" type="UserType" minOccurs="0" xdb:SQLName="REJECTED_BY"/>
65 <xs:element name="Date" type="DateType" minOccurs="0" xdb:SQLName="DATE_REJECTED"/>
66 <xs:element name="Comments" type="CommentsType" minOccurs="0" xdb:SQLName="REASON_REJECTED"/>
67 </xs:all>
68 </xs:complexType>
69 <xs:complexType name="ShippingInstructionsType" xdb:SQLType="SHIPPING_INSTRUCTIONS_T" xdb:maintainDOM="false">
70 <xs:sequence>
71 <xs:element name="name" type="NameType" minOccurs="0" xdb:SQLName="SHIP_TO_NAME"/>
72 <xs:element name="address" type="AddressType" minOccurs="0" xdb:SQLName="SHIP_TO_ADDRESS"/>
73 <xs:element name="telephone" type="TelephoneType" minOccurs="0" xdb:SQLName="SHIP_TO_PHONE"/>
74 </xs:sequence>
75 </xs:complexType>
76 <xs:simpleType name="moneyType">
77 <xs:restriction base="xs:decimal">
78 <xs:fractionDigits value="2"/>
79 <xs:totalDigits value="12"/>
80 </xs:restriction>
81 </xs:simpleType>
82 <xs:simpleType name="quantityType">
83 <xs:restriction base="xs:decimal">
84 <xs:fractionDigits value="4"/>
85 <xs:totalDigits value="8"/>
86 </xs:restriction>
87 </xs:simpleType>
88 <xs:simpleType name="UserType">
89 <xs:restriction base="xs:string">
90 <xs:minLength value="1"/>
91 <xs:maxLength value="10"/>
92 </xs:restriction>
93 </xs:simpleType>
94 <xs:simpleType name="RequestorType">
95 <xs:restriction base="xs:string">
96 <xs:minLength value="0"/>
97 <xs:maxLength value="128"/>
98 </xs:restriction>
99 </xs:simpleType>
100 <xs:simpleType name="CostCenterType">
101 <xs:restriction base="xs:string">
102 <xs:minLength value="1"/>
103 <xs:maxLength value="4"/>
104 </xs:restriction>
105 </xs:simpleType>
106 <xs:simpleType name="VendorType">
107 <xs:restriction base="xs:string">
108 <xs:minLength value="0"/>
109 <xs:maxLength value="20"/>
110 </xs:restriction>
111 </xs:simpleType>
112 <xs:simpleType name="PurchaseOrderNumberType">
113 <xs:restriction base="xs:integer"/>
114 </xs:simpleType>
115 <xs:simpleType name="SpecialInstructionsType">
116 <xs:restriction base="xs:string">
117 <xs:minLength value="0"/>
118 <xs:maxLength value="2048"/>
119 </xs:restriction>
120 </xs:simpleType>
121 <xs:simpleType name="NameType">
122 <xs:restriction base="xs:string">
123 <xs:minLength value="1"/>
124 <xs:maxLength value="20"/>
125 </xs:restriction>
126 </xs:simpleType>
127 <xs:simpleType name="AddressType">
128 <xs:restriction base="xs:string">
129 <xs:minLength value="1"/>
130 <xs:maxLength value="256"/>
131 </xs:restriction>
132 </xs:simpleType>
133 <xs:simpleType name="TelephoneType">
134 <xs:restriction base="xs:string">
135 <xs:minLength value="1"/>
136 <xs:maxLength value="24"/>
137 </xs:restriction>
138 </xs:simpleType>
139 <xs:simpleType name="DateType">
140 <xs:restriction base="xs:date"/>
141 </xs:simpleType>
142 <xs:simpleType name="CommentsType">
143 <xs:restriction base="xs:string">
144 <xs:minLength value="1"/>
145 <xs:maxLength value="2048"/>
146 </xs:restriction>
147 </xs:simpleType>
148 <xs:simpleType name="DescriptionType">
149 <xs:restriction base="xs:string">
150 <xs:minLength value="1"/>
151 <xs:maxLength value="256"/>
152 </xs:restriction>
153 </xs:simpleType>
154 </xs:schema>
155 ');
156 begin
157 if (dbms_xdb.existsResource(:schemaPath)) then
158 dbms_xdb.deleteResource(:schemaPath);
159 end if;
160 res := dbms_xdb.createResource(:schemaPath,xmlSchema);
161 end;
162 /
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_xmlschema.registerSchema
3 (
4 :schemaURL,
5 xdbURIType(:schemaPath).getClob(),
6 TRUE,TRUE,FALSE,FALSE
7 );
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> create or replace view PURCHASEORDER_XML
2 of xmltype
3 xmlSCHEMA "http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd" Element "PurchaseOrder"
4 with object id
5 (
6 substr(extractValue(object_value,'/PurchaseOrder/Reference'),1,32)
7 )
8 as
9 select xmlElement
10 (
11 "PurchaseOrder",
12 xmlAttributes
13 (
14 'http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd' as "xsi:noNamespaceSchemaLocation",
15 'http://www.w3.org/2001/XMLSchema-instance' as "xmlns:xsi"
16 ),
17 xmlElement("Reference",p.REFERENCE),
18 xmlElement
19 (
20 "Actions",
21 ( select xmlAgg
22 (
23 xmlElement
24 (
25 "Action",
26 xmlElement("User",ACTIONEDBY),
27 case
28 when DATEACTIONED is not null
29 then xmlElement("Date",DATEACTIONED)
30 end
31 )
32 )
33 from PURCHASEORDER_ACTION a
34 where a.REFERENCE = p.REFERENCE
35 )
36 ),
37 xmlElement
38 (
39 "Reject",
40 xmlForest
41 (
42 REJECTEDBY as "User",
43 DATEREJECTED as "Date",
44 COMMENTS as "Comments"
45 )
46 ),
47 xmlElement("Requestor",REQUESTER),
48 xmlElement("User",USERID),
49 xmlElement("CostCenter",COSTCENTER),
50 xmlElement
51 (
52 "ShippingInstructions",
53 xmlElement("name",SHIPTONAME),
54 xmlElement("address",ADDRESS),
55 xmlElement("telephone",PHONE)
56 ),
57 xmlElement("SpecialInstructions",SPECIALINSTRUCTIONS),
58 xmlElement
59 (
60 "LineItems",
61 ( select xmlAgg
62 (
63 xmlElement
64 (
65 "LineItem",
66 xmlAttributes(LINENO as "ItemNumber"),
67 xmlElement("Description",DESCRIPTION),
68 xmlElement
69 (
70 "Part",
71 xmlAttributes
72 (
73 UPC as "Id",
74 QUANTITY as "Quantity",
75 UNITPRICE as "UnitPrice"
76 )
77 )
78 )
79 )
80 from PURCHASEORDER_LINEITEM l
81 where l.REFERENCE = p.REFERENCE
82 )
83 )
84 )
85 from PURCHASEORDER_TABLE p, PURCHASEORDER_REJECTION r, PURCHASEORDER_SHIPPING s
86 where r.REFERENCE = p.REFERENCE
87 and s.REFERENCE = p.REFERENCE
88 /
View created.
SQL> set long 10000 pages 0 lines 140
SQL> --
SQL> select x.object_value.extract('/*')
2 from PURCHASEORDER_XML x
3 /
<PurchaseOrder xsi:noNamespaceSchemaLocation="http://xfiles:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Reference>SMCCAIN-20030109123335470PDT</Reference>
<Actions>
<Action>
<User>SVOLLMAN</User>
</Action>
</Actions>
<Reject/>
<Requestor>Samuel B. McCain</Requestor>
<User>SMCCAIN</User>
<CostCenter>A10</CostCenter>
<ShippingInstructions>
<name>Samuel B. McCain</name>
<address>800 Bridge Parkway,Redwood Shores,CA,94065,USA</address>
<telephone>650 506 7800</telephone>
</ShippingInstructions>
<SpecialInstructions>Courier</SpecialInstructions>
<LineItems>
<LineItem ItemNumber="1">
<Description>Life of Brian - Monty Python's</Description>
<Part Id="715515010320" Quantity="2" UnitPrice="39.95"/>
</LineItem>
<LineItem ItemNumber="2">
<Description>The Night Porter</Description>
<Part Id="37429145227" Quantity="2" UnitPrice="29.95"/>
</LineItem>
<LineItem ItemNumber="3">
<Description>Oliver Twist</Description>
<Part Id="37429128121" Quantity="1" UnitPrice="39.95"/>
</LineItem>
<LineItem ItemNumber="4">
<Description>Notorious</Description>
<Part Id="715515012720" Quantity="4" UnitPrice="39.95"/>
</LineItem>
<LineItem ItemNumber="5">
<Description>In the Mood for Love</Description>
<Part Id="715515012928" Quantity="3" UnitPrice="39.95"/>
</LineItem>
<LineItem ItemNumber="6">
<Description>Alphaville</Description>
<Part Id="37429130926" Quantity="2" UnitPrice="29.95"/>
</LineItem>
<LineItem ItemNumber="7">
<Description>General Idi Amin Dada</Description>
<Part Id="37429166529" Quantity="4" UnitPrice="29.95"/>
</LineItem>
<LineItem ItemNumber="8">
<Description>In the Mood for Love</Description>
<Part Id="715515012928" Quantity="3" UnitPrice="39.95"/>
</LineItem>
<LineItem ItemNumber="9">
<Description>Flesh for Frankenstein</Description>
<Part Id="715515009423" Quantity="3" UnitPrice="39.95"/>
</LineItem>
<LineItem ItemNumber="10">
<Description>The Killer</Description>
<Part Id="715515008976" Quantity="1" UnitPrice="39.95"/>
</LineItem>
<LineItem ItemNumber="11">
<Description>Ballad of a Soldier</Description>
<Part Id="37429167922" Quantity="2" UnitPrice="29.95"/>
</LineItem>
<LineItem ItemNumber="12">
<Description>Ordet</Description>
<Part Id="37429158623" Quantity="2" UnitPrice="0"/>
</LineItem>
</LineItems>
</PurchaseOrder>
SQL> begin
2 for x in (select object_value from PURCHASEORDER_XML) loop
3 x.object_value.schemaValidate();
4 end loop;
5 end;
6 /
PL/SQL procedure successfully completed.
SQL> -
XML DB to Relational table?
Hi Everybody,
We have a situation to map the elements/attributes of XML tables in XML DB (Oracle 9i) to target relational tables.
We have XML schema as starting point. Do you have any white paper or documentation to help us do mapping ?
I appreciate your help.
RamYou can start from here:
http://otn.oracle.com/tech/xml/xmldb/index.html -
From XML in CLOB to relational table doubt
versions 11.2.0.2.0 / 10.2.0.4.0
It's a long time, no see since my last dealing with xml and no luck to have an attribute value returned into the relational table.
It's *<IntrBkSttlmAmt Ccy="???">999999</IntrBkSttlmAmt>*
For the rest the below works in both versions but used on an xml having a 10000 <CdtTrfTxInf> on 11g it took 9 seconds and was killed because no answer was produced after 30 minutes on 10g. A colleague using java loaded the relational table in 34 seconds on 10g and produced the relational table on 11g in just 5 seconds.
The 10g version is surviving with no xmldb installed and there are rumors our thinking heads didn't succeed to deactivate it on 11g yet.
Any suggestion concerning alternate ways to produce a relational table from an xmltype located in a clob column of a relational table are welcome
(looking at CLOB in XML to Normal table Best approach? I thought too many xmltable would have to be used)
with
the_data as
(select q'~
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.01">
<pacs.008.001.01>
<GrpHdr>
<MsgId>1L1U000JB4UT1FVS</MsgId>
<MsgId>9X9X999XX9XX9XXX</MsgId>
<CreDtTm>YYYY-MM-DDTHH:MI:SS</CreDtTm>
<NbOfTxs>99999</NbOfTxs>
<TtlIntrBkSttlmAmt Ccy="???">9999999</TtlIntrBkSttlmAmt>
<IntrBkSttlmDt>YYYY-MM-DD</IntrBkSttlmDt>
<SttlmInf>
<SttlmMtd>XXXX</SttlmMtd>
<ClrSys>
<ClrSysId>XXXX</ClrSysId>
</ClrSys>
</SttlmInf>
</GrpHdr>
<CdtTrfTxInf>
<PmtId>
<InstrId>XXXXXXX999999-XX999999.XX</InstrId>
<EndToEndId>X9999999999</EndToEndId>
<TxId>X9999-9999999999</TxId>
</PmtId>
<PmtTpInf>
<SvcLvl>
<Cd>XXXX</Cd>
</SvcLvl>
</PmtTpInf>
<IntrBkSttlmAmt Ccy="???">999999</IntrBkSttlmAmt>
<ChrgBr>XXXX</ChrgBr>
<InstgAgt>
<FinInstnId>
<BIC>XXXXXX9X</BIC>
</FinInstnId>
</InstgAgt>
<Dbtr>
<Nm>NAME</Nm>
<PstlAdr>
<AdrLine>ADDRESS</AdrLine>
<AdrLine>CITY</AdrLine>
<Ctry>XX</Ctry>
</PstlAdr>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>XX99999999999999999</IBAN>
</Id>
</DbtrAcct>
<DbtrAgt>
<FinInstnId>
<BIC>XXXXXX9X</BIC>
</FinInstnId>
</DbtrAgt>
<CdtrAgt>
<FinInstnId>
<BIC>XXXXXX9X</BIC>
</FinInstnId>
</CdtrAgt>
<Cdtr>
<Nm>NAME</Nm>
<PstlAdr>
<AdrLine>ADDRESS</AdrLine>
<AdrLine>CITY</AdrLine>
<Ctry>XX</Ctry>
</PstlAdr>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>XX99999999999999999</IBAN>
</Id>
</CdtrAcct>
<RmtInf>
<Strd>
<CdtrRefInf>
<CdtrRef>X99999999-9999999999</CdtrRef>
</CdtrRefInf>
<AddtlRmtInf>ADDITIONAL INFO</AddtlRmtInf>
</Strd>
</RmtInf>
</CdtTrfTxInf>
</pacs.008.001.01>
</Document>
~' the_column
from dual
select v.instrid,v.endtoendid,v.txid,v.cd,
v.ccy, /* returned as NULL - the only attribute value */
v.intrbksttlmamt,v.chrgbr,v.bic1,v.nm1,v.adrline11,v.adrline12,v.ctry1,v.iban1,
v.bic2,v.bic3,v.nm2,v.adrline21,v.adrline22,v.ctry2,v.iban2,v.cdtrref,v.addtlrmtinf
from (select xmltype(the_column) the_column_xml
from the_data
) w,
xmltable(xmlnamespaces(default 'urn:iso:std:iso:20022:tech:xsd:pacs.008.001.01'),
'for $r in /Document/pacs.008.001.01/CdtTrfTxInf
return <rw>
<InstrId>{$r/PmtId/InstrId}</InstrId>
<EndToEndId>{$r/PmtId/EndToEndId}</EndToEndId>
<TxId>{$r/PmtId/TxId}</TxId>
<Cd>{$r/PmtTpInf/SvcLvl/Cd}</Cd>
<Ccy>{$r/IntrBkSttlmAmt/@Ccy}</Ccy>
<IntrBkSttlmAmt>{ora:replace($r/IntrBkSttlmAmt,"[.]",",")}</IntrBkSttlmAmt>
<ChrgBr>{$r/ChrgBr}</ChrgBr>
<BIC1>{$r/InstgAgt/FinInstnId}</BIC1>
<Nm1>{$r/Dbtr/Nm}</Nm1>
<AdrLine11>{$r/Dbtr/PstlAdr/AdrLine[1]}</AdrLine11>
<AdrLine12>{$r/Dbtr/PstlAdr/AdrLine[2]}</AdrLine12>
<Ctry1>{$r/Dbtr/PstlAdr/Ctry}</Ctry1>
<IBAN1>{$r/DbtrAcct/Id}</IBAN1>
<BIC2>{$r/DbtrAgt/FinInstnId}</BIC2>
<BIC3>{$r/CdtrAgt/FinInstnId}</BIC3>
<Nm2>{$r/Cdtr/Nm}</Nm2>
<AdrLine21>{$r/Cdtr/PstlAdr/AdrLine[1]}</AdrLine21>
<AdrLine22>{$r/Cdtr/PstlAdr/AdrLine[2]}</AdrLine22>
<Ctry2>{$r/Cdtr/PstlAdr/Ctry}</Ctry2>
<IBAN2>{$r/CdtrAcct/Id}</IBAN2>
<CdtrRef>{$r/RmtInf/Strd/CdtrRefInf/CdtrRef}</CdtrRef>
<AddtlRmtInf>{$r/RmtInf/Strd/AddtlRmtInf}</AddtlRmtInf>
</rw>'
passing w.the_column_xml
columns instrid varchar2(300) path '/rw/InstrId',
endtoendid varchar2(150) path '/rw/EndToEndId',
txid varchar2(200) path '/rw/TxId',
cd varchar2(50) path '/rw/Cd',
ccy varchar2(50) path '/rw/Ccy',
intrbksttlmamt varchar2(50) path '/rw/IntrBkSttlmAmt',
chrgbr varchar2(100) path '/rw/ChrgBr',
bic1 varchar2(100) path '/rw/BIC1',
nm1 varchar2(1000) path '/rw/Nm1',
adrline11 varchar2(1000) path '/rw/AdrLine11',
adrline12 varchar2(1000) path '/rw/AdrLine12',
ctry1 varchar2(50) path '/rw/Ctry1',
iban1 varchar2(200) path '/rw/IBAN1',
bic2 varchar2(100) path '/rw/BIC2',
bic3 varchar2(100) path '/rw/BIC3',
nm2 varchar2(1000) path '/rw/Nm2',
adrline21 varchar2(1000) path '/rw/AdrLine21',
adrline22 varchar2(1000) path '/rw/AdrLine22',
ctry2 varchar2(50) path '/rw/Ctry2',
iban2 varchar2(200) path '/rw/IBAN2',
cdtrref varchar2(1000) path '/rw/CdtrRef',
addtlrmtinf varchar2(1000) path '/rw/AddtlRmtInf'
) vRegards
EtbinHi,
It's a long time, no see since my last dealing with xml and no luck to have an attribute value returned into the relational table.When you use this :
<Ccy>{$r/IntrBkSttlmAmt/@Ccy}</Ccy>That doesn't set the value of the Ccy element with the attribute value, but actually add the attribute Ccy to the element Ccy, which results in
<Ccy Ccy="???"></Ccy>Knowing that, you have three options :
1) Leaving the XQuery as it is and using this instead in the COLUMNS clause :
ccy varchar2(50) path '/rw/Ccy/@Ccy',2) Modifying the XQuery to get the atomic value out of the attribute (using the fn:data function) :
<Ccy>{fn:data($r/IntrBkSttlmAmt/@Ccy)}</Ccy>3) Simplifying the whole thing, something like :
select v.instrid, v.endtoendid, v.txid, v.cd, v.ccy,
replace(v.intrbksttlmamt,'.',',') as intrbksttlmamt, v.chrgbr, v.bic1, v.nm1, v.adrline11, v.adrline12, v.ctry1, v.iban1,
v.bic2, v.bic3, v.nm2, v.adrline21, v.adrline22, v.ctry2, v.iban2, v.cdtrref, v.addtlrmtinf
from the_data w,
xmltable(xmlnamespaces(default 'urn:iso:std:iso:20022:tech:xsd:pacs.008.001.01'),
'/Document/pacs.008.001.01/CdtTrfTxInf'
passing xmltype(w.the_column)
columns instrid varchar2(300) path 'PmtId/InstrId',
endtoendid varchar2(150) path 'PmtId/EndToEndId',
txid varchar2(200) path 'PmtId/TxId',
cd varchar2(50) path 'PmtTpInf/SvcLvl/Cd',
ccy varchar2(50) path 'IntrBkSttlmAmt/@Ccy',
intrbksttlmamt varchar2(50) path 'IntrBkSttlmAmt',
chrgbr varchar2(100) path 'ChrgBr',
bic1 varchar2(100) path 'InstgAgt/FinInstnId',
nm1 varchar2(1000) path 'Dbtr/Nm',
adrline11 varchar2(1000) path 'Dbtr/PstlAdr/AdrLine[1]',
adrline12 varchar2(1000) path 'Dbtr/PstlAdr/AdrLine[2]',
ctry1 varchar2(50) path 'Dbtr/PstlAdr/Ctry',
iban1 varchar2(200) path 'DbtrAcct/Id',
bic2 varchar2(100) path 'DbtrAgt/FinInstnId',
bic3 varchar2(100) path 'CdtrAgt/FinInstnId',
nm2 varchar2(1000) path 'Cdtr/Nm',
adrline21 varchar2(1000) path 'Cdtr/PstlAdr/AdrLine[1]',
adrline22 varchar2(1000) path 'Cdtr/PstlAdr/AdrLine[2]',
ctry2 varchar2(50) path 'Cdtr/PstlAdr/Ctry',
iban2 varchar2(200) path 'CdtrAcct/Id',
cdtrref varchar2(1000) path 'RmtInf/Strd/CdtrRefInf/CdtrRef',
addtlrmtinf varchar2(1000) path 'RmtInf/Strd/AddtlRmtInf'
) vThat last option could possibly get you some performance improvement as well.
Edited by: odie_63 on 14 sept. 2011 20:57 -
Generate xml output file from relational table
Hi All,
I'd like to generate an XML file from a relational table but would like to persist the XSD in Oracle does anyone have a working example?
Edited by: houchen on Jun 2, 2009 5:34 AMFrom the FAQ on the {forum:id=34} forum, {thread:id=416001}.
If you are wanting to register the schemas in Oracle, you will find info on that as well in the FAQ. -
Approach to parse large number of XML files into the relational table.
We are exploring the option of XML DB for processing a large number of files coming same day.
The objective is to parse the XML file and store in multiple relational tables. Once in relational table we do not care about the XML file.
The file can not be stored on the file server and need to be stored in a table before parsing due to security issues. A third party system will send the file and will store it in the XML DB.
File size can be between 1MB to 50MB and high performance is very much expected other wise the solution will be tossed.
Although we do not have XSD, the XML file is well structured. We are on 11g Release 2.
Based on the reading this is what my approach.
1. CREATE TABLE XML_DATA
(xml_col XMLTYPE)
XMLTYPE xml_col STORE AS SECUREFILE BINARY XML;
2. Third party will store the data in XML_DATA table.
3. Create XMLINDEX on the unique XML element
4. Create views on XMLTYPE
CREATE OR REPLACE FORCE VIEW V_XML_DATA(
Stype,
Mtype,
MNAME,
OIDT
AS
SELECT x."Stype",
x."Mtype",
x."Mname",
x."OIDT"
FROM data_table t,
XMLTABLE (
'/SectionMain'
PASSING t.data
COLUMNS Stype VARCHAR2 (30) PATH 'Stype',
Mtype VARCHAR2 (3) PATH 'Mtype',
MNAME VARCHAR2 (30) PATH 'MNAME',
OIDT VARCHAR2 (30) PATH 'OID') x;
5. Bulk load the parse data in the staging table based on the index column.
Please comment on the above approach any suggestion that can improve the performance.
Thanks
AnuragTThanks for your response. It givies more confidence.
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
TNS for Linux: Version 11.2.0.3.0 - Production
Example XML
<SectionMain>
<SectionState>Closed</SectionState>
<FunctionalState>CP FINISHED</FunctionalState>
<CreatedTime>2012-08</CreatedTime>
<Number>106</Number>
<SectionType>Reel</SectionType>
<MachineType>CP</MachineType>
<MachineName>CP_225</MachineName>
<OID>99dd48cf-fd1b-46cf-9983-0026c04963d2</OID>
</SectionMain>
<SectionEvent>
<SectionOID>99dd48cf-2</SectionOID>
<EventName>CP.CP_225.Shredder</EventName>
<OID>b3dd48cf-532d-4126-92d2</OID>
</SectionEvent>
<SectionAddData>
<SectionOID>99dd48cf2</SectionOID>
<AttributeName>ReelVersion</AttributeName>
<AttributeValue>4</AttributeValue>
<OID>b3dd48cf</OID>
</SectionAddData>
- <SectionAddData>
<SectionOID>99dd48cf-fd1b-46cf-9983</SectionOID>
<AttributeName>ReelNr</AttributeName>
<AttributeValue>38</AttributeValue>
<OID>b3dd48cf</OID>
<BNCounter>
<SectionID>99dd48cf-fd1b-46cf-9983-0026c04963d2</SectionID>
<Run>CPFirstRun</Run>
<SortingClass>84</SortingClass>
<OutputStacker>D2</OutputStacker>
<BNCounter>54605</BNCounter>
</BNCounter>
I was not aware of Virtual column but looks like we can use it and avoid creating views by just inserting directly into
the staging table using virtual column.
Suppose OID id is the unique identifier of each XML FILE and I created virtual column
CREATE TABLE po_Virtual OF XMLTYPE
XMLTYPE STORE AS BINARY XML
VIRTUAL COLUMNS
(OID_1 AS (XMLCAST(XMLQUERY('/SectionMain/OID'
PASSING OBJECT_VALUE RETURNING CONTENT)
AS VARCHAR2(30))));
1. My question is how then I will write this query by NOT USING COLMUN XML_COL
SELECT x."SECTIONTYPE",
x."MACHINETYPE",
x."MACHINENAME",
x."OIDT"
FROM po_Virtual t,
XMLTABLE (
'/SectionMain'
PASSING t.xml_col <--WHAT WILL PASSING HERE SINCE NO XML_COL
COLUMNS SectionType VARCHAR2 (30) PATH 'SectionType',
MachineType VARCHAR2 (3) PATH 'MachineType',
MachineName VARCHAR2 (30) PATH 'MachineName',
OIDT VARCHAR2 (30) PATH 'OID') x;
2. Insetead of creating the view then Can I do
insert into STAGING_table_yyy ( col1 ,col2,col3,col4,
SELECT x."SECTIONTYPE",
x."MACHINETYPE",
x."MACHINENAME",
x."OIDT"
FROM xml_data t,
XMLTABLE (
'/SectionMain'
PASSING t.xml_col <--WHAT WILL PASSING HERE SINCE NO XML_COL
COLUMNS SectionType VARCHAR2 (30) PATH 'SectionType',
MachineType VARCHAR2 (3) PATH 'MachineType',
MachineName VARCHAR2 (30) PATH 'MachineName',
OIDT VARCHAR2 (30) PATH 'OID') x
where oid_1 = '99dd48cf-fd1b-46cf-9983';<--VIRTUAL COLUMN
insert into STAGING_table_yyy ( col1 ,col2,col3
SELECT x."SectionOID",
x."EventName",
x."OIDT"
FROM xml_data t,
XMLTABLE (
'/SectionMain'
PASSING t.xml_col <--WHAT WILL PASSING HERE SINCE NO XML_COL
COLUMNS SectionOID PATH 'SectionOID',
EventName VARCHAR2 (30) PATH 'EventName',
OID VARCHAR2 (30) PATH 'OID',
) x
where oid_1 = '99dd48cf-fd1b-46cf-9983';<--VIRTUAL COLUMN
Same insert for other tables usind the OID_1 virtual coulmn
3. Finaly Once done how can I delete the XML document from XML.
If I am using virtual column then I beleive it will be easy
DELETE table po_Virtual where oid_1 = '99dd48cf-fd1b-46cf-9983';
But in case we can not use the Virtual column how we can delete the data
Thanks in advance
AnuragT -
Converting Relational Tables to Object Views
We have extra information stored for each
field in a table. We call these Vertical
Tables:
rowid primary key - ties to normal tab
column_name "" - ties to column in ""
text_value the value if text
reliability rating for level of accuracy...
date of entry
Yes there are normal tables that the applications also access if they just need the value of the columns.
So I want to take this to object views. This way, while oracle is learning how to alter objects, we can still maintain our data and old application while converting to the use of objects.
I thought the best solution would be Type(s) based on the orignal data type. A generic type, text65_t could be created to hold every column that is less than 65 characters long:
CREATE TYPE text65_t AS OBJECT
WITH OBJECT IDENTIFIER(row_id) AS
row_id VARCHAR2(30),
value VARCHAR2(65),
reliability NUMBER(1,0),
doe DATE
A view can easily be created of this. The
mapping is one to one.
My problem is the next level. How can I build another view on top of text65_t, integer_t, date_t... that ties all of the
vertical rows back into a normal relational table or object.
Thanks,
bill
nullHi migration group,
I realize this is kind of off topic for
this discussion group. Where can I ask
questions like this?
thanks
bill -
10g: Must all related tables be in the same project?
Since we will eventaully have over 500 tables to map, we would like to be able to maintain these tables/classes in different projects. How do we map foreign key references between tables/classes that we would like to maintain in different projects?
I don't know if theis is why I'm getting this error, but I initially created two projects with independent tables. Then I wanted to join some tables in one project to some tables in another project. (This is all using Offline Database Objects.) I dropped some tables managed in project A into the diagram for project B and created the foreign key relations (from B to A.) Now whenever I try to open the TopLink Mappings node for project B in the Navigator, I get the following error. I get this error even if I drop ALL the tables from project A into project B's diagram (meaning there is nothing left in the schema that could be the missing 'parent'.)
Local Exception Stack:
Exception [TOPLINK-98] (Oracle9iAS TopLink - Release 2 (9.0.4.0) (Build 030612)): oracle.toplink.exceptions.DescriptorException
Exception Description: The underlying descriptor callback method [postBuild], with parameter (DescriptorEvent), triggered an exception.
Internal Exception: java.lang.reflect.InvocationTargetException
Target Invocation Exception: java.lang.IllegalStateException: This object is missing a parent: MWTable[C14] (AVEGA.DATAMART)
Descriptor: XMLDescriptor(oracle.toplink.workbench.model.MWProject --> [DatabaseTable(project)])
at oracle.toplink.exceptions.DescriptorException.<init>(DescriptorException.java:207)
at oracle.toplink.exceptions.DescriptorException.<init>(DescriptorException.java:212)
at oracle.toplink.exceptions.DescriptorException.targetInvocationWhileEventExecution(DescriptorException.java:1364)
at oracle.toplink.publicinterface.DescriptorEventManager.executeEvent(DescriptorEventManager.java:133)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:179)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:331)
at oracle.toplink.queryframework.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:227)
at oracle.toplink.queryframework.ReadObjectQuery.execute(ReadObjectQuery.java:344)
at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:498)
at oracle.toplink.queryframework.ReadQuery.execute(ReadQuery.java:111)
at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:1968)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1096)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1048)
at oracle.toplink.publicinterface.Session.readObject(Session.java:2502)
at oracle.toplink.workbench.ui.WorkbenchSession.getMWProjectNamed(WorkbenchSession.java:270)
at oracle.toplink.addin.persistence.MWJDeveloperPersistence.open(MWJDeveloperPersistence.java:176)
at oracle.toplink.tsceditor.persistence.PersistenceManager.open(PersistenceManager.java:942)
at oracle.toplink.addin.manager.MWJDeveloperMediator.openMWProject(MWJDeveloperMediator.java:164)
at oracle.toplink.addin.manager.MWJDeveloperMediator.locateAndOpenProjectImp(MWJDeveloperMediator.java:626)
at oracle.toplink.addin.manager.MWJDeveloperMediator.getEditableObjectFor(MWJDeveloperMediator.java:430)
at oracle.toplink.addin.ui.view.explorer.MWExplorer.updateExplorer(MWExplorer.java:586)
at oracle.toplink.addin.ui.view.explorer.MWExplorer.setContext(MWExplorer.java:458)
at oracle.ideimpl.explorer.ExplorerManagerImpl.getExplorerForHost(ExplorerManagerImpl.java:1048)
at oracle.ideimpl.explorer.ExplorerWindowImpl.viewSelectionChanged(ExplorerWindowImpl.java:544)
at oracle.ide.addin.AbstractPinnable.viewSelectionChanged(AbstractPinnable.java:232)
at oracle.ideimpl.explorer.ExplorerWindowImpl.viewSelectionChanged(ExplorerWindowImpl.java:376)
... etc.If you wish to split your project up into two projects and have some relationships between some of those objects in the projects, you could map all of the objects for each project, but do not map the relationships. For those classes with relationships to other classes in other project you can define an amendment method. An amendment method is a callback into Java code that will be called when the descriptor is loaded. In this method you can then create the mapping to the class in the other project through the descriptor and mapping code API. (see oracle.toplink.mappings, oracle.toplink.publicinterface.Descriptor)
You can also make use of descriptor deactivation to define relationships between projects. For this you would import the related classes into the project and deactivate them. This will allow you to define relationships to them, but will not export their mapping information when deploying.
In general it is probably easier to keep everything in one project and use your content/code management system and merge tools to manage the project. -
Syntax of DDL options and related (table) column names
Hi,
where can I find something like a mapping between DDL options and related table column names?
For example I do have the table options PCTFREE, FREELISTS and NOCOMPRESS. The related table columns out of user_tables are PCT_FREE, FREELIST and COMPRESS.
PCT(_)FREE wins an Underscore, FREELIST(S) wins an "S" and it is "NOCOMPRESS" if COMPRESS has a value "Y(es)".
Hope somebody can help.So far I didn't find any information that is not in
the DDL script gernerated from
DBMS_METADATA.get_DDL.Alright, I give you an example:
I create a table with the following DDL:
"CREATE TABLE IntBuch (
int_bunr integer NOT NULL,
int_sdat double precision NOT NULL,
int_hblz char(8) NOT NULL,
int_hkto char(7) NOT NULL,
int_hdat double precision NOT NULL,
KtoNr char(7) NOT NULL,
BLZ char(8) NOT NULL,
CONSTRAINT PK_IntBuch PRIMARY KEY (int_bunr)
USING INDEX
PCTFREE 10
STORAGE (
INITIAL 1000
NEXT 500
PCTINCREASE 0
MINEXTENTS 1
MAXEXTENTS 4096
PCTFREE 20
LOGGING
CREATE UNIQUE INDEX intid
ON IntBuch (int_bunr DESC)
CREATE INDEX hkto
ON IntBuch (int_hblz,int_hkto)
COMMENT ON TABLE IntBuch
IS 'Kommentar zu DB-Tabelle InBuch'
COMMENT ON COLUMN IntBuch.int_sdat IS 'Kommentar zu DB-Spalte int_sdat'
ALTER TABLE IntBuch
ADD CONSTRAINT Gutschrift FOREIGN KEY (int_hkto,int_hblz) REFERENCES Konto
ON DELETE CASCADE
ADD FOREIGN KEY (KtoNr,BLZ) REFERENCES Konto
ADD FOREIGN KEY (int_bunr) REFERENCES Buchung
ON DELETE CASCADE
After that I read the DDL with DBMS_METADATA.get_DDL and I get
" CREATE TABLE "UOENDE"."INTBUCH"
( "INT_BUNR" NUMBER(*,0) NOT NULL ENABLE,
"INT_SDAT" FLOAT(126) NOT NULL ENABLE,
"INT_HBLZ" CHAR(8) NOT NULL ENABLE,
"INT_HKTO" CHAR(7) NOT NULL ENABLE,
"INT_HDAT" FLOAT(126) NOT NULL ENABLE,
"KTONR" CHAR(7) NOT NULL ENABLE,
"BLZ" CHAR(8) NOT NULL ENABLE,
CONSTRAINT "PK_INTBUCH" PRIMARY KEY ("INT_BUNR")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 16384 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" ENABLE,
CONSTRAINT "GUTSCHRIFT" FOREIGN KEY ("INT_HKTO", "INT_HBLZ")
REFERENCES "UOENDE"."KONTO" ("KTONR", "BLZ") ON DELETE CASCADE ENABLE,
FOREIGN KEY ("KTONR", "BLZ")
REFERENCES "UOENDE"."KONTO" ("KTONR", "BLZ") ENABLE,
FOREIGN KEY ("INT_BUNR")
REFERENCES "UOENDE"."BUCHUNG" ("BU_NR") ON DELETE CASCADE ENABLE
) PCTFREE 20 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS"
If there are no more DDLOptions possible than that, it is fine for me. If not, but all kinds of options are to find in only one or two tables of the database ( user_tables for table options, dba_constraints and dba_segments for column options, primary and foreign keys, user_indexes and user_segments for indexes ...), that is fine for me, too. (As long as I get to know which tables are "sufficient" for that.) If it is different than both of that, that's bad.
However if you want to use defaults instead of
absolut values, it is better to remove certain parts,
like the storage clause, from the generated output.I understand this, but I am more interested to have all and not leaving out some of them in order to have the defaults in the database after running the DDL.
A totally different approach could be to
a) create a database link from one DB to another.
b) create table <new_table> as select * from
<old_table@dbLink> where 1=2;I keep that in mind, thanks for that hint. -
Create XML (using DTD) from multiple relation tables
Hello and thank you in advanced.
I'm trying to create an XML document, based on a specific DTD, by selecting information from multiple tables in the database.
Is there a tool (in XDK maybe?) that will allow me to map my relational tables to a specific DTD?
I could build the XML manually, but I was hoping that Oracle has already solved this problem with an automated tool.
Thanks again,
Sean CloutierIs that the same thing as me writing an XSQL document which contains all of my queries (or views).
In other words, do I have to map everything by hand or is there a tool to do that for me?
thanks again,
Sean
null -
i have a many-to-many relation with a
relation table.
the relation table has a "id" - column as primary key
and two foreign keys columns
REL_TABLE
ID | TABLE_A_ID | TABLE_B_ID
where at the toplink workbench can i define
the sequencing for the "id" - column ?
thanksA relation table that contains any additional information, such as its own PK or qualifying fields, is not a typically mapped using a M:M. TopLink's M:M mapping assumes the relation table contains only the two FKs, which together form the PK of the table.
The simplest solution is to map another class to the relation table that has its own unique identity for each relationship and then configure sequencing on this mapped class.
Doug -
How to insert into xml table from relational table
I wrote a sqlstaement that selects value from the relational tables. Now I want to replace root node "<event_start01>" with following value to the above selected xml string. My select returns root node and all nodes and elements of the root node.
I tried holding above sellected value into varchar2 variable but I get ora-00600 error. If I hold above selected values into xmltype variable then I am not able to replace root node with the following value.
I want to rplace rootnode with the following string.
INSERT INTO FRMD_EVENT_START01(xml_event_start) VALUES
(XMLTYPE('<event_start01
xmlns="event_start01.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="event_start01.xsd
event_start01.xsd">Normally, you'd do this by joining B, C, and D together. In the simplest case, something like
INSERT INTO A( col1, ... col10 )
SELECT B.col1, ..., B.col4,
C.col5,
D.col6, ..., D.col10
FROM B,
C,
D,
WHERE B.someKeyColumn = C.someKeyColumn
AND C.anotherKeyColumn = D.anotherKeyColumnYou'd have to know how the data in B, C, and D relate to fill in the WHERE clause. This basically tells Oracle how to match the data in a particular row in B with the data in a particular row in C with the data in a particular row in D.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC
Maybe you are looking for
-
Ipod stuck in disk mode, please help
hey, my ipod has gone crazy on me, yet again, and is now stuck in disk mode. i can connect it to my laptop and it appears to updats songs but when i disconnect it the screen says "OK to disconnect", this is after it has been disconnected. i have look
-
AC_FL_Runcontent null or not defined error plus I have a js redirector trojan
Can't find error
-
This is a philosophy approach to solve a problem. I am developing several applets to help out our manufacturing and engineering staffs. A lot of it is just extracting data from csv files and doing some plotting while other applets automate some produ
-
1) What kind of 'day-to-day' maintenance/administration/monitoring processes for your oracle EBS system do you put through change control? Can you provide some examples? 2) Also if you are like a systems administrator for Oracle EBS, what are your da
-
Does perfdump work for AS7 on Win2k
I want to enable perfdump to monitor performance for SunOne AS7 running on win2k but cant get it to work. Ideas?