Dbms_xmlschema.generateschema
Hi!
I want to generate a XMLschema from the database but i only get this:
DBMS_XMLSCHEMA.GENERATESCHEMA(UPPER('SCOTT'),'EMPLOYEE_T').GETCLOBVAL()
<?xml version="1.0"?>
<xsd:schema targetNamespace="http://ns.oracle.com/xdb/SCOT
This is my code:
select dbms_xmlschema.generateschema(upper('scott'), 'EMPLOYEE_T').getClobVal()
from dual;
This is my database:
9.2.0.1.0
Is my database the reason or have i done something wrong?
With best regards
Nicole
Hi Nicole
"set long 1000000000" should solve your problem.
Chris
PS: if you want to use XDB you should install 9.2.0.4.0
Similar Messages
-
Dbms_xmlschema.generateschema - JAXB
dbms_xmlschema.generateschema - JAXB
We want to use our Oracle produced xsd to build JAVA content trees for unmarshalling and marshalling USING JAXB. The Oracle generated xsd does NOT nest complex sequence elements properly for JAXB. Any input is appreciated.
Below is an example from the sun tutorial for using JAXB. Notice the ITEMS/ITEM structure. Below that is our example types, PL/SQL to generate xsd and the results.
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
<xsd:element name="comment" type="xsd:string"/>
<xsd:complexType name="PurchaseOrderType">
<xsd:sequence>
<xsd:element name="shipTo" type="USAddress"/>
<xsd:element name="billTo" type="USAddress"/>
<xsd:element ref="comment" minOccurs="0"/>
<xsd:element name="items" type="Items"/>
</xsd:sequence>
<xsd:attribute name="orderDate" type="xsd:date"/>
</xsd:complexType>
<xsd:complexType name="USAddress">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="street" type="xsd:string"/>
<xsd:element name="city" type="xsd:string"/>
<xsd:element name="state" type="xsd:string"/>
<xsd:element name="zip" type="xsd:decimal"/>
</xsd:sequence>
<xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/>
</xsd:complexType>
<xsd:complexType name="Items">
<xsd:sequence>
<xsd:element name="item" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="productName" type="xsd:string"/>
<xsd:element name="quantity">
<xsd:simpleType>
<xsd:restriction base="xsd:positiveInteger">
<xsd:maxExclusive value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="USPrice" type="xsd:decimal"/>
<xsd:element ref="comment" minOccurs="0"/>
<xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="partNum" type="SKU" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<!-- Stock Keeping Unit, a code for identifying products -->
<xsd:simpleType name="SKU">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{3}-[A-Z]{2}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
CREATE OR REPLACE TYPE sjs.Item AS OBJECT
( "productName" VARCHAR2(100),
"quantity" INTEGER
CREATE OR REPLACE TYPE sjs.Items AS TABLE OF sjs.Item
CREATE OR REPLACE TYPE sjs.purchaseOrder AS OBJECT
("comment" VARCHAR2(100),
"Items" Items
DECLARE
RECURSE BOOLEAN := TRUE;
ANNOTATE BOOLEAN := FALSE;
EMBEDCOLL BOOLEAN := FALSE;
Schemaurl VARCHAR2(10) := 'WWW';
XSD_TYPE XMLTYPE;
XSD_CLOB CLOB;
XML_CLOB CLOB;
XML_TYPE XMLsequenceTYPE;
valid_flag INTEGER;
p_out CLOB;
message VARCHAR2(4000);
BEGIN
EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY XML_DIR AS ''C:\XMLAPI_PRODUCE''';
XSD_TYPE := dbms_xmlschema.generateschema('SJS','ITEMS','purchaseOrder',RECURSE,ANNOTATE,EMBEDCOLL);
XSD_CLOB := XSD_TYPE.getclobval;
sjs.file_util.write_clob(XSD_CLOB,'po.xsd','C:\XMLAPI_PRODUCE');
DBMS_LOB.CREATETEMPORARY(xml_CLOB,TRUE,dbms_lob.CALL);
DBMS_LOB.OPEN(xml_CLOB, DBMS_LOB.LOB_READWRITE);
DBMS_LOB.CREATETEMPORARY(xsd_CLOB,TRUE,dbms_lob.CALL);
DBMS_LOB.OPEN(xsd_CLOB, DBMS_LOB.LOB_READWRITE);
DBMS_LOB.CLOSE(xml_CLOB);
DBMS_LOB.FREETEMPORARY(xml_CLOB);
DBMS_LOB.CLOSE(xsd_CLOB);
DBMS_LOB.FREETEMPORARY(xsd_CLOB);
END;
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xdb="http://xmlns.oracle.com/xdb" xsi:schemaLocation="http://xmlns.oracle.com/xdb http://xmlns.oracle.com/xdb/XDBSchema.xsd">
<xsd:element name="purchaseOrder" type="ITEMSType"/>
<xsd:complexType name="ITEMSType">
<xsd:sequence>
<xsd:element name="ITEMS_ITEM" type="ITEMType" maxOccurs="unbounded" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ITEMType">
<xsd:sequence>
<xsd:element name="productName">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="quantity" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>DB Structure
Parent Table - Incident --> Child Table - IncidentCharges --> Child Table of IncidentCharges --> IncidentChargeWeapons
Container
Oracle Containers for JAVA(OC4J)
We have a schema (Incident.xsd) which comprises of our entire database structure. We unmarshalled the schema using JAXB to Java classes and interfaces .
It created 2 .java classes and 2 .java interfaces for each high level tag . for eg for our Incident tag it created a Incident interface and a IncidentType Interface
and also it created 2 classes IncidentImpl and IncidentTypeImpl . The IncidentTypeImpl has all the get and set properties we require eg. getIncidentType,
setIncidentType,getIncidentNumber,setIncidentNumber,getOccuranceDate,setOccuranceDate etc.
Our objective is to create a JSP page which has form fields to enter data which use these JAXB generated classes get and set properties. In other words
we want to bind the JSP form fields to these JAXB generated classes. And once these JAXB objects are populated we want to marshal it and create a XML file with the data from those JAXB . Our database would then consume the generated XML. We tried creating a simple incident form with just 3 fields IncidentType,Occurance date and Incident Number and tried to bind these fields with the properties from IncidentTypeImpl classes using the <jsp:usebean> tag . When we deployed it to our container and tried to load the Incident.jsp page , it would not load up . Only when we cleared all the bindings it loaded up .
Then we tried another workaround (just to get it working. Not a preferred approach) . We created another simple JAVA bean(not JAXB generated beans) which has set and get properties for the form fields and bound the form fields to it.
On submitting the JSP page we called a servlet which takes data from our created bean and transfers it to the JAXB generated IncidentTypeImpl bean. When we deployed this the jsp page loads up and also our bean is filled with data . But the servlet bombs with this error below.
500 Internal Server Error
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext
at Servlets.IncidentServlet.doPost(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
at java.lang.Thread.run(Thread.java:534)
We have 2 questions .
1. Can a JSP page be bound directly to this JAXB generated bean in pretty much the same way as we bind it to our own bean ? (We would like to do this so that we dont have to create duplicate classes which mirror the JAXB generated classes.)
2. Is there something special we have to do to deploy this application to recognize the JAXB classes. Do we have to deploy some jar file for it to recognize those classes ? -
ORA-31094 & ORA-31082 when registering Schemas generated w/generateSchema()
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)
);Please post your question to XML DB forum for further help.
-
How do you "unregister a schema". The following is being used to register and validate but it will not "reregister". getting the following error:
DECLARE
RECURSE BOOLEAN := TRUE;
ANNOTATE BOOLEAN := FALSE;
EMBEDCOLL BOOLEAN := TRUE;
XSD_TYPE XMLTYPE;
XSD_CLOB CLOB;
XML_CLOB CLOB;
XML_TYPE XMLTYPE;
valid_flag INTEGER;
p_out CLOB;
BEGIN
EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY XML_DIR AS ''C:\XMLAPI_PRODUCE''';
XSD_TYPE := dbms_xmlschema.generateschema('SJS','XMLAPI_INCIDENT_TYPE','APIIncident',RECURSE,ANNOTATE,EMBEDCOLL);
XSD_CLOB := XSD_TYPE.getclobval;
dbms_xmlschema.registerSchema('http://www.oracle.com/best.xsd', XSD_CLOB);
sjs.file_util.write_clob(XSD_CLOB,'TEST.xml','C:\XMLAPI_PRODUCE');
DBMS_LOB.CREATETEMPORARY(xml_CLOB,TRUE,dbms_lob.CALL);
DBMS_LOB.OPEN(xml_CLOB, DBMS_LOB.LOB_READWRITE);
sjs.file_util.ReadClob(xml_CLOB,'XML_DIR','INC200306261138511.xml');
xml_type := XMLTYPE.createXML(xml_clob);
IF xml_type.isSchemaValid('http://www.oracle.com/best.xsd') = 1 THEN
DBMS_OUTPUT.PUT_LINE('Valid xml');
ELSE
DBMS_OUTPUT.PUT_LINE('NOT Valid xml');
END IF;
DBMS_LOB.CLOSE(xml_CLOB);
DBMS_LOB.FREETEMPORARY(xml_CLOB);
dbms_output.put_line(p_out);
END;
ERROR at line 1:
ORA-31085: schema "http://www.oracle.com/best.xsd" already registered
ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 0
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 26
ORA-06512: at line 15Got it, Thanks, The following stil always produces Not valid for the xml. Do you know a way to get the info on why the xml is invalid?
Thanks
SET SERVEROUTPUT ON SIZE 1000000
DECLARE
RECURSE BOOLEAN := TRUE;
ANNOTATE BOOLEAN := FALSE;
EMBEDCOLL BOOLEAN := TRUE;
XSD_TYPE XMLTYPE;
XSD_CLOB CLOB;
XML_CLOB CLOB;
XML_TYPE XMLTYPE;
valid_flag INTEGER;
p_out CLOB;
BEGIN
EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY XML_DIR AS ''C:\XMLAPI_PRODUCE''';
XSD_TYPE := dbms_xmlschema.generateschema('SJS','XMLAPI_INCIDENT_TYPE','APIIncident',RECURSE,ANNOTATE,EMBEDCOLL);
XSD_CLOB := XSD_TYPE.getclobval;
dbms_xmlschema.deleteSchema('http://www.oracle.com/best.xsd', dbms_xmlschema.DELETE_CASCADE);
dbms_xmlschema.registerSchema('http://www.oracle.com/best.xsd', XSD_CLOB);
sjs.file_util.write_clob(XSD_CLOB,'TEST.xml','C:\XMLAPI_PRODUCE');
DBMS_LOB.CREATETEMPORARY(xml_CLOB,TRUE,dbms_lob.CALL);
DBMS_LOB.OPEN(xml_CLOB, DBMS_LOB.LOB_READWRITE);
sjs.file_util.ReadClob(xml_CLOB,'XML_DIR','TEST.xml');
xml_type := XMLTYPE.createXML(xml_clob);
IF xml_type.isSchemaValid(XSD_CLOB) = 1 THEN
DBMS_OUTPUT.PUT_LINE('Valid xml');
ELSE
DBMS_OUTPUT.PUT_LINE('NOT Valid xml');
END IF;
DBMS_LOB.CLOSE(xml_CLOB);
DBMS_LOB.FREETEMPORARY(xml_CLOB);
dbms_output.put_line(p_out);
END; -
Generateschema minlength/maxlength ??
Can the dbms_xmlschema.generateschema procedure produce minlength and maxlength when producing the schema?
Thanks9.2.0.4
Windows 2000
Can the dbms_xmlschema.generateschema generate minlength/maxlength attributes?
Here is the procedure call:
XSD_TYPE := dbms_xmlschema.generateschema('SJS','XMLAPI_INCIDENT_TYPE','APIIncident',FALSE,FALSE,FALSE);
here is the output portion:
<?xml version="1.0"?>
<xsd:schema targetNamespace="http://ns.oracle.com/xdb/SJS" xmlns="http://ns.oracle.com/xdb/SJS" 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="IncidentRecord" type="XMLAPI_INCIDENT_TYPEType"/>
<xsd:complexType name="XMLAPI_INCIDENT_TYPEType">
<xsd:sequence>
<xsd:element name="I_ID" type="xsd:double"/>
<xsd:element name="AgencyORI" type="xsd:string"/>
<xsd:element name="IncidentNumber" type="xsd:string"/>
<xsd:element name="DivisionPrecinct" type="xsd:string"/>
<xsd:element name="CaseNumber" type="xsd:string"/>
<xsd:element name="IncidentType" type="xsd:string"/>
<xsd:element name="ExternalIncidentID" type="xsd:string"/>
<xsd:element name="ExternalSourceLocation" type="xsd:string"/> -
Call to createxml with a schema url does not create schema based xml
Unfortunately I am unable to post the exact creates that I have done, but I am having a problem and none of my DBA's were able to help me.
Basically what I have done is, I had existing tables in our database that have legacy data in them. Our ultimate goal is to export information in xml format from the database.
The first thing I did was to create objects in oracle that wrapped the logic of these tables and filled the objects in based on on ID parameter. There are 3 separate levels of objects. One object that has tables of two other objects each of which has tables of objects themselves.
After the objects were created, I used a call to dbms_xmlschema.generateschema to generate the schema for these objects. After that I changed the schema so that the names of the elements in the schema were names that i wanted to be. I THOUGHT that this would map my oracle object names to new element names.
After the schema was generated and changed, I used a call to dbms_xmlschema.registerSchema with the following options:
local=>true, genTypes=>false, force=>false, GENTABLES=>false, genbean=>false
I tried it with gentables = true, but unfortunately i don't have access to create these tables and the dba's were not allowing me to because they aren't familiar with the xml capabilities and I couldn't explain why it was necessary. I'm not sure that it is.
Once the schema was registered, i made a call to xmltype.createxml
with a call to my object contstructor method as the first parameter, and the schema url that was registered in the database as the second parameter.
Now, here is my problem. The xmltype result that comes back from the query to createxml does not return the element tag names that i had written in the schema. The tag names are the same as the object names which are the same as it is if i didn't use the schema url at all. Does anyone know what I could possibly be doing wrong? Maybe I am misunderstanding the functionality of creating xml with an oracle xml annotated schema. Please help!code tags and formatting are done with square brackets :-) Check out the Formatting Help on the message entry page
What does the URL resolve to when you view source on the JSP page?
Try it just "/ViewScores" rather than "/servlet/ViewScores"
Apart from that, it looks fine to me
Cheers,
evnafets -
Register schema: insufficient privileges to use enablehierarchy
Hello,
In Oracle11g release 2 I'm trying to register a schema. It works, as long as I set enablehierarchy to ENABLE_HIERARCHY_NONE.
For all other values of this parameter, I get this error message:
ORA-31061: XDB error: DBMS_XDBZ.ENABLE_HIERARCHY
ORA-06512: at "XDB.DBMS_XDBZ0", line 131
ORA-06512: at "XDB.DBMS_XDBZ0", line 586
ORA-01031: insufficient privileges
ORA-06512: at "XDB.DBMS_XDBZ", line 37
ORA-06512: at line 1
ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 55
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 159
ORA-06512: at line 4
for instance, this works:
declare doc xmltype;
begin
select dbms_xmlschema.generateschema(user,'VORM') into doc from dual;
dbms_xmlschema.registerschema('http://www.5hart.com/schema/vormen.xsd', doc,
gentypes => false,
enablehierarchy=>dbms_xmlschema.*ENABLE_HIERARCHY_NONE*);
end;
but this doesn't:
declare doc xmltype;
begin
select dbms_xmlschema.generateschema(user,'VORM') into doc from dual;
dbms_xmlschema.registerschema('http://www.5hart.com/schema/vormen.xsd', doc,
gentypes => false,
enablehierarchy=>dbms_xmlschema.*ENABLE_HIERARCHY_CONTENTS*);
end;
Could someone tell me what privileges I'm missing? I have the role XDBADMIN, I've tried "grant execute on DBMS_XDBZ, but nothing works.
Help would be appreciated.
Thanx,
Marko
Edited by: user11998055 on 10-dec-2009 2:09
Edited by: user11998055 on 10-dec-2009 2:55Nowadays I can explain why this works - I think.
Locally registered xml schemas are protected by ACL's (more or less) and is accessable ONLY by the user that created it (besides SYS). DBA,XDBADMIN, system accounts etc are just not good enough.
The direct granted "alter session" prevents having to use the full syntax of OWNER.OBJECT_NAME.COLUMN_NAME@DBLINK etc, etc... and thus refering to objects can be reduced to OBJECT_NAME instead of OWNER.OBJECTNAME and makes it possible for the package to do its XDBZ thingy.
;-) -
Restrictive query always returns no rows
I am trying to run a query with a where clause, but I'm always getting no rows returned. I am obviously overlooking something. Here are my scripts that are on the employee dept tables.
The scripts run without any errors and when I do a 'select * from dept_xml' I get the complete XML output. However if I run the query
select * from dept_xml
where existsNode(sys_nc_rowinfo$, '/DEPT_T[DEPTNO=40]') = 1
no rows returned
WHY??
drop type emp_t force
drop type emplist_t force
drop type dept_t force
drop type deptlist_t force
drop type depts_t force
CREATE OR REPLACE TYPE emp_t AS OBJECT
EMPNO NUMBER(4),
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(8,2),
COMM NUMBER(8,2)
CREATE OR REPLACE TYPE emplist_t AS TABLE OF emp_t
CREATE OR REPLACE TYPE dept_t AS OBJECT
DEPTNO NUMBER(2),
DNAME VARCHAR2(14),
LOC VARCHAR2(13),
EMPS EMPLIST_T
CREATE OR REPLACE TYPE deptlist_t AS TABLE OF dept_t
CREATE OR REPLACE TYPE depts_t AS OBJECT
DEPTS DEPTLIST_T
begin
dbms_xmlschema.deleteSchema('http://www.oracle.com/depts.xsd', 4);
dbms_xmlschema.registerSchema('http://www.oracle.com/depts.xsd', dbms_xmlschema.generateschema('SCOTT','DEPT_T'),TRUE,FALSE);
end;
CREATE OR REPLACE VIEW dept_xml OF XMLTYPE
XMLSCHEMA "http://www.oracle.com/depts.xsd" ELEMENT "DEPT_T"
WITH OBJECT ID (sys_nc_rowinfo$.extract('/DEPT_T/DEPTNO').getNumberVal())
AS
SELECT dept_t(d.deptno,
d.dname,
d.loc,
cast(multiset(SELECT emp_t(e.empno,
e.ename,
e.job,
e.mgr,
e.hiredate,
e.sal,
e.comm)
FROM emp e
WHERE e.deptno = d.deptno)
AS emplist_t))
FROM dept d;#1. I would strong recommend using the SQL/XML operators (XMLElement, XMLForest etc)to define your view, rather than creating SQL Types. We will be focusing future development on improving the performance and functionality of the SQL/XML operators, so these operators are now the preferred approach.
#2 Please post the XML document that is generated by teh view. I suspect that the XPATH expression does not match the generated docuemnt. -
Tool to create XML definition, a tool for creating XSD
I need a tool to create XML definition, a tool for creating XSD.
I was trying to do this with Oracle packages. But again there are some problems. Could you tell me which one, I should use?
Can I do it with the Oracle SQL Developer?Hello,
i get the error message and I don't know, what I can do
The user have the permissions to use DBMS_LOB package.
Is it the sofware, do I need a license version tool for XML generation
SQL> select DBMS_XMLSCHEMA.GENERATESCHEMA( 'HR', 'EMP_DATA' )
2 from dual;
select DBMS_XMLSCHEMA.GENERATESCHEMA( 'HR', 'EMP_DATA' )
ERROR at line 1:
ORA-00904: "DBMS_XMLSCHEMA"."GENERATESCHEMA": invalid identifier -
Hi all,
I'm trying to generate schema to custom type like:
CREATE OR REPLACE TYPE my_type AS OBJECT
(field1 number(1),
field2 varchar2(10));
CREATE OR REPLACE TYPE my_type_ct as table of my_type;
The select DBMS_XMLSCHEMA.GENERATESCHEMA(user,'MY_TYPE' ) from dual works fine, but by
select DBMS_XMLSCHEMA.GENERATESCHEMA(user,'MY_TYPE_CT' ) from dual -I'm getting ORA-19034.
What I'm missing?
Thanks a lot,
AlexHi,
GENERATESCHEMA works on scalar object types, so that the generated schema describes a single-rooted XML content (i.e. an XML document).
To make it work in your case, you'll have to create another object type containing the collection and build the schema from it. -
Generate + register xml schema
Hi,
I want to generate and register an xml schema based on the following object type :
CREATE TYPE STRAAT_T AS OBJECT
naam varchar2(50),
prv_cd number(1),
arr_cd number(1),
gem_cd number(3)
I ran the following pl/sql code :
begin
dbms_xmlschema.registerSchema(schemaURL=>'http://www.oracle.com/straat.xsd',
schemaDoc=>dbms_xmlschema.generateschema('TEST_RKW','STRAAT_T'));
end;
but got the following error code :
.ORA-31094: Incompatible SQL-type "STRAAT_T" for attribute of element "STRAAT_T".
What is wrong with this ???
tx for any help.Roger
Since the Type already exists you need to pass the value 'FALSE', as the fourth argument to registerSchema().
Eg
CREATE or replace TYPE STRAAT_T AS OBJECT
naam varchar2(50),
prv_cd number(1),
arr_cd number(1),
gem_cd number(3)
begin
dbms_xmlschema.registerSchema('http://www.oracle.com/straat.xsd', dbms_xmlschema.generateschema('SCOTT','STRAAT_T'),TRUE,FALSE);
end;
/ -
Hello,
I have some problems with dbms_xmlschema.registerschema
My database is: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
My XSD schema is (SEPA pain.002.001.03.xsd) also available on this url: http://code.google.com/p/leontestbed/source/browse/trunk/bc2/sample/Schema/pain.002.001.03.xsd?r=241
After
begin
DOK_XML_UTIL.p_vnesi_xsd_blob(401941242); -- store a XSD on file system from blob field
dbms_xmlschema.registerschema(
schemaurl => 'http://localhost/TEST1.XSD',
schemadoc => bfilename('ETAX_LOAD','TEST1.XSD'),
csid => nls_charset_id('AL32UTF8'));
commit;
end;I get:
ORA-31084: error while creating table "INIS_PROD"."Document2781_TAB" for element "Document"
ORA-02320: failure in creating storage table for nested table column "XMLDATA"."CstmrPmtStsRpt"."OrgnlPmtInfAndSts"
ORA-01792: maximum number of columns in a table or view is 1000
ORA-02310: exceeded maximum number of allowable columns in table
ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 37
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 65
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 136
ORA-06512: at line 4
What I'am doing wrong or what is the reason for this error..Arrgghhh.....
begin
DOK_XML_UTIL.p_vnesi_xsd_blob(401941242);
dbms_xmlschema.registerschema(
schemaurl => 'http://localhost/TEST1.XSD',
schemadoc => bfilename('ETAX_LOAD','TEST1.XSD'),
csid => nls_charset_id('AL32UTF8')
, local => true
, genTypes => false
, genTables => false);
commit;
end;sorry... -
Problems with the function DBMS_XMLSCHEMA.copyEvolve
I´m having problems with the evolution of xml-schema.
First the function DBMS_XMLSCHEMA.copyEvolve works correctly, but since one week I get only errors. Strangely is the fact that I use the same files (xml-schema, xslt and xml instances) and the same SQL-Code. Even if I delete all tables, directories, ... with the drop instruction and create them again, I get only error messages. It is also strangely that the function DBMS_XMLSCHEMA.copyEvolve not works if the old and new xml-schema are identical and no XSLT-Stylesheet is handed over. Can by the function DBMS_XMLSCHEMA.copyEvolve something going wrong in the database ? Do I must recreate the database, and how can I do that by the XE? But that can not be a good solution.
Has anybody a idea what can I do?
Here is my error report:
Error starting at line 1 in command:
BEGIN
DBMS_XMLSCHEMA.copyEvolve(
schemaURLs => xdb$string_list_t('http://localhost:8080/internal/xmlschema/testschema.xsd'),
newSchemas => XMLSequenceType(XDBURIType('/public/testschema_evolution.xsd').getXML()),
transforms => XMLSequenceType(XDBURIType('/public/MapTotestschema_evolution.xslt').getXML()));
END;
Error report:
ORA-30944: Fehler beim Rollback für XML-Schema "http://localhost:8080/internal/xmlschema/testschema.xsd" Tabelle "MYUSER"."XMLSCHEMATABELLE" Spalte ""
ORA-02304: Ungültiges Objektidentifizierungsliteral
ORA-30942: Fehler bei XML Schema Evolution für Schema "http://localhost:8080/internal/xmlschema/testschema.xsd" Tabelle <n/a> Spalte ""
ORA-31088: Objekt "MYUSER"."BIN$QNQjNoYiRfC4KlQtnfUpMw==$0" hängt von Schema ab
ORA-06512: in "XDB.DBMS_XMLSCHEMA_INT", Zeile 113
ORA-06512: in "XDB.DBMS_XMLSCHEMA", Zeile 210
ORA-06512: in Zeile 2
Thanks DavidCan you try doing the following before running copyEvolve
SQL> purge recyclebin
2 /
Recyclebin purged.
SQL> alter session set recyclebin = off
2 /
Session altered.
SQL>and see if it works as expected. -
Hi,
We upgraded our database from 8.1.6.3 to 9.2.0.3. In the recent version of database, I am unable to find DBMS_XMLSCHEMA package. What should I do?
Thanks,
JatinderCould you please recommend which document specifically should I look into to resolve this issue.
Thanks,
Jatinder -
Register XML schema using dbms_xmlschema in Oracle 11g
I have a xsd file located at C:\temp\test.xsd
I need to register this schema to create a XMLType table for Object Relational XML Storage.
How do I register the schema for relational storage?
I do not seem to find any example on internet for registering the schema for relational storage.
Any help would be highly appreciated.Thanks for help. The table is created now. But it created a CLOB table whereas I want a relational table with rows and columns. Is it because the schema was registered with SCHEMADOC as bfilename? How do I get the relational storage?
BEGIN
DBMS_XMLSCHEMA.registerSchema(
SCHEMAURL=> 'TESTDEPT.XSD',
SCHEMADOC=> bfilename('XML_DIR','TESTDEPT.XSD'),
LOCAL=> TRUE,
GENTYPES=> TRUE,
GENTABLES=> FALSE,
CSID=> nls_charset_id('AL32UTF8'));
END;
CREATE TABLE TESTDEPT OF XMLType
XMLTYPE store AS OBJECT RELATIONAL
XMLSCHEMA "TESTDEPT.XSD" ELEMENT "root";
desc TESTDEPT;
Name Null Type
SYS_NC_ROWINFO$ XMLTYPE()
SELECT dbms_metadata.get_ddl('TABLE','TESTDEPT') from dual;
DBMS_METADATA.GET_DDL('TABLE','TESTDEPT')
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(CLOB)
CREATE TABLE "DMUSER"."TESTDEPT" OF XMLTYPE
XMLSCHEMA "TESTDEPT.XSD" ELEMENT "root" ID 4090 PCTFREE 10 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 FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS"
My database version:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
Maybe you are looking for
-
Deleting all stock balances in IM and WM
Looking for some ideas on the topic of deleting all stock balances in a plant in both IM and WM for a project that is occurring currently. We plan on using transaction MB1C with a 562 movement type, we have configured our WM movement type to create a
-
Hi All, Under HGrid region, I create two items (messageStyledText) through Personalization and set its property. Both column appearing on page properly but when i try to reorder according to requirement, it is always displaying at end of the table. M
-
How to see full conent when using jdb
I am using jdb to debug some corruptted char array. When I dump one buffer object that contains char array, I can not view full content since it is too long. Is there a way I can save to this content to a file? Or is there another way to look at full
-
IPhoto 6 Rebuilding Thumbnails
I recently upgraded from iPhoto 5 to 6, and since then, 3 times in the past week iPhoto has told me that it needs to rebuild my thumbnails. This takes about 10 minutes, so it's really getting on my nerves. Is anyone else having this problem or know h
-
i need a new serial number