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!

ORA-31094 & ORA-31082 when registering Schemas generated w/generateSchema()

387940Feb 22 2003
I have genereated several Schemas using DBMS_XMLSCHEMA.generateSchema(). However, trying to register these Schemas results in error messages. The error messages state that "REF" and also my own Types were incompatible SQL-Types for an Attribute or Element (ORA-31094). Also, they state that "SQLSchema" was an invalid Attribute (ORA-31082).
As an example, I have included one of the Schemas that has been generated, the procedure used to register it and and also the type OTYP_Artikel it has been generated from. I would like to know why the Schemas generated by Oracle contain these errors and how to fix this.

declare
doc varchar2(2000) := '<xsd:schema targetNamespace="http://ns.oracle.com/xdb/OO_CHEF" xmlns="http://ns.oracle.com/xdb/OO_CHEF" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/xdb http://xmlns.oracle.com/xdb/XDBSchema.xsd">
<xsd:element name="OTYP_ARTIKEL" type="OTYP_ARTIKELType" xdb:SQLType="OTYP_ARTIKEL" xdb:SQLSchema="OO_CHEF"/>
<xsd:complexType name="OTYP_ARTIKELType">
<xsd:sequence>
<xsd:element name="ARTIKEL_NR" type="xsd:string" xdb:SQLName="ARTIKEL_NR" xdb:SQLType="VARCHAR2"/>
<xsd:element name="MWST" type="xsd:hexBinary" xdb:SQLName="MWST" xdb:SQLType="REF"/>
<xsd:element name="BEZEICHNUNG" type="xsd:string" xdb:SQLName="BEZEICHNUNG" xdb:SQLType="VARCHAR2"/>
<xsd:element name="LISTENPREIS" type="xsd:double" xdb:SQLName="LISTENPREIS" xdb:SQLType="NUMBER"/>
<xsd:element name="BESTAND" type="xsd:double" xdb:SQLName="BESTAND" xdb:SQLType="NUMBER"/>
<xsd:element name="MINDESTBESTAND" type="xsd:double" xdb:SQLName="MINDESTBESTAND" xdb:SQLType="NUMBER"/>
<xsd:element name="VERPACKUNG" type="xsd:string" xdb:SQLName="VERPACKUNG" xdb:SQLType="VARCHAR2"/>
<xsd:element name="LAGERPLATZ" type="xsd:double" xdb:SQLName="LAGERPLATZ" xdb:SQLType="NUMBER"/>
<xsd:element name="KANN_WEGFALLEN" type="xsd:double" xdb:SQLName="KANN_WEGFALLEN" xdb:SQLType="NUMBER"/>
<xsd:element name="BESTELLVORSCHLAG" type="xsd:date" xdb:SQLName="BESTELLVORSCHLAG" xdb:SQLType="DATE"/>
<xsd:element name="NACHBESTELLUNG" type="xsd:date" xdb:SQLName="NACHBESTELLUNG" xdb:SQLType="DATE"/>
<xsd:element name="NACHBESTELLMENGE" type="xsd:double" xdb:SQLName="NACHBESTELLMENGE" xdb:SQLType="NUMBER"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>';
begin
dbms_xmlschema.registerSchema('http://www.oracle.com/best.xsd', doc);
end;
DROP TABLE otab_artikel
/
DROP TABLE otab_mwstsatz
/
DROP TYPE otyp_artikel
/
DROP TYPE otyp_mwstsatz
/

CREATE OR REPLACE TYPE otyp_mwstsatz AS OBJECT (
mwst integer,
prozent number (3,3),
beschreibung varchar2(10),

MAP MEMBER FUNCTION mwst_order RETURN REAL,
PRAGMA RESTRICT_REFERENCES
(mwst_order, RNDS, WNDS, RNPS, WNPS),
STATIC FUNCTION construct_mwst (in_mwst IN INTEGER,
in_prozent IN NUMBER, in_beschreib IN VARCHAR2)
RETURN otyp_mwstsatz

);

/

show errors

CREATE OR REPLACE TYPE BODY otyp_mwstsatz AS

MAP MEMBER FUNCTION mwst_order RETURN REAL IS
BEGIN
RETURN prozent;
END mwst_order;

STATIC FUNCTION construct_mwst (in_mwst IN INTEGER,
in_prozent IN NUMBER,
in_beschreib IN VARCHAR2)
RETURN otyp_mwstsatz IS
BEGIN
IF in_mwst < 0 THEN
DBMS_OUTPUT.PUT_LINE ('Mwst-Schluessel muss >=0 sein');
raise_application_error(-1,'Wertfehler bei mwst',FALSE);
ELSE
RETURN otyp_mwstsatz(in_mwst,in_prozent,in_beschreib);
END IF;
END construct_mwst;
END;
/

show errors


CREATE TABLE otab_mwstsatz OF otyp_mwstsatz
(
mwst NOT NULL,
prozent NOT NULL,
CONSTRAINT pk_mwstsatz PRIMARY KEY (mwst)
)
/

CREATE OR REPLACE TYPE otyp_artikel AS OBJECT (
artikel_nr varchar2(4),
mwst REF otyp_mwstsatz,
bezeichnung varchar2(15),
listenpreis number(8,2),
bestand number(5,0),
mindestbestand number (5,0),
verpackung varchar2(15),
lagerplatz number(2,0),
kann_wegfallen number(1,0),
bestellvorschlag date,
nachbestellung date,
nachbestellmenge number(5,0),
MEMBER FUNCTION get_mwst RETURN REAL,
PRAGMA RESTRICT_REFERENCES (get_mwst, WNDS, WNPS)
);
/
show errors

CREATE OR REPLACE TYPE BODY otyp_artikel AS
MEMBER FUNCTION get_mwst RETURN REAL IS
lvar_prozent NUMBER(3,3);
lvar_mwst otyp_mwstsatz;
BEGIN
SELECT DEREF(mwst) INTO lvar_mwst
FROM dual;
lvar_prozent := lvar_mwst.prozent;

RETURN lvar_prozent;
END get_mwst;
END;
/
show errors

CREATE TABLE otab_artikel OF otyp_artikel (
CONSTRAINT pk_artikel PRIMARY KEY (artikel_nr),
CONSTRAINT nn_mwst mwst NOT NULL,
CONSTRAINT nn_bezeichnung bezeichnung NOT NULL,
CONSTRAINT nn_listenpreis listenpreis NOT NULL,
CONSTRAINT nn_bestand bestand NOT NULL,
CONSTRAINT chk_bestand CHECK (bestand >= 0),
CONSTRAINT nn_mindestbestand mindestbestand NOT NULL,
CONSTRAINT chk_mindestbestand CHECK (mindestbestand >= 0),
CONSTRAINT chk_nachbestell
CHECK (nachbestellmenge IS NULL OR nachbestellmenge >= 0)
);
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 22 2003
Added on Feb 22 2003
0 comments
269 views