Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

unique constraint defined in xsd

462094Nov 3 2005 — edited Jul 19 2006
Hi all,

The Database cannot check against the unique constraint by the scripts on below, is there anything wrong with my script, or the database cannot check the unique constraint when I insert the xml into the table? (btw, is there any simple sample for the unique constraint for xsd)?

DECLARE
custschema VARCHAR2(2000) :=
'<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb">
<xs:complexType name="columnType" xdb:SQLType="columnType">
<xs:sequence>
<xs:element name="name" type="xs:string" nillable="false"/>
<xs:element name="width" type="xs:positiveInteger" nillable="false"/>
</xs:sequence>
<xs:attribute name="seq" type="xs:positiveInteger" use="required" />
</xs:complexType>
<xs:complexType name="columns" xdb:SQLType="columns">
<xs:sequence>
<xs:element name="column" maxOccurs="unbounded" type="columnType"/>
</xs:sequence>
</xs:complexType>
<xs:element name="FixLengthColDef">
<xs:complexType xdb:SQLType="FixLengthColDef">
<xs:sequence>
<xs:element name="interfaceId" type="xs:string" nillable="false"/>
<xs:element name="interfaceSeq" type="xs:positiveInteger" nillable="false"/>
<xs:element name="columns" maxOccurs="unbounded" type="columns"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="uniqueNode">
<xs:selector xpath="xs:columns/column"/>
<xs:field xpath="xs:@seq"/>
</xs:unique>
</xs:element>
</xs:schema>';
BEGIN DBMS_XMLSCHEMA.RegisterSchema('xxifFL1.xsd', custschema);
END;
/

CREATE TABLE xxiftbl1 OF XMLType XMLSCHEMA "xxifFL1.xsd" ELEMENT "FixLengthColDef";

DECLARE
custxmldoc XMLType;
BEGIN
custxmldoc := XMLType.CREATEXML('
<FixLengthColDef xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="xxifFL1.xsd">
<interfaceId>if001</interfaceId>
<interfaceSeq>1</interfaceSeq>
<columns>
<column seq="1">
<name>col1</name>
<width>15</width>
</column>
<column seq="1">
<name>col2</name>
<width>25</width>
</column>
</columns>
</FixLengthColDef>');
INSERT INTO xxiftbl1 VALUES(custxmldoc);
END;
/

Thanks in advance,
Alan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 16 2006
Added on Nov 3 2005
15 comments
1,286 views