Referential constraints on XMLType tables
Hi all,
I'm trying to create an XMLType table with a foreign key that references another XMLType table. Shouldn't be a big deal, i thought.
CREATE TABLE datasets (
ID NUMBER,
XML XMLTYPE )
XMLTYPE COLUMN XML XMLSCHEMA "dataset_schema.xsd" ELEMENT "root";
CREATE TABLE categories OF XMLTYPE XMLSCHEMA "categories.xsd" ELEMENT "categories";
ALTER TABLE datasets
2 ADD CONSTRAINT dataset_isvalid
3 FOREIGN KEY(XML.XMLDATA."dataset"."metaInformation"."referenceFunction"."category")
4 REFERENCES categories(XMLDATA."category"."name");
FOREIGN KEY(XML.XMLDATA."dataset"."metaInformation"."referenceFunction"."category")
ERROR at line 3:
ORA-22809: nonexistent attribute
I've then been reading through the postings regarding foreign key and unique constraints and i've managed to understand the concept of nested tables. To my dismay, trying to establish referential constraints my nested tables would throw an ORA-30730 stating this cannot be done.
I've simplified my schemas a little so it won't get to complicated: one table will store datasets and the other will hold category names.
The schema for the categories is
<?xml version="1.0" encoding="UTF-8"?>
<!-- schema for categories -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="categories">
<xs:complexType>
<xs:sequence>
<xs:element name="category" type="categoryType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="categoryType">
<xs:sequence>
<xs:element name="subCategory" type="subCategoryType" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="localName" type="xs:string" use="required"/>
<xs:attribute name="type" type="xs:byte" use="required"/>
</xs:complexType>
<xs:complexType name="subCategoryType">
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="localName" type="xs:string" use="required"/>
</xs:complexType>
</xs:schema>
and the schema for the dataset table is
<?xml version="1.0" encoding="UTF-8"?>
<!- dataset schema-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:complexType name="datasetType">
<xs:sequence>
<xs:element name="metaInformation" type="metaInformationType"/>
<xs:element ref="otherInformation"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="metaInformationType">
<xs:sequence>
<xs:element name="referenceFunction" type="referenceFunctionType"/>
</xs:sequence>
</xs:complexType>
<xs:element name="otherInformation" type="xs:string"/>
<xs:complexType name="referenceFunctionType">
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="category" type="xs:string" use="required"/>
<xs:attribute name="subCategory" type="xs:string" use="required"/>
</xs:complexType>
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="dataset" type="datasetType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Now I want to define the referenceFunction/@category attribute of the dataset to be a foreign key to the categories table. Is it possible at all to do that with constraints? After failing with the nested table approach I really do not have any clue I would greatly appreciate any hints.
Thanks,
oli
Nested tables do not currently support referential integrity.
Foreign Keys on elements with maxOccurs > 0
Similar Messages
-
Adding a Unique and Referential Constraint to XMLType of Purchase Table
SQL> desc XDBPO_TYPE
XDBPO_TYPE is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
messageType VARCHAR2(4000)
MessageHeader XDBPO_MESSAGEHEADER_TYPE
Order XDBPO_ORDER_CLLT
SQL> desc XDBPO_MESSAGEHEADER_TYPE
XDBPO_MESSAGEHEADER_TYPE is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
version VARCHAR2(50)
payloadId VARCHAR2(4000)
transmissionAgent VARCHAR2(4000)
timeStamp VARCHAR2(20)
senderName VARCHAR2(150)
senderComponent VARCHAR2(150)
documentReferenceId VARCHAR2(50)
documentReferenceIdType VARCHAR2(50)
dataCleansingDocumentId VARCHAR2(50)
singleTransaction VARCHAR2(4000)
Configuration XDBPO_CONFIGURATION_TYPE
HeaderIndexedAttribute XDBPO_HIATTRIBUTE_CLLT
I following the example in the demo in
Adding a Unique and Referential Constraint to Table Purchaseorder
which the constraint is added to the reference field.
but for my case, i need to add my constraint
to MessageHeader/@payloadId
how do i go about in adding the constraint?
tried to use this syntax logic but not successful:
alter table purchaseorder
add constraint REFERENCE_IS_UNIQUE
unique (xmldata."Reference")
Anyone have any idea? Mark?
Thanks.nevermind i solved the problem already
i will just post the solution incase someone else wants to add constraint to the sub xmltype object
alter table purchaseorder
add constraint REFERENCE_IS_UNIQUE
unique (xmldata."MessageHeader"."payloadId"); -
Question about how to create FORIGEN KEY constraints against XMLTYPE table
Hi,
1.I have a table called SNPLEX_DESIGN which is created as XMLTYPE, the XMLTYPE is refered to a registered XMLschema. The XMLschema has a data element called BATCH_ID, and I create a primary key for the SNPLEX_DESIGN table on the BATCH_ID. The SQL staement as
ALTER TABLE SNPLEX.SNPLEX_DESIGN ADD (CONSTRAINT "BATCH_ID_PK" PRIMARY KEY(xmldata."BATCH_ID"))
2. I have another table call SNPLEX_PROCESS which is a regual relational table with a column TOKENID. I would like to create a forign key on TOKENID which needs to refer to the SNPLEX_DESIGN table BATCH_ID_PK primary key.
But I got error when I try to alter the SNPLEX_PROCESS table.
SQL> ALTER TABLE "SNPLEX"."SNPLEX_PROCESS" ADD (CONSTRAINT "BATCH_ID_FK" FOREIGN KEY("TOKENID") RE
FERENCES "SNPLEX"."SNPLEX_DESIGN"(xmldata."BATCH_ID"));
ERROR at line 1:
ORA-02298: cannot validate (SNPLEX.BATCH_ID_FK) - parent keys not found
3. Can someone helps me on this.. I have no problem to create a foreign key in SNPLEX_DESIGN to refere primary key in relational table. But Why I can not do the other way around.
Any assistances will be appreciated..
JinsenHi Jinsen
As mentioned in the error message not all rows in PROCESS have a corresponding value in DESIGN.
To find out which are missing do some selects to compare your data or use the exception clause in the ALTER TABLE statement.
e.g.: ALTER TABLE "SNPLEX"."SNPLEX_PROCESS" ADD (CONSTRAINT "BATCH_ID_FK" FOREIGN KEY("TOKENID") RE
FERENCES "SNPLEX"."SNPLEX_DESIGN"(xmldata."BATCH_ID")) EXCEPTIONS INTO <exception table>
Notice that you have to create the <exception table> with the script $ORACLE_HOME/rdbms/admin/utlexcpt.sql.
Chris -
Constraints on a XMLTYPE table
Hi,
Has anyone been able to construct constraints on a XMLTYPE table as shown on page 5-52 of the XDB Developers
guide.
Whatever I try I get errors:
create table poc_wip2 of xmltype
element "http://www.derwent.co.uk/wpi.xsd#WPI"
(unique(XMLDATA.WPI_TYPE.BibPt2645_T.co))
(unique(XMLDATA.WPI_TYPE.BibPt2645_T.co))
ERROR at line 3:
ORA-00922: missing or invalid option
create table poc_wip2 p of xmltype
element "http://www.derwent.co.uk/wpi.xsd#WPI"
(unique(extract(value(p),/WPI/BibPt@co')))
create table poc_wip2 p of xmltype
ERROR at line 1:
ORA-00922: missing or invalid option
What I would like to be able to do is to define a primary key constraint based on three attribute values. Is this possible
using XMLTYPE?
Thanks
PetePeter
Remember that the attribute names generated from the Schema are case sensitive bu SQL is not. You will have to use something like XMLDATA.WPI_TYPE."BibPt2645_T"."co" in the constraint definition
It may be easier to create the table via registerSchema and then alter the constraint onto the table..
EG.
alter table purchaseorder
add constraint REFERENCE_IS_UNIQUE
unique (xmldata."Reference")
alter table purchaseorder
add constraint USER_IS_VALID
foreign key (xmldata."User") references SCOTT.emp(ename)
create trigger VALIDATE_PURCHASEORDER
before insert on purchaseorder
for each row
declare
XMLDATA xmltype;
begin
XMLDATA := :new.sys_nc_rowinfo$;
xmltype.schemavalidate(XMLDATA);
end;
--quit
The reason for this is that if you want to keep a table created from a schema in_sync with the resource view you need to call
dbms_xdbz.enableHierarchy(SCHEMA,TABLE) after creating the table.. -
Tables ordered by referential constraint (integrity) order
Hi,
I have some 30 tables with SOME (not all) tables having referential integrity.
For example, column B in Table No.2 may refer column A of Table No.1 and so on.
Now I want to read some records from every table and re-insert those records into the same table (after changing some column values).
For this, I am planning to write a procedure which will get these 30 table names as input and do the above for each and every table (read and insert into the same table). The thing I want these 30 tables to be ordered according to the referential integrity. That is the parent tables to be present FIRST followed by child table. So that, when I follow this order when INSERTING records I won't get any referential integrity constraint errors.
In the example above, Table No.1 should come FIRST followed by Table 2 and so on.
Could anyone please throw some light on how to order the given tables in the order their referential integrity.
Thanks.Data dictionary view DBA/ALL/USER_CONSTRAINTS will show you constraints on your tables. Start with your tables without any FK constraints - these will be parent table(s). Then look for your tables dependent on your parent tables. These will be first child table(s). Repeat the process till you cover all your tables.
SY.
Edited by: Solomon Yakobson on Feb 20, 2012 6:21 AM -
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.
:-) -
Insert data into the xml schema-based xmltype table problem!
Hello, there,
I got problem in inserting data into the xmltype table after registered XML schema and created table. details see below:
1) xml schema:
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2007 sp2 (http://www.altova.com) by Constantin Ilea (EMERGIS INC) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.emergis.com/eHealth/EHIP/data/meta/profile:v1" targetNamespace="http://www.emergis.com/eHealth/EHIP/data/meta/profile:v1" elementFormDefault="qualified">
<!-- ************** PART I: BEGIN SIMPLE OBJECT TYPE DEFINITIONS ********************************** -->
<xs:simpleType name="RoutingType">
<xs:restriction base="xs:string">
<xs:enumeration value="Synch"/>
<xs:enumeration value="Asynch"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="StatusType">
<xs:restriction base="xs:string">
<xs:enumeration value="ACTIVE"/>
<xs:enumeration value="VOID"/>
<xs:enumeration value="PENDING"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="SenderApplicationType">
<xs:restriction base="xs:string">
<xs:enumeration value="PR"/>
<xs:enumeration value="CR"/>
<xs:enumeration value="POS"/>
<xs:enumeration value="CPP"/>
<xs:enumeration value="Other"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ServiceTypeType">
<xs:restriction base="xs:string">
<xs:enumeration value="IS"/>
<xs:enumeration value="WS"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="RouteDirect">
<xs:restriction base="xs:string">
<xs:enumeration value="Request"/>
<xs:enumeration value="Reply"/>
<xs:enumeration value="None"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="Indicator">
<xs:annotation>
<xs:documentation>can we also change the value to "ON" and "OFF" instead? in this way this cn be shared by all type of switch indicator</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="YES"/>
<xs:enumeration value="NO"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="RuleType">
<xs:restriction base="xs:string">
<xs:enumeration value="ControlAct"/>
<xs:enumeration value="WSPolicy"/>
<xs:enumeration value="AccessControl"/>
<xs:enumeration value="Certification"/>
<xs:enumeration value="MessageConformance"/>
<xs:enumeration value="Variant"/>
<xs:enumeration value="Routing"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="HL7Result">
<xs:restriction base="xs:string">
<xs:enumeration value="ACCEPT"/>
<xs:enumeration value="REFUSE"/>
<xs:enumeration value="REJECT"/>
<xs:enumeration value="ACK"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="IIPType">
<xs:restriction base="xs:string">
<xs:enumeration value="PUT"/>
<xs:enumeration value="GET/LIST"/>
<xs:enumeration value="NOTIF"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ProfileTypeType">
<xs:restriction base="xs:string">
<xs:enumeration value="IIPProfile"/>
<xs:enumeration value="BizOperationProfile"/>
<xs:enumeration value="OrchestrationProfile"/>
<xs:enumeration value="DomainObjectProfile"/>
<xs:enumeration value="ServiceProfile"/>
<xs:enumeration value="ExceptionProfile"/>
<xs:enumeration value="CustomizedProfile"/>
<xs:enumeration value="SystemProfile"/>
<xs:enumeration value="HL7XMLSchemaProfile"/>
<xs:enumeration value="EnricherParametersProfile"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ParameterType">
<xs:restriction base="xs:string">
<xs:enumeration value="String"/>
<xs:enumeration value="Object"/>
<xs:enumeration value="Number"/>
<xs:enumeration value="Document"/>
</xs:restriction>
</xs:simpleType>
<!-- ************** PART I: END SIMPLE OBJECT TYPE DEFINITIONS ********************************** -->
<!-- ************** PART II: BEGIN COMPLEX OBJECT TYPE DEFINITIONS ********************************** -->
<!-- *********************** begin new added objects, by rshan *************************************** -->
<xs:complexType name="ProfileType">
<xs:annotation>
<xs:documentation>
1.Profile IS USED TO BE AN WRAPPER ELEMENT FOR ALL KIND OF PROFILES NO MATTER WHAT KIND OF PROFILE IT IS
2.ProfileID used to uniquely identify the current profile
3.ProfileData used to hold all the necessary profile related data
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="ProfileID" type="ProfileIDType">
<xs:annotation>
<xs:documentation>this will hold all the common attributes, espically the global unique identifier to the profile, no matter what type of profile is</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="ProfileData" type="ProfileDataType">
<xs:annotation>
<xs:documentation>all the non-common profile meta data that attached to each specific profile type such as IIPProfile, OrchestrationProfile, and BizOperationProfile will be placed here</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ProfileIDType">
<xs:annotation>
<xs:documentation>global unique identifier and all the common attributes across all different profiles, the @ID and @Type together will be used as the primary key to identify the profile data</xs:documentation>
</xs:annotation>
<xs:attribute name="ID" type="xs:ID" use="required">
<xs:annotation>
<xs:documentation>ID is the global unique identifier to the profile, no matter what type of profile it is</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Name"/>
<xs:attribute name="Description"/>
<xs:attribute name="Version">
<xs:annotation>
<xs:documentation>version of the profile data</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Type" type="ProfileTypeType" use="required">
<xs:annotation>
<xs:documentation>value to identify the ProfileType type within
IIPProfile,BizOperationProfile,OrchestrationProfile,DomainObjectProfile
ServiceProfile,ExceptionProfile,SystemProfile,HL7XMLSchemaProfile,
EnricherParametersProfile,CustomizedProfile
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Status" type="StatusType" default="ACTIVE">
<xs:annotation>
<xs:documentation>used to show the related profile data status like "ACTIVE","PENDING","VOID"...</xs:documentation>
</xs:annotation>
</xs:attribute>
<!--
<xs:sequence>
<xs:element name="ProfileReference" type="ProfileIDType" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>this will be the place to hold the integrity relationship with other profiles like foreign key if existed and necessary to show up</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
-->
</xs:complexType>
<xs:complexType name="ProfileDataType">
<xs:annotation>
<xs:documentation>meta data associated tightly to each specific type of profile</xs:documentation>
</xs:annotation>
<xs:choice>
<xs:element name="EnricherParametersProfileData" type="EnricherParametersDataType">
<xs:annotation>
<xs:documentation>Enricher Parameters related profile data
1. one instance of this type may contains all the related System metadata.
2. idType part may use to identify different version/release/status
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="ExtendProfileData" type="ExtendProfileDataType">
<xs:annotation>
<xs:documentation>If needed, any profile data not defined within the current release scope can be added here </xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:complexType name="ExtendProfileDataType">
<xs:sequence>
<xs:element name="ExtendProfile" type="xs:anyType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="EnricherParametersDataType">
<xs:sequence>
<xs:element name="EnricherParameter" type="EnricherParameter" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="EnricherParameter">
<xs:sequence>
<xs:element ref="Enricher"/>
</xs:sequence>
<xs:attribute name="serviceName" type="xs:string" use="required"/>
<xs:attribute name="interactionID" type="xs:string"/>
</xs:complexType>
<xs:element name="Enricher">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="Parameters" type="Parameters"/>
<xs:element ref="Section" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="ValueType">
<xs:attribute name="field" use="required"/>
<xs:attribute name="value"/>
<xs:attribute name="action"/>
</xs:complexType>
<xs:element name="Section">
<xs:complexType>
<xs:sequence>
<xs:element name="Value" type="ValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="Section" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="path" use="required"/>
</xs:complexType>
</xs:element>
<xs:complexType name="Parameters">
<xs:sequence>
<xs:element name="Parameter" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" use="required"/>
<xs:attribute name="reference"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="RuleList">
<xs:annotation>
<xs:documentation>an array of rules</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="Rule" type="RuleProfile" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="RuleProfile">
<xs:attribute name="RName" use="required"/>
<xs:attribute name="RType" type="RuleType" use="required"/>
<xs:attribute name="Status" default="ON">
<xs:annotation>
<xs:documentation>By default is ON (or if is missing)</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Order"/>
<xs:attribute name="Direction" type="RouteDirect">
<xs:annotation>
<xs:documentation>Request / Reply</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
<!-- ************** PART II: END COMPLEX OBJECT TYPE DEFINITIONS *********************************** -->
<!-- ************** PART III: BEGIN ROOT ELEMENTS DEFINITIONS ********************************* -->
<!-- 0) Profile wrapper root element
Profile IS USED TO BE AN WRAPPER ELEMENT FOR ALL KIND OF PROFILES NO MATTER WHAT KIND OF PROFILE IT IS
-->
<xs:element name="Profile" type="ProfileType">
<xs:annotation>
<xs:documentation>Profile IS USED TO BE AN WRAPPER ELEMENT FOR ALL KIND OF PROFILES NO MATTER WHAT KIND OF PROFILE IT IS</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
2)register xml schema:
SQL> begin
2 dbms_xmlschema.registerSchema
3 (
4 schemaurl=>'http://rac3-1-vip:8080/home/'||USER||'/xsd/EHIPProfile_v00.xsd',
5 schemadoc=>xdbURIType('/home/'||USER||'/xsd/EHIPProfile_v00.xsd').getClob(),
6 local=>True,
7 gentypes=>True,
8 genbean=>False,
9 gentables=>False
10 );
11 End;
12 /
PL/SQL procedure successfully completed.
SQL>
SQL>
3) xml data:
<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSpy v2007 sp2 (http://www.altova.com)-->
<Profile xmlns="http://www.emergis.com/eHealth/EHIP/data/meta/profile:v1">
<ProfileID Type="EnricherParametersProfile" Status="ACTIVE" ID="EnricherPP.ID.0001" Name="EnricherPP.ID.0001" Description="EnricherPP.ID.0001" Version="01"/>
<ProfileData>
<EnricherParametersProfileData>
<EnricherParameter serviceName="LRS_BusinessDomainObject.lrs.businessDomainObject.domainObjectBuilder.concrete.ExceptionCreators:createExceptionV50CategoryCanonicalPart" interactionID="">
<Enricher>
<Parameters>
<Parameter name="MESSAGE_ID" reference="test"/>
</Parameters>
<Section path="HEADER">
<Section path="RESPONSE_TYPE">
<Value field="value" value="I"/>
</Section>
<Section path="HL7_STANDARD_VERSION">
<Value field="value" value="HL7V3"/>
</Section>
<Section path="DESIRED_ACKNOWLEDGMENT_TYPE">
<Value field="value" value="NE"/>
</Section>
<Section path="SENDING_NETWORK_ADDRESS">
<Value field="value" value=""/>
</Section>
<Section path="SENDING_APPLICATION_IDENTIFIER">
<Value field="root" value="2.16.840.1.113883.3.133.1.3"/>
<Value field="extension" value=""/>
</Section>
<Section path="SENDING_APPLICATION_NAME">
<Value field="value" value="NL HIAL"/>
</Section>
</Section>
</Enricher>
</EnricherParameter>
<EnricherParameter serviceName="LRS_BusinessDomainObject.lrs.businessDomainObject.domainObjectBuilder.concrete.DomainObjectCreators:createFindClientsAssociatedIdentifersRequestObject" interactionID="PRPA_IN101105CA">
<Enricher>
<Parameters>
<Parameter name="MESSAGE_ID" reference="test"/>
</Parameters>
<Section path="HEADER">
<Section path="RESPONSE_TYPE">
<Value field="value" value="I"/>
</Section>
<Section path="HL7_STANDARD_VERSION">
<Value field="value" value="HL7V3"/>
</Section>
<Section path="PROCESSING_CODE">
<Value field="value" value="T"/>
</Section>
<!--
<Section path="PROCESSING_MODE_CODE">
<Value field="value" value="T"/>
</Section>
-->
<Section path="DESIRED_ACKNOWLEDGMENT_TYPE">
<Value field="value" value="NE"/>
</Section>
<Section path="RECEIVER_NETWORK_ADDRESS">
<Value field="value" value="prsunew.moh.hnet.bc.ca"/>
</Section>
<Section path="RECEIVER_APPLICATION_IDENTIFIER">
<Value field="root" value="2.16.840.1.113883.3.40.5.1"/>
<Value field="extension" value=""/>
</Section>
<Section path="SENDING_NETWORK_ADDRESS">
<Value field="value" value=""/>
</Section>
<Section path="SENDING_APPLICATION_IDENTIFIER">
<Value field="root" value="2.16.840.1.113883.3.133.1.3"/>
<Value field="extension" value=""/>
</Section>
<Section path="SENDING_APPLICATION_NAME">
<Value field="value" value="NL HIAL"/>
</Section>
</Section>
</Enricher>
</EnricherParameter>
<EnricherParameter serviceName="LRS_BusinessDomainObject.lrs.businessDomainObject.domainObjectBuilder.concrete.DomainObjectContentEnrichers:enrichPRRequest" interactionID="">
<!--Sample XML file generated by XMLSpy v2007 sp2 (http://www.altova.com)-->
<Enricher>
<Parameters>
<Parameter name="MESSAGE_IDENTIFIER" reference="test"/>
</Parameters>
<Section path="HEADER">
<Section path="HL7_STANDARD_VERSION">
<Value field="value" value="V3PR2"/>
</Section>
<!--POS/CPP populated ?-->
<!--Not sure if this should be set as a variance within EHIP or if we expect the POS/CPP to provide this value-->
<Section path="PROCESSING_CODE">
<Value field="value" value="T"/>
</Section>
<!--POS/CPP populated ?-->
<Section path="PROCESSING_MODE_CODE">
<Value field="value" value="T"/>
</Section>
<!--POS/CPP populated ?-->
<Section path="DESIRED_ACKNOWLEDGMENT_TYPE">
<Value field="value" value="NE"/>
</Section>
<!-- note:We Expect PRS to give us a web service address -->
<!--<Section path="RECEIVER_NETWORK_ADDRESS">
<Value field="value" value="_http://PRSServer/svcName"/>
</Section>
-->
<Section path="RECEIVER_APPLICATION_IDENTIFIER[0]">
<Value field="root" value="2.16.840.1.113883.3.40.1.14"/>
<Value field="extension" value="SIT1"/>
</Section>
<!-- note: values of the fields to be provided by PRS -->
<Section path="RECEIVER_APPLICATION_NAME[0]">
<Value field="value" value="receiverAppName"/>
</Section>
<!-- note: RECEIVER_ORGANIZATION has an extra trailing space, as in the Excel mapping spreadsheet -->
<!-- note: values of the fields to be specified by PRS later -->
<Section path="RECEIVER_AGENT/RECEIVER_ORGANIZATION/RECEIVER_ORGANIZATION_IDENTIFIER[0]">
<Value field="root" value="2.16.840.1.113883.3.40.4.1"/>
<Value field="extension" value="receiverOrgId"/>
</Section>
<Section path="SENDING_APPLICATION_NAME[0]">
<Value field="value" value="NLPRSCLNT"/>
</Section>
<!-- note: SENDING_ORGANIZATION has an extra trailing space, as in the Excel mapping spreadsheet -->
<!-- note: values of the fields to be specified by PRS later -->
<Section path="SENDING_AGENT/SENDING_ORGANIZATION/SENDING_ORGANIZATION_IDENTIFIER[0]">
<Value field="root" value="2.16.840.1.113883.4.3.57"/>
<Value field="extension" value="3001"/>
</Section>
<Section path="PERFORMER/HEALTHCARE_WORKER_IDENTIFIER[0]">
<Value field="root" value="2.16.840.1.113883.4.3.57"/>
<Value field="extension" value="HIAL_USR"/>
</Section>
</Section>
<Section path="PAYLOAD">
<!--<Section path="QUERY_STATUS_CODE">
<Value field="value" value="New"/>
</Section>-->
<!-- note: AUDIT has an extra trailing space, as in the Excel mapping spreadsheet -->
<Section path="AUDIT[0]/AUDIT_INFORMATION">
<Value field="code" value="LATEST"/>
<Value field="codeSystem" value="PRSAuditParameters"/>
</Section>
<!-- note: CONFIDENCE has an extra trailing space, as in the Excel mapping spreadsheet -->
<Section path="CONFIDENCE/CONFIDENCE_VALUE">
<Value field="value" value="100"/>
</Section>
<!-- note: HISTORY has an extra trailing space, as in the Excel mapping spreadsheet -->
<Section path="HISTORY/INCLUDE_HISTORY_INDICATOR">
<Value field="value" value="false"/>
</Section>
<!-- note: JURISDICTION has an extra trailing space, as in the Excel mapping spreadsheet -->
<Section path="JURISDICTION/JURISDICTION_TYPE">
<Value field="value" value="NL"/>
</Section>
<!-- note: RESPONSE_OBJECT has an extra trailing space, as in the Excel mapping spreadsheet -->
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[0]">
<Value field="code" value="GRS_ADDRESS"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[1]">
<Value field="code" value="GRS_ELECTRONIC_ADDRESS"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[2]">
<Value field="code" value="GRS_IDENTIFIER"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[3]">
<Value field="code" value="GRS_ORGANIZATION_NAME"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[4]">
<Value field="code" value="GRS_PERSONAL_NAME"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[5]">
<Value field="code" value="GRS_REGISTRY_IDENTIFIER"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[6]">
<Value field="code" value="GRS_TELEPHONE"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[7]">
<Value field="code" value="PRS_CONDITION"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[8]">
<Value field="code" value="PRS_CONFIDENTIALITY_INDICATOR"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[9]">
<Value field="code" value="PRS_DEMOGRAPHIC_DETAIL"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[10]">
<Value field="code" value="PRS_DISCIPLINARY_ACTION"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[11]">
<Value field="code" value="PRS_INFORMATION_ROUTE"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[12]">
<Value field="code" value="PRS_NOTE"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[13]">
<Value field="code" value="PRS_PROVIDER_CREDENTIAL"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[14]">
<Value field="code" value="PRS_PROVIDER_EXPERTISE"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[15]">
<Value field="code" value="PRS_PROVIDER_RELATIONSHIP"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[16]">
<Value field="code" value="PRS_STATUS"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[17]">
<Value field="code" value="PRS_WORK_LOCATION"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[18]">
<Value field="code" value="PRS_WORK_LOCATION_ADDRESS"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[19]">
<Value field="code" value="PRS_WORK_LOCATION_DETAIL"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[20]">
<Value field="code" value="PRS_WORK_LOCATION_ELECTRONIC_ADDRESS"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[21]">
<Value field="code" value="PRS_WORK_LOCATION_INFORMATION_ROUTE"/>
</Section>
<Section path="RESPONSE_OBJECT[0]/PROVIDER_QUERY_RESPONSE_OBJECT[22]">
<Value field="code" value="PRS_WORK_LOCATION_TELEPHONE"/>
</Section>
<!-- note: ROLE_CLASS has an extra trailing space, as in the Excel mapping spreadsheet -->
<Section path="ROLE_CLASS /ROLE_CLASS_VALUE">
<Value field="value" value="LIC"/>
</Section>
<Section path="SORT_CONTROL[0]/SORT_CONTROL_ELEMENT_NAME">
<Value field="code" value="PrincipalPerson.name.value.family"/>
</Section>
<Section path="SORT_CONTROL[0]/SORT_CONTROL_DIRECTION_CODE">
<Value field="value" value="A"/>
</Section>
</Section>
</Enricher>
</EnricherParameter>
</EnricherParametersProfileData>
</ProfileData>
</Profile>
the data is valid against the schema through XML Spy tool... and loaded into the XDB repository...
4) create table and insert data:
SQL> CREATE TABLE EHIP_PROFILE OF SYS.XMLTYPE
2 XMLSCHEMA "http://rac3-1-vip:8080/home/EHIPSBUSER1/xsd/EHIPProfile_v00.xsd" ELEMENT "Profile"
3 ;
Table created.
SQL>
SQL> alter table EHIP_PROFILE
2 add CONSTRAINT EHIP_PROF_PK PRIMARY KEY(XMLDATA."ProfileID"."ID",XMLDATA."ProfileID"."Type");
Table altered.
SQL>
SQL>
SQL>
SQL>
SQL> select xdbURIType('/home/'||USER||'/ProfileData/EnricherPP.ID.0001.xml').getClob() from dual;
XDBURITYPE('/HOME/'||USER||'/PROFILEDATA/ENRICHERPP.ID.0001.XML').GETCLOB()
<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSpy
SQL>
SQL>
SQL> insert into ehip_profile values(xmltype.createXML(xdbURIType('/home/'||USER||'/ProfileData/EnricherPP.ID.0001.xml').getClob()));
insert into ehip_profile values(xmltype.createXML(xdbURIType('/home/'||USER||'/ProfileData/EnricherPP.ID.0001.xml').getClob()))
ERROR at line 1:
ORA-21700: object does not exist or is marked for delete
what's the problem caused the "ORA-21700: object does not exist or is marked for delete" error?
Thanks in advance for your help?Thanks Marco,
Here're my environment:
SQL> select INSTANCE_NUMBER, INSTANCE_NAME,HOST_NAME,VERSION from v$instance;
INSTANCE_NUMBER INSTANCE_NAME HOST_NAME VERSION
2 rac32 RAC3-2 10.2.0.3.0
I followed your suggested in the above, and always purge recyclebin, but still got the same problem. because in 10gr2, there's no dbms_xmlschema.purge_schema available,
and I did checked the recyclebin after force the delete of schema, nothing inside. any other recommendation? -
Indices and constraints on XML Tables/Columns (with Schema)
Hi,
I've read a lot of documents by know, but the more I read the more I got confused. So I hope you can help me.
Frist my Oracle Server Version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit
I've manages to create a table with a column with the type SYS.XMLTYPE and the storage modle "Object Relational" with an XML Schema.
I can insert data and I can execute XQuery statements.
I can also create an XMLTYPE table with my Schema, althoug the tool SQL Developer keeps telling me, that the one column wich is generated within the table is of the type CLOB instead of object realtional (which is what I defined).
The query for that is:
CREATE TABLE ENTRY_XML OF XMLTYPE
XMLTYPE STORE AS OBJECT RELATIONAL
XMLSCHEMA "BBMRI_Entry.xsd" ELEMENT "Entry";
That's where I am, now my questions:
1. What's the difference? I'm aware of the obviouse difference, that with the first way I can add relational columns as well, but apart from that? If I only want to store the xml data, is the second approach always better (especially in regard to my next question)?
2. My schema contains elements with attributes (which contain IDs), which have to be unique. So I tried to add a UNIQUE constraint, but failed. I found this (http://www.oracle.com/technology/sample_code/tech/java/codesnippet/xmldb/constraints/Specify_Constraints.html), but it just doesn't work.
Query: "ALTER TABLE ENTRY_XML CONSTRAINT ENTRY_XML_SUBID_UNQIUE UNIQUE (xmldata."SubId");"
Error: "ORA-01735: invalid ALTER TABLE option"
3. I didn't try yet, but I need to specifiy foreign keys within the XML as well (which is explained in the link at question 2). I guess the solution to question 2 will make this possible as well.
4. Since I can create a UNIQUE constaint for attributes (well, I can't yet, but I hope that this will change soon) I woundered if it would be possible to realize something like auto_increment. Although I see the problem with validating the xml input if the Ids are empty. Any suggestions on that problem? Do I have to query for the highest (free) id before I can insert the new documents?
Well, that's enough for today, I hope someone can help me!
Greetings, FlorianI've read through all the literature (again) and found out, that I did most of the stuff right in the first place. I just missinterpreted the generated tables for the types and wondered why they only contained one column. Well, at least one mistery solved.
But know to make it easier just one question, which might solve all problems I have:
How can I create UNIQUE constraints and FOREIGN KEYS when I have a table or column of the type XmlType with a schema using the object relational storage method?
I found a solution http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb05sto.htm#i1042421 (Example 5-12), but it just does not work for me.
I removed the FOREIGN KEY and tried it again and the UNIQUE Key works.
So basically the question is how to retrieve the "AId" Attribute. "XMLDATA"."AId", "XMLDATA"."Attribute"."AId" and "XMLDATA"."Subject"."Attribute"."AId" all do not work.
I've added my schema declarations at the bottom (which I've already successfully registred and used without foreign keys and constraints, so they work).
After I've registered the two schema files 3 types and 11 tables where created. One type for the attribute, one for the study type and one probably to link the attributes to the study types. The tables are one for the attribute, 4 for the content*-elements, 2 for the study type (I don't really know why two) and 4 with strange names starting with "SYS_NT" and then some random numbers and letters (looks alot like some base64 encoded string).
The Query I try to use to create the table is: (The table "Attribute" already exists and contains a field "ID", which is it's PK.)
CREATE TABLE STUDYTYPE_XML
OF XMLType (UNIQUE ("XMLDATA"."STId"),
FOREIGN KEY ("XMLDATA"."AId") REFERENCES ATTRIBUTE(ID))
XMLTYPE STORE AS OBJECT RELATIONAL
ELEMENT "StudyType.xsd#StudyType";
The error I get is:
Error starting at line 1 in command:
CREATE TABLE STUDYTYPE_XML
OF XMLType (UNIQUE ("XMLDATA"."STId"),
FOREIGN KEY ("XMLDATA"."AId") REFERENCES ATTRIBUTE(ID))
ELEMENT "StudyType.xsd#StudyType"
Error at Command Line:3 Column:37
Error report:
SQL Error: ORA-22809: nonexistent attribute
22809. 00000 - "nonexistent attribute"
Cause: An attempt was made to access a non-existent attribute of an
object type.
Action: Check the attribute reference to see if it is valid. Then retry
the operation.
Attribute-Schema (Attribute.xsd):
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:attribute name="AId">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="0" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Name" type="xs:string" />
<xs:element name="ContentString" type="xs:string" />
<xs:element name="ContentInteger" type="xs:integer" />
<xs:element name="ContentDouble" type="xs:decimal" />
<xs:element name="ContentDate" type="xs:date" />
<xs:element name="Attribute">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element ref="ContentString" />
<xs:element ref="ContentInteger" />
<xs:element ref="ContentDouble" />
<xs:element ref="ContentDate" />
</xs:choice>
<xs:attribute ref="AId" use="required" />
<xs:attribute ref="Name" use="optional" />
</xs:complexType>
</xs:element>
</xs:schema>
Study Type Schema (StudyType.xsd):
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="Attribute.xsd" />
<xs:attribute name="STId">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="0" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:element name="StudyType">
<xs:complexType>
<xs:sequence>
<xs:element ref="Attribute" minOccurs="1" maxOccurs="unbounded" />
<xs:element ref="StudyType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute ref="STId" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>
Edited by: alwaysspam on Sep 8, 2010 5:35 PM -
Incorrect order for referential constraints in Export
When multiple tables are selected to export, the created file places the ALTER TABLE statements for the Referential Constraints immediately after the creation of the source table. Unfortunately, most of the time this will mean that the referenced table has not yet been created and the statement will fail.
All referential constraints should be created as a separate block of statements at the end of the file rather than table by table where errors will occur if the script is simply run.I managed to resolve the issue by un-commenting below lines( they were commented in std though) -
XDECI FILL IT & XDECI FILL RT -
Hierarchical queries and referential constraints
Experts,
What is the rationale for having a referential integrity constraint on a table that has rows bound by hierarchical relationships ?? The hierarchical relationship ensures that each row is referencing another in the same table via the PRIOR clause. If I add a foreign key relationship to these columns , does it make any sense ??/
-Rekhabut you can use a hierarchical query to display constraints in a tree !
SQL> create table t1 (a number primary key);
Table created.
SQL> create table t2 (b number primary key, a number references t1(a));
Table created.
SQL> create table t3 (c number primary key, b number references t2(b));
Table created.
SQL> create table t4 (d number primary key, a number references t1(a));
Table created.
SQL> create table t5 (e number primary key, f number references t5(e));
Table created.
SQL> select sys_connect_by_path(p.table_name,':')||':'||r.table_name p
from all_constraints p
join all_constraints r
on (p.constraint_name = r.r_constraint_name and p.owner = r.r_owner)
where CONNECT_BY_ISLEAF = 1
connect by nocycle prior r.table_name = p.table_name
start with p.table_name not in (select r.table_name from all_constraints p join
all_constraints r on (p.constraint_name = r.r_constraint_name and
p.owner = r.r_owner and p.table_name != r.table_name) );
:DEPT:EMP
:T1:T4
:T1:T2:T3
:T5:T5 -
To create referential constraints or not while designing a data model...
Hi,
If I were to design a data model involving some tables which tend to grow fast and huge, which option w.r.t creating referential constraints (foreign key constraints) between tables is advisable - to create or not to create?
Assuming that there are no specific requirements to implement referential integrity (though it maybe implicity stated). I know that creating referential constraints might maintain data integrity but on the other hand, it might be a bottleneck in some data-intensive queries/operations involving huge tables.
In other words, what factors should we consider while deciding on to create referential constraints or not in a data model?
thanks & regds,
Ashok.Hi,
>>it might be a bottleneck in some data-intensive queries/operations involving huge tables.
Hummm, are you sure ? I'm not convinced that foreign key constraints can cause a bottlenecks while querying the database. Why ? Otherwise, DML statements can be affected by some constraints and indexes ... in some systems for example perform data loading in a Data Warehouse, DSS Systems, etc....
"The key thing to remember here is that if you cannot guarantee the integrity of your data, it doesn't matter how fast you can retrieve it from the database"
Cheers -
Find missing referential constraints
I have a master table that is referenced by many other tables. Unfortunately, many of these child tables have been created without the necessary referential constraint to the parent. How can I easily identify these tables?
The code would be like
select table_name
from tables
where table_column like '%master_column'
and not exists referential constraint on this table_column to the master_table
Has anyone had to do this in the past - do you have an example script?
Thanks
RichardHere is something I cobbled together that seems to work - its not pretty though...
SELECT *
FROM DBA_TAB_COLUMNS atc,
DBA_OBJECTS allo
WHERE (UPPER(atc.column_name) LIKE :column_name)
AND (atc.owner IN (:owner))
AND (allo.object_name = atc.table_name)
AND (allo.owner = atc.owner)
AND (allo.object_type IN ('TABLE', 'VIEW', 'CLUSTER', 'MATERIALIZED VIEW', 'UNDEFINED'))
AND NOT EXISTS
(SELECT *
FROM (SELECT AO.NAME TABLE_NAME,
AU.NAME OWNER,
BCN.NAME CONSTRAINT_NAME,
DECODE(ac.TYPE#, 4,
DECODE(ac.refact, 1, 'CASCADE', 2, 'SET NULL', 'NO ACTION'),
NULL) delete_rule,
BO.NAME TN, BU.NAME R_OWNER
FROM SYS.CDEF$ BC, SYS.CON$ BCN, SYS.OBJ$ BO, SYS.USER$ BU,
SYS.CON$ BRC, SYS.USER$ BRU, SYS.OBJ$ BRO,
SYS.CDEF$ AC, SYS.CON$ ACN, SYS.OBJ$ AO, SYS.USER$ AU
WHERE BC.CON# = BCN.CON#
AND BC.OBJ# = BO.OBJ#
AND BO.OWNER# = BU.USER#
AND BC.RCON# = BRC.CON#(+)
AND BRC.OWNER# = BRU.USER#(+)
AND BC.ROBJ# = BRO.OBJ#(+)
AND AC.CON# = BC.RCON#
AND AC.CON# = ACN.CON#
AND AO.OBJ# = AC.OBJ#
AND AO.OWNER# = AU.USER#
AND AC.TYPE# IN (2,3)) A,
DBA_CONS_COLUMNS B
WHERE B.TABLE_NAME = A.TN
AND B.CONSTRAINT_NAME = A.CONSTRAINT_NAME
AND B.OWNER = A.R_OWNER
AND b.table_name = atc.table_name
AND b.owner = atc.owner)
Richard -
Scope keyword and referential constraints
Hi guys,
I'm new in DB relational-object, and looking at oracle guide
I have foud that I can specify both scope and referential constraint using the keyword REFERENTIAL associated with keyword SCOPE FOR
([http://download-east.oracle.com/docs/cd/B14117_01/appdev.101/b10799/adobjbas.htm#sthref108] basic component of oracle object)
Now, I checked that SCOPE FOR work properly:
ALTER TABLE SOME_TAB ADD (SCOPE FOR (ATTRIBUE_SOME_TAB) IS ANOTHER_TAB);
but I can't specify REFERENTIAL constraint in any way and
neither I have founf some explanation about
Have Someone idea about this?
Thanks, for your helps to me!See:
Re: to REF or not to REF?
"To avoid dangling REFs, we must have good old foreign key:
ALTER TABLE emp_obj_tab ADD CONSTRAINT emp_dept_fk FOREIGN KEY (dept_oid) REFERENCES dept_obj_tab;"
Regards -
I cannot see XMLType table in sql*plus
Hi,
Although I have wokred extensively with Oracle, I am new to Oracle XMLdb. My problem is I cannot see the XMLType tables created under my schema. I can see the tables when I do a select from user_xml_tables. But if I do a 'desc' or 'select from', I get ORA-04043 or ORA-00942. I can desc an XMLType table owned by xdb. I am using Oralce 10g. Please provide a solution asap as a customer is waiting on this.
Thanks,
Jayati RayRaghu !!
GREAT!!!
It was a BUG in Oracle sql developer, I installed the new version v3.0, It WORKS like a CHARM.
Thanks a million for your help!!!
Cheers
Tony -
How to delete an .xml file from xmltype table?
Hi expert,
I am in I am in Oracle Enterprise Manager 11g 11.2.0.1.0.
SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 22 11:40:23 2011
I have inserted 3 .xml files into an xmltype table: DOCUMENT
SQL> SELECT OBJECT_VALUE FROM document;
OBJECT_VALUE
<?xml version="1.0" encoding="WINDOWS-1252"?>
<?xml-stylesheet href="http://www.accessdata.fda.gov/spl/stylesheet/spl.xsl" type="text/xsl"?>
<document xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLoc
ation="urn:hl7-org:v3 http://localhost:8080/home/DEV/xsd/spl.xsd" classCode="DOC">
<id root="5ca4e3cb-7298-4948-8cc2-58e71ad32694"/>
<code code="51725-0" c
<?xml version="1.0" encoding="WINDOWS-1252"?>
<?xml-stylesheet href="http://www.accessdata.fda.gov/spl/stylesheet/spl.xsl" type="text/xsl"?>
<document xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLoc
ation="urn:hl7-org:v3 http://localhost:8080/home/DEV/xsd/spl.xsd" classCode="DOC">
<id root="03d6a2cd-fdda-4fe1-865d-da0db9212f34"/>
<code code="51725-0" c
<?xml version="1.0" encoding="WINDOWS-1252"?>
<?xml-stylesheet href="http://www.accessdata.fda.gov/spl/stylesheet/spl.xsl" type="text/xsl"?>
<document xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLoc
ation="urn:hl7-org:v3 http://localhost:8080/home/DEV/xsd/spl.xsd" classCode="DOC">
<id root="09ff06d6-8b85-43dd-b5cc-e22d00f02bd0"/>
<code code="51725-0" c
I tried to delete one xml file which with id root="03d6a2cd-fdda-4fe1-865d-da0db9212f34'
delete from DOCUMENT
where xmlexists('$p/document/id[@root="03d6a2cd-fdda-4fe1-865d-da0db9212f34"]'PASSING OBJECT_VALUE AS "p");
but failed.
Is there any expert can help?
Thanks a lot!
Cow
Edited by: Cow on Mar 11, 2011 7:02 PMHi,
Namespace issue.
You have to declare it in the XQuery prolog :
DELETE FROM document
WHERE XMLExists( 'declare default element namespace "urn:hl7-org:v3"; (::)
$p/document/id[@root=$root_value]'
passing object_value as "p",
'03d6a2cd-fdda-4fe1-865d-da0db9212f34' as "root_value" )
;
Maybe you are looking for
-
Transaction type ZGC not possible (posting to affiliated company) in ABSO
Hi all, We have depreciation areas 01, 30, 31, 32 . dep area 30, 31, 32 inherits the values from 01. We want to post credit value to dep area 01 after doing the aqusition . Hence we created a seperate transaction type ZGC ( in aqusitions- Tcode AO73
-
Cannot open attached email from adobe reader
Adobe reader cannot open in protected mode due to a problem with your system configuration. Woud you like to open adobe with protected mode. If I try to open with protected mode disabled then it says acrobat failed to load its core Dll I have tried t
-
quisierasaber porque no me toma el pago un proovedor dr internet con tarjeta de credito,gracias
-
HT3986 iMac (24-inch Mid 2007) can i install win7 64 bit on this mac?
i am using win7 32bit and want to install win 7 64bit. can i install it?
-
Am I stuck storing all my downloaded music on my computer if I want it to stay on my ipod when I sync new songs? It's taking up way too much memory.