DBMS_XMLSAVE + Oracle XE 10.2
The official documentation of the Oracle XE 10.2 ( http://download.oracle.com/docs/cd/B25329_01/doc/appdev.102/b25108.pdf ) at the page 149 indicated that this version supports Oracle packages DBMS_XMLSAVE and DBMS_XMLQUERY, but I haven't those packages. Is this a mistake in the documentation or how can I install these packages?
Hello,
Check following document on metalink
Doc ID: 6952870.8 see if this resolves your problem (bug related).
Regards
Similar Messages
-
Update the passed XML in a PL/SQL procedure and then use DBMS_XMLSAVE
hi folks,
This is a great forum and most of you guys were awesome in replying to complex queries........
I have a small issue, I am trying to do a bulk insert from my application by constructing an XML result set and pass that XML to the SP as a CLOB and using DBMS_XMLSAVE package to insert it to the oracle table. It works like a charm for me when this is as straight forward as this. But when my requirement is, I need to generate sequence numbers for a particular column (Primary key column), while for other columns I pass values from the UI (as a XML object which my SP accepts as a CLOB), i am at a loss for solution to achieve this. It would mean, that I have to generate the sequence numbers for each row and then update this value to the passed XML clob. Any indicators on how to achieve this?
I found this solution at one of the thread which might most probably help me,
declare
2 l_cnt number;
3 begin
4 select count(*) into l_cnt from books,xmltable('/Books/Book' passing object_value);
5 for i in 1..l_cnt loop
6 update books set object_value =
7 updatexml(object_value,'/Books/Book['||i||']/BookID', xmlelement("BookID",sequence_bookid.nextval))
8 where existsnode(object_value,'/Books/Book['||i||']')=1;
9 end loop;
10 end;
11 /
But here, they are trying to update a XMLTable book, but in my case the XML is a clob object and not a XML table. Will this solution work for my case as well? Please provide any pointers to me... Thanks...First if your version of Oracle has DBMS_XMLSTORE, use that instead.
Reason: {thread:id=876376} (See Marco's response).
It is possible you could run into issues, but you should start with DBMS_XMLSTORE.
Since you will have the XML in the SP, treat the data as an XMLType instead of a CLOB for as long as you can since you need to do UpdateXML on it.
For your sample PL/SQL code, lines 4-5 are replaced with the WHILE loop shown in Method 2 at
{message:id=3610259}.
The UPDATE would be replaced with the following pseudocode
SELECT UPDATEXML(<l_xmltype_variable>, ...)
INTO <l_xmltype_variable>
FROM dual;
Once your loop is done, l_xmltype_variable would contain your updated XML and then you can use that XMLType directly on the call to DBMS_XMLSTORE or convert it back to a clob via
l_clob_variable := l_xmltype_variable.getClobVal(); -
DBMS_XMLSave issues with different databases
This is a brainteaser...
I have set up a couple of stored procedures in a package that inser / update and delete values in a database table using the DBMS_XMLSave functions as per the article 'Using XML-SQL Utility (XSU), 24 of 26' and re-use the context handle.
This is being used for an ASP application and as such I am using the Oracle 8.1.7 OLEDb provider and passing the XML string as a clob to the stored procedures using a command object.
I am now moving the application to another database in preparation for it going to staging and have come across a very interesting error. On the old database everything worked correctly, though on this new database (same IIS server) when i try to insert, update or delete on any table using the XML functions i get the following error:
Unable to insert the details. SQL ERROR:[ORA-29532: Java call terminated by uncaught Java exception: oracle.xml.sql.OracleXMLSQLException: Expected name instead of ??.]
Using the same ASP i connected to the old database and successfully ran the page, i change it to the new database and get the above error.
However I can successfully execute the stored procedure from a command prompt (TOAD) on the new database.
I have done some digging and found that it might have something to do with the NLS settings in the database.
if i change the NLS registry key (HKEY_LOCAL_MACHINE\Software\Oracle\HOME0\NLS_LANG) from AMERICAN_AMERICA.WE8ISO8859P1 to AMERICAN_AMERICA.UTF8 on the IIS server i am running my ASP from, i can get both to return the same error though the question marks turn upside down.
Here's an example of the sample code i am using. Note how i have to convert a CLOB to a string and back to a CLOB. This was because originally Oracle would not accept CLOBS from ASP (as the createParameter method did not really have a clob datatype but did have a longvarchar though Oracle recognises it as a clob because i can do clob operations on it. If anyone has an idea to get around this could you tell me as well?)
Here's a snippit of the package i use
saveCtx := DBMS_XMLSave.newContext('USER_FAVOURITE'); -- create the context once..!
DBMS_XMLSave.setKeyColumn(saveCtx, 'FAVOURITE_ID'); -- set the key column name.
PROCEDURE insert_XML(
o_result OUT NUMBER,
o_result_msg OUT VARCHAR2,
xmlDoc in clob
) is
e_processing_error EXCEPTION;
v_processing_msg VARCHAR2(1990);
v_result_msg VARCHAR2(1990);
insXML CLOB;
BEGIN
-- Create a temp LOB as an input parameter
DBMS_LOB.CREATETEMPORARY(insXML,TRUE);
-- Write the XML doc to the LOB
DBMS_LOB.WRITE(insXML, DBMS_LOB.GETLENGTH(xmlDoc), 1, DBMS_LOB.SUBSTR(xmlDoc, 32767));
rows := DBMS_XMLSave.insertXML(saveCtx, insXML);
-- Free the LOB space in memory
DBMS_LOB.FREETEMPORARY(insXML);
END;XSU don't suppose to support databases other than Oracle.
-
Error While Loading XMl Doc into Oracle Database 10g
Hi all,
I have a task that , I have to make a utillity by which we can load XML Doc into a Table. While searching on Internet i found following Procedure on ASK Tom
CREATE OR REPLACE
procedure insert_xml_emps(
p_directory in varchar2, p_filename in varchar2, vtableName in varchar2 )
as
v_filelocator bfile;
v_cloblocator clob;
l_ctx dbms_xmlsave.ctxType;
l_rows number;
begin
dbms_lob.createtemporary(v_cloblocator,true);
v_filelocator := bfilename(p_directory, p_filename);
dbms_lob.open(v_filelocator, dbms_lob.file_readonly);
DBMS_LOB.LOADFROMFILE(v_cloblocator, v_filelocator,
dbms_lob.getlength(v_filelocator));
l_ctx := dbms_xmlsave.newContext(vTableName);
l_rows := dbms_xmlsave.insertxml(l_ctx,v_cloblocator);
dbms_xmlsave.closeContext(l_ctx);
dbms_output.put_line(l_rows || ' rows inserted...');
dbms_lob.close(v_filelocator);
DBMS_LOB.FREETEMPORARY(v_cloblocator);
end ;
when i try to run this procedure
BEGIN
insert_xml_emps('XML_LOAD','load.xml','IBSCOLYTD');
END;
it gaves me following Error
ORA-29532: java call terminated by uncaught java exception : Oracle.xml.sql.OracleXMLSQLException:No
rows to modify-- the row enclosing tag missing. Specify the correct row enclosing tag.
ORA-06512: at "SYS.DBMS_XMLSAVE", line 115
ORA-06512: at "EXT_TEST.INSERT_XML_EMPS", line 18
ORA-06512: at line 2
Can anyone describe me this error
Thanks.
Best Regards.SQL> /* Creating Your table */
SQL> CREATE TABLE IBSCOLYTD
2 (
3 ACTNOI VARCHAR2 (8),
4 MEMONOI NUMBER (7,0),
5 MEMODTEI DATE,
6 AMOUNTI NUMBER (8,0),
7 BRCDSI NUMBER (4,0),
8 TYPEI NUMBER (4,0),
9 TRANSMONI NUMBER (6,0)
10 );
Table created.
SQL> CREATE OR REPLACE PROCEDURE insert_xml_emps(p_directory in varchar2,
2 p_filename in varchar2,
3 vtableName in varchar2) as
4 v_filelocator BFILE;
5 v_cloblocator CLOB;
6 l_ctx DBMS_XMLSTORE.CTXTYPE;
7 l_rows NUMBER;
8 v_amount_to_load NUMBER;
9 dest_offset NUMBER := 1;
10 src_offset NUMBER := 1;
11 lang_context NUMBER := DBMS_LOB.DEFAULT_LANG_CTX;
12 warning NUMBER;
13 BEGIN
14 dbms_lob.createtemporary(v_cloblocator, true);
15 v_filelocator := bfilename(p_directory, p_filename);
16 dbms_lob.open(v_filelocator, dbms_lob.file_readonly);
17 v_amount_to_load := DBMS_LOB.getlength(v_filelocator);
18 --- ***This line is changed*** ---
19 DBMS_LOB.LOADCLOBFROMFILE(v_cloblocator,
20 v_filelocator,
21 v_amount_to_load,
22 dest_offset,
23 src_offset,
24 0,
25 lang_context,
26 warning);
27
28 l_ctx := DBMS_XMLSTORE.newContext(vTableName);
29 DBMS_XMLSTORE.setRowTag(l_ctx, 'ROWSET');
30 DBMS_XMLSTORE.setRowTag(l_ctx, 'IBSCOLYTD');
31 -- clear the update settings
32 DBMS_XMLStore.clearUpdateColumnList(l_ctx);
33 -- set the columns to be updated as a list of values
34 DBMS_XMLStore.setUpdateColumn(l_ctx, 'ACTNOI');
35 DBMS_XMLStore.setUpdateColumn(l_ctx, 'MEMONOI');
36 DBMS_XMLStore.setUpdatecolumn(l_ctx, 'MEMODTEI');
37 DBMS_XMLStore.setUpdatecolumn(l_ctx, 'AMOUNTI');
38 DBMS_XMLStore.setUpdatecolumn(l_ctx, 'BRCDSI');
39 DBMS_XMLStore.setUpdatecolumn(l_ctx, 'TYPEI');
40 DBMS_XMLStore.setUpdatecolumn(l_ctx, 'TRANSMONI');
41 -- Now insert the doc.
42 l_rows := DBMS_XMLSTORE.insertxml(l_ctx, v_cloblocator);
43 DBMS_XMLSTORE.closeContext(l_ctx);
44 dbms_output.put_line(l_rows || ' rows inserted...');
45 dbms_lob.close(v_filelocator);
46 DBMS_LOB.FREETEMPORARY(v_cloblocator);
47 END;
48 /
Procedure created.
SQL> BEGIN
2 insert_xml_emps('TEST_DIR','load.xml','IBSCOLYTD');
3 END;
4 /
PL/SQL procedure successfully completed.
SQL> SELECT * FROM ibscolytd;
ACTNOI MEMONOI MEMODTEI AMOUNTI BRCDSI TYPEI TRANSMONI
28004125 251942 05-SEP-92 400 513 1 0
28004125 251943 04-OCT-92 400 513 1 0
SQL> -
Oracle 9i R2 XML-XSLT Conversion: Best Approach?
Hello Folks,
I have an architectural design question that is based on the cabilities of the Oracle XMLTYPE datatype and functionality in the 9i Release 2 database. For the upgrade-focussed crowd out there, the company I'm working for are currently working on an 11G migration, but timescales are not going to allow this version of the database to be used on the project I'm working on.
Broadly speaking, this is what I know how to accomplish in 9i Release 2 at this point in time (with my present knowledge):
1. Convert an XML file - stored as a CLOB in the database - into an XMLTYPE object within PL/SQL.
2. Use an XSL stylesheet in CLOB form, combined with the XMLTYPE.TRANSFORM functionality in PL/SQL, to convert the originating XML file's format into Oracle's 'Canonical' (<ROWSET>.....</ROWSET>) XML format.
3. Insert the Canonical Format XML into a standard Relational Table using the DBMS_XMLSAVE functionality.
I can make all the above work. However, the obvious configuration design would rely on storing the XSL Stylesheets in CLOB form in a database table. Whilst I'm confident this would work okay, I want to be sure I've not overlooked a better and more practical way to reference Stylesheets and perform this kind of operation at database level.
There is just so much documentation available on the 9i R2 XML functionality, that the mind boggles trying to digest it all. There seem to be multiple and differing approaches to producing the kind of outcome I've just described. What I'm trying to investigate is if there is a "Best Practice" approach I should be considering?
If anybody can pass on any suggested approaches from their experience, or recommend a good book or reference source that isn't an Oracle Manual (I've already read those), then that would be great.
Thanks in advance for any help or suggestions.
JamesHere is a temporary workaround for the problem...
SQL> SELECT value(p).transform
2 (
3 dburiType('/SCOTT/STYLESHEET_TAB/ROW[ID = "1"]/SHEET/text()').getXML()
4 ).getClobVal() AS result
5 FROM nations p
6 /
RESULT
3333 -
Error while using dbms_xmlsave.UpdateXML and dbms_xmlsave.insertXML
The Record I am trying to insert/update has the following structure
<ROWSET>
<ROW>
<COL1>123</COL1>
</ROW>
</ROWSET>
Table structure is as below
COL1 INT [Primary constraint]
COL2 VARCHAR2(100) NOT NULL [but has default value of 'COL2_Default']
Now since the XML doesn't have the entry for COL2, I am explicitly setting the columns to be updated/inserted using dbms_xmlsave.setUpdateColumn.
I use the logic the following logic to insert/update the table
-- set the primary key column name. This forms the where clause for update statement
dbms_xmlsave.setkeycolumn(l_Context , 'COL1');
-- cXML have the XML structure mentioned above
l_rows := dbms_xmlsave.updateXML(l_Context, cXML);
IF l_rows <= 0 THEN -- which means no rows found for update
l_rows := dbms_xmlsave.insertXML(l_Context, cXML);
END IF;
Now when the excution of dbms_xmlsave.updateXML happens Java Runtime Error is thrown.
ORA-29532: Java call terminated by uncaught Java exception: oracle.xml.sql.OracleXMLSQLException: 'java.sql.SQLException: Missing IN or OUT parameter at index:: 5' encountered during processing ROW element 0. All prior XML row changes were rolled back. in the XML document.
The version of oracle I am using is 9.2.0.6.0.
Please let me know if anyone has any idea on this error.Found maybe an applicable reference...
On http://publib.boulder.ibm.com/infocenter/wasinfo/v4r0/index.jsp?topic=/com.ibm.support.was.doc/html/Java_2_Connectivity_(J2C)/1163246.html
it says:
* Application code is missing a setXXX method call somewhere.
* There might be a problem in the Oracle JDBC driver code.
If the latter is the problem than you should or try a different JDBC driver or (which is probably the best solution anyway) create an iTar with Oracle support via metalink.oracle.com
Other references can also be found on the internet when using google which could be applicable. Search on keywords: "Missing IN or OUT parameter at index"
Message was edited by:
mgralike -
Error when using DBMS_XMLSave package
Hi,
I am a novice at XML technology. And although I have picked up on the basics, please do bear with my questions. My requirement is that we are receiving XML files in a particular format (as below), which I need to load into Oracle tables.
<?xml version="1.0"?>
<Root_Element>
<Examinee>
<MACode>A</MACode>
<TestingJID>TN</TestingJID>
<ExamineeID>100001</ExamineeID>
<CreateDate>20020221</CreateDate>
<Demographic>
<InfoDate>20020221</InfoDate>
<FirstTime>1</FirstTime>
<LastName>JANE</LastName>
<FirstName>DOE</FirstName>
<MiddleInitial>C</MiddleInitial>
<LithoNumber>73</LithoNumber>
<IdType>1</IdType>
<IdNumber>30738</IdNumber>
<DOB>19630525</DOB>
<EthnicCode>1</EthnicCode>
<GenderCode>2</GenderCode>
<MilitaryCode/>
<MSCode/>
<RFT01>1</RFT01>
<RFT02></RFT02>
<RFT03></RFT03>
<RFT17></RFT17>
<StreetAddress>SomeAddress</StreetAddress>
<City>SomeCity</City>
<StateCode>TN</StateCode>
<ZipCode>37000</ZipCode>
<EdLevel>8</EdLevel>
<SU01> </SU01>
<SU02> </SU02>
<SU03> </SU03>
<SU04> </SU04>
<TestCenterCode>34</TestCenterCode>
<PassStatus>1</PassStatus>
<CompleteStatus>1</CompleteStatus>
<CompleteDate>20020221</CompleteDate>
<TotStdScore>268</TotStdScore>
<AvgStdScore>53.6</AvgStdScore>
<CredJID>TN</CredJID>
<CredStatus>1</CredStatus>
<CredNbr>100001</CredNbr>
<CredDate>20020310</CredDate>
</Demographic>
<Test>
<TestDate>20020221</TestDate>
<TestNbr>1</TestNbr>
<SrlNbr>13773784</SrlNbr>
<Fmt>3</Fmt>
<Frm>23</Frm>
<Raw>47</Raw>
<Top>10</Top>
<RN1>30</RN1>
<RN2>35</RN2>
<RN3></RN3>
<RS1>4</RS1>
<RS2>4</RS2>
<RS3></RS3>
<ESY>8</ESY>
<Std>58</Std>
<Rnk>81</Rnk>
<FErr>0</FErr>
<EErr>0</EErr>
<MErr>0</MErr>
<JErr>0</JErr>
<AErr>0</AErr>
<QErr>0</QErr>
<Best>1</Best>
<Inactive>0</Inactive>
<Response>4,4,4,2,2,5,1,1,2,4,5,5,5,1,3,1,5,4,1,1,5,3,1,3,5,4,4,4,4,3,1,4,1,1,3,4,2,4,4,3,1,1,4,5,4,3,1,2,4,1, , , , , </Response>
</Test>
<Test>
<TestDate>20020221</TestDate>
<TestNbr>2</TestNbr>
<SrlNbr>13773784</SrlNbr>
<Fmt>3</Fmt>
<Frm>23</Frm>
<Raw>46</Raw>
<Std>53</Std>
<Rnk>67</Rnk>
<FErr>0</FErr>
<EErr>0</EErr>
<MErr>0</MErr>
<JErr>0</JErr>
<AErr>0</AErr>
<QErr>0</QErr>
<Best>1</Best>
<Inactive>0</Inactive>
<Response>5,3,5,3,2,4,3,4,3,3,2,4,3,2,2,3,2,2,2,3,1,4,3,5,4,3,1,1,2,1,2,4,5,5,2,5,4,5,4,1,3,2,1,4,1,3,2,4,2,1,1,1,4,4,5,2,3,2,1, , , , , </Response>
</Test>
</Examinee>
</Root_Element>
We will be creating new tables, so taking into account the nested structures we decided to go the object-relational route. The "Examinee" is on the higher level with a single "Demographic" and multiple "Test" under it. This is what we have created.
create or replace type DEMOGRAPHIC_TY as object (
InfoDate VARCHAR2(50),
FirstTime VARCHAR2(50),
LastName VARCHAR2(50),
FirstName VARCHAR2(50),
MiddleInitial VARCHAR2(50),
LithoNumber VARCHAR2(50),
IdType VARCHAR2(50),
IdNumber VARCHAR2(50),
DOB VARCHAR2(50),
EthnicCode VARCHAR2(50),
GenderCode VARCHAR2(50),
MilitaryCode VARCHAR2(50),
MSCode VARCHAR2(50),
RFT01 VARCHAR2(50),
RFT02 VARCHAR2(50),
RFT03 VARCHAR2(50),
RFT17 VARCHAR2(50),
StreetAddress VARCHAR2(50),
City VARCHAR2(50),
StateCode VARCHAR2(50),
ZipCode VARCHAR2(50),
EdLevel VARCHAR2(50),
SU01 VARCHAR2(50),
SU02 VARCHAR2(50),
SU03 VARCHAR2(50),
SU04 VARCHAR2(50),
TestCenterCode VARCHAR2(50),
PassStatus VARCHAR2(50),
CompleteStatus VARCHAR2(50),
CompleteDate VARCHAR2(50),
TotStdScore VARCHAR2(50),
AvgStdScore VARCHAR2(50),
CredJID VARCHAR2(50),
CredStatus VARCHAR2(50),
CredDate VARCHAR2(50),
CredNbr VARCHAR2(50));
create or replace type TEST_TY as object (
TestDate VARCHAR2(50),
TestNbr VARCHAR2(50),
SrlNbr VARCHAR2(50),
Fmt VARCHAR2(50),
Frm VARCHAR2(50),
"Raw" VARCHAR2(50),
Top VARCHAR2(50),
RN1 VARCHAR2(50),
RN2 VARCHAR2(50),
RN3 VARCHAR2(50),
RS1 VARCHAR2(50),
RS2 VARCHAR2(50),
RS3 VARCHAR2(50),
ESY VARCHAR2(50),
Std VARCHAR2(50),
Rnk VARCHAR2(50),
FErr VARCHAR2(50),
EErr VARCHAR2(50),
MErr VARCHAR2(50),
JErr VARCHAR2(50),
AErr VARCHAR2(50),
QErr VARCHAR2(50),
Best VARCHAR2(50),
Inactive VARCHAR2(50),
Response VARCHAR2(100));
create or replace type TEST_NT as table of TEST_TY;
create table EXAMINEE (
MACode VARCHAR2(50),
TestingJID VARCHAR2(50),
ExamineeID VARCHAR2(50),
CreateDate VARCHAR2(50),
Demographic DEMOGRAPHIC_TY,
Test TEST_NT)
nested table Test store as Test
CREATE DIRECTORY XML_DIR AS 'C:\TestXML';
CREATE TABLE XML_TEMP (key NUMBER, f_lob BFILE);
INSERT INTO XML_TEMP VALUES (1,BFILENAME('XML_DIR','M01.XML'));
And this is the procedure,
CREATE OR REPLACE PROCEDURE loadxml AS
insCtx sys.DBMS_XMLSave.ctxType;
rows number;
fil BFILE;
buffer RAW(32767);
len INTEGER;
insrow INTEGER;
BEGIN
SELECT f_lob INTO fil FROM xml_temp WHERE key = 1;
DBMS_LOB.FILEOPEN(fil,DBMS_LOB.FILE_READONLY);
len := DBMS_LOB.GETLENGTH(fil);
DBMS_LOB.READ(fil,len,1,buffer);
insCtx := sys.DBMS_XMLSave.newContext('examinee'); -- get the context handle
rows := sys.DBMS_XMLSave.insertXML(insCtx,buffer); -- this inserts the document
sys.DBMS_XMLSave.closeContext(insCtx); -- this closes the handle
IF DBMS_LOB.FILEISOPEN(fil) = 1 THEN
DBMS_LOB.FILECLOSE(fil);
END IF;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('In Exception');
DBMS_OUTPUT.PUT_LINE(SQLERRM(SQLCODE));
IF DBMS_LOB.FILEISOPEN(fil) = 1 THEN
DBMS_LOB.FILECLOSE(fil);
END IF;
end;
And when I execute this, it gives an error,
In Exception
ORA-29532: Java call terminated by uncaught Java exception: oracle.xml.sql.OracleXMLSQLException: Start of root element expected.
I have tried to follow the XML Developer Guide as much possible, but might be missing something.
H E L P !!!!
Thanks.When I try the describe, it says object not found. If I go into OEM, I don't see that package either. Again, I didn't create that database, but I thought the XML DB stuff was installed by default with the database. Is there a way to add that package after the database is created?
Thanks,
Andrew -
Error while using DBMS_XMLSave package...
Hi All,
I am using DBMS_XMLSave package and when I try to execute the following code, it is giving me error "Java call terminated by uncaught Java exception:"
I am executing following code ....
declare
insCtx DBMS_XMLSave.ctxType;
begin
insCtx := DBMS_XMLSave.newContext('scott.emp');
end;
I am getting following error ...
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
java.lang.ExceptionInInitializerError
ORA-06512: at "SYS.DBMS_XMLSAVE"
ORA-06512: at line
Please help me to overcome the problem....
Thanx in advance ,
YogeshFound maybe an applicable reference...
On http://publib.boulder.ibm.com/infocenter/wasinfo/v4r0/index.jsp?topic=/com.ibm.support.was.doc/html/Java_2_Connectivity_(J2C)/1163246.html
it says:
* Application code is missing a setXXX method call somewhere.
* There might be a problem in the Oracle JDBC driver code.
If the latter is the problem than you should or try a different JDBC driver or (which is probably the best solution anyway) create an iTar with Oracle support via metalink.oracle.com
Other references can also be found on the internet when using google which could be applicable. Search on keywords: "Missing IN or OUT parameter at index"
Message was edited by:
mgralike -
Errors installing XDK 9.2.0.1.0 on Oracle 9i - please help !
I am pulling my hair out ...
I am trying to install the XDK into a 9i database.
I have granted JAVAUSERPRIV and JAVASYSPRIV to user SYSTEM
I unzipped the XDK into my 9i Oracle home.
I run a DOS window and CD to oracle_home\bin
I type xdkload -u "system/manager@pcinp" -s
the script runs but falls over with errors and when it does the select at the end it has the error :
SQL> Rem Use these to test the results..
SQL> select dbms_xmlquery.getxml('select * from dual', 2) from dual;
ERROR:
ORA-29541: class SYSTEM.oracle/xml/sql/query/OracleXMLStaticQuery could not be
resolved
ORA-06512: at "SYSTEM.DBMS_XMLQUERY", line 19
ORA-06512: at "SYSTEM.DBMS_XMLQUERY", line 271
ORA-06512: at line 1
I wrote a script to recompile any invalid classes but they don;t want to recompile - here they are :
ALTER java class "/109a284b_OracleXMLStaticQuery" resolve;
ALTER java class "/12249373_OracleXMLStaticQuery" resolve;
ALTER java class "/1f249eae_OracleADTName" resolve;
ALTER java class "/20f12cf_OracleXMLSQLException" resolve;
ALTER java class "/233ebe61_OracleXMLDocGenStrin" resolve;
ALTER java class "/23714d96_OracleXMLDataSetGenJ" resolve;
ALTER java class "/2d1ca5dd_OracleXMLDataSetExtJ" resolve;
ALTER java class "/3ad949fd_OracleXMLUtil" resolve;
ALTER java class "/3ce8c9fc_OracleXMLSave" resolve;
ALTER java class "/3f8bf704_OracleCollectionName" resolve;
ALTER java class "/41ef4922_OracleCursorName" resolve;
ALTER java class "/482ed896_OracleXMLSQLNoRowsEx" resolve;
ALTER java class "/4e2d263c_OracleXMLDocGenDOM" resolve;
ALTER java class "/52bed193_OracleXMLQuery" resolve;
ALTER java class "/5c4b55ba_OracleXMLStaticSave" resolve;
ALTER java class "/61dfe75e_OracleXMLConvert" resolve;
ALTER java class "/6caec517_OracleScalarName" resolve;
ALTER java class "/72f0508e_OracleXMLDocGenLob" resolve;
ALTER java class "/7e1f2f8f_OracleXMLStaticSaveS" resolve;
ALTER java class "/9001dfa7_OracleColumnName" resolve;
ALTER java class "/964b85ec_XSUXSchemaHandler" resolve;
ALTER java class "/a152eb84_OracleXMLDataSet" resolve;
ALTER java class "/b293975_OracleXMLDocGenDOMFra" resolve;
ALTER java class "/c33162ba_OracleXMLStaticQuery" resolve;
ALTER java class "/c499402b_OracleXMLDocGenSAX" resolve;
ALTER java class "/ed58df4e_OracleXMLDataSetJdbc" resolve;
ALTER java class "/f57715f1_OracleXMLStaticSaveM" resolve;
ALTER java class "OracleXMLStore" resolve;
I have spent a day on Metalink trying to sort this out but I am getting nowhere - does anyone have any idea on what is going wrong ? Before I installed I ran the XMLDROP command and manually drop the other packages :
drop package dbms_xmlquery;
drop package dbms_xmlsave;
drop package xmlgen;
drop public synonym dbms_xmlquery;
drop public synonym dbms_xmlsave;
drop public synonym xmlgen;
and manually removed these JAR files thru dropjava:
xschema, xsu12, classgen, xmlplsql,xmlparserv2
Please help !!!!!Look for the tip in this message:
Re: ArrayOfStruct Issues
Best regards, Marcelo. -
Best method to load XML data into Oracle
Hi,
I have to load XML data into Oracle tables. I tried using different options and have run into a dead end in each of those. I do not have knowledge of java and hence have restricted myself to PL/SQL solutions. I tried the following options.
1. Using DBMS_XMLSave package : Expects the ROWSET and ROW tags. Connot change format of the incoming XML file (Gives error oracle.xml.sql.OracleXMLSQLException: Start of root element expected).
2. Using the XMLPARSER and XMLDOM PL/SQL APIs : Works fine for small files. Run into memory problems for large files (Gives error java.lang.OutOfMemoryError). Have tried increasing the JAVA_POOL_SIZE but does not work. I am not sure whether I am changing the correct parameter.
I have read that the SAX API does not hog memory resources since it does not build the entire DOM tree structure. But the problem is that it does not have a PL/SQL implementation.
Can anyone PLEASE guide me in the right direction, as to the best way to achieve this through PL/SQL ??? I have not designed the tables so am flexible on using purely relational or object-relational design. Although would prefer to keep a purely relational design. (Had tried used object-relational for 1. and purely relational for 2. above)
The XML files are in the following format, (EXAMINEEs with single DEMOGRAPHIC and multiple TESTs)
<?xml version="1.0"?>
<Root_Element>
<Examinee>
<MACode>A</MACode>
<TestingJID>TN</TestingJID>
<ExamineeID>100001</ExamineeID>
<CreateDate>20020221</CreateDate>
<Demographic>
<InfoDate>20020221</InfoDate>
<FirstTime>1</FirstTime>
<LastName>JANE</LastName>
<FirstName>DOE</FirstName>
<MiddleInitial>C</MiddleInitial>
<LithoNumber>73</LithoNumber>
<StreetAddress>SomeAddress</StreetAddress>
<City>SomeCity</City>
<StateCode>TN</StateCode>
<ZipCode>37000</ZipCode>
<PassStatus>1</PassStatus>
</Demographic>
<Test>
<TestDate>20020221</TestDate>
<TestNbr>1</TestNbr>
<SrlNbr>13773784</SrlNbr>
</Test>
<Test>
<TestDate>20020221</TestDate>
<TestNbr>2</TestNbr>
<SrlNbr>13773784</SrlNbr>
</Test>
</Examinee>
</Root_Element>
Thanks for the help.Please refer to the XSU(XML SQL Utility) or TransX Utility(for Multi-language Document) if you want to load data in XML format into database.
Both of them require special XML formats, please first refer to the following docs:
http://otn.oracle.com/docs/tech/xml/xdk_java/doc_library/Production9i/doc/java/xsu/xsu_userguide.html
http://otn.oracle.com/docs/tech/xml/xdk_java/doc_library/Production9i/doc/java/transx/readme.html
You can use XSLT to transform your document to the required format.
If you document is large, you can use SAX method to insert data into database. But you need to write the code.
The following sample may be useful:
http://otn.oracle.com/tech/xml/xdk_sample/xdksample_040602i.html -
Using dbms_xmlsave.insertXML
Hi all,
I am reading an XML data which has similar structure to:
<dept>
<name> department name </name>
<loc> department location </loc>
<emp>
<fisrt> first name for first employee </first>
<last> last name for first employee </last>
</emp>
<emp>
<first> first name for second employee </first>
<last> last name for second employee </last>
</emp>
</dept>
I do not have control on the structure of the XML data as I am reading it from external source. Now I have created a table as follows:
SQL> create type emprec as object (
first varchar2(30),
last varchar2(30)
SQL> create type empreclist as table of emprec;
SQL> create table mydept (
name varchar2(30),
loc varchar2(50),
emp empreclist);
Now when I use the dbms_xmlsave.insertXML , the columns name,loc are populated but the column emp is not populated and i I define the emp column as (emprec) type, then only the last <emp></emp> data is inserted.
Any ideas how to read all the <emp></emp> data into the dept table ?Hi,
I have been trying for a while to get a nested collection loaded. The oracle documentation is no help. But what i did in the end is this. I built the object table, inserted the nested collection manual and then ran the command line XSU (documented in the app. dev. guide xml) to save the tabledata as XML (only one record) with the -withDTD switch. This creates a XML with inline DTD. Surprise surprise when you load that document it does work, even when you add more nested rows in the document. This XML file will also show you if you build the table correctly. It seems that XSU needs the DTD to be able to load nested collections.
If you are running windows the command line utility can be run like this
java -cp c:\oracle\ora81\rdbms\jlib\xsu12.jar;c:\oracle\ora81\lib\xmlparserv2.jar;c:\oracle\ora81\jdbc\lib\classes12.zip OracleXML getXML -user "username/password" -withDTD "select * from yourtable" >g:\xmlfiles\output.xml
have fun -
Error opening external DTD 'Segnatura.dtd' using dbms_xmlsave.insertXML
I've been trying to insert a document in a table. All works fine
if the xml doesn't contains the doctype element!
If I add the row
<!DOCTYPE Segnatura SYSTEM "Segnatura.dtd">
to my xml I get the error:
oracle.xml.sql.OracleXMLSQLException: Error opening external DTD
'Segnatura.dtd'.
If I specify all the path "file:///temp/Segnatura.dtd" the insert
works, but I don't want to do in that way beacause I don't want
to modify the original xml that i'm inserting!
In the package dbms_xmlsave I have no ways to change the
basedir/baseurl
or to setValidationMode to false like in xmlparser package.
Is there any way to solve this problem??
Thank's in advance
Mauro
This is an example scratch of my xml doc:
<?xml version = '1.0' encoding = 'ISO-8859-1'?>
<!DOCTYPE Segnatura SYSTEM "Segnatura.dtd">
<Segnatura versione="2001-05-07"
xmlns:xml="http://www.w3.org/XML/1998/namespace" xml:lang="it">
</Segnatura>Hy Steven, thank's for your attention.
I'm not using the xsql servlet.
I'm reading an xml file coming from the file system and I want to
import it in the db using a java stored proc.
I also have the dtd file (Segnatura.dtd) but I don't know where
to put in on the server.
If I run my java program and I put Segnatura.dtd in the execution
classpath on the program the xml is loaded fine.
If I load the stored proc in the db then I don't know where to
put the dtd. Do I have to put the directory containing the dtd in
the server classpath and the restart the db maibe?
thank's
mauro -
I am trying to save contents of xml file into database tables. I know I have to use dbms_xmlsave.insertxml, but it does not allow you to work with multiple tables, so I created a view to join 2 tables together. But when I try to insert into the view I get this error:
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
oracle.xml.sql.OracleXMLSQLException: Exception
'oracle.jdbc.driver.OracleSQLException:ORA-01732: data manipulation operation
not legal on this view
' encountered during processing ROW element 1All prior XML row changes were
rolled back. in the XML document.
ORA-06512: at "SYS.DBMS_XMLSAVE", line 91
ORA-06512: at line 31
My xmldatagram looks like this:
<?xml version = "1.0"?>
<warranty_claim>
<ROW>
<customer_claim_no>12345</customer_claim_no>
<claim_date>2003-SEP-24</claim_date>
<repair_shop_site_name>test supplier</repair_shop_site_name>
<failed_part_no>12345</failed_part_no>
<other_part>
<other_part_item>
<customer_claim_no>12345</customer_claim_no>
<part_no>54321</part_no>
<unit_price>10.2</unit_price>
<quantity>10</quantity>
<total_price>102</total_price>
</other_part_item>
<other_part_item>
<customer_claim_no>12345</customer_claim_no>
<part_no>98767</part_no>
<unit_price>20.2</unit_price>
<quantity>10</quantity>
<total_price>202</total_price>
</other_part_item>
</other_part>
</ROW>
</warranty_claim>
create or replace type ph_other_part as object(
customer_claim_no varchar2(100),
part_id number,
part_no varchar2(100),
description varchar2(100),
unit_price number,
quantity number,
total_price number,
part_failed varchar2(100))
create or replace type ph_othpart_tab as table of ph_other_part
create or replace view ph_wc_view
as select customer_claim_no,
claim_date,
repair_shop_site_name,
failed_part_no,
CAST(MULTISET(select customer_claim_no,
part_id,
part_no,
description,
unit_price,
quantity,
total_price,
part_failed
from ph_wc_part pwp
where pwp.customer_claim_no = pwc.customer_claim_no
) AS sys.ph_othpart_tab ) other_part
from ph_warranty_claim pwc
main script
declare
insCtx dbms_xmlsave.ctxType;
rowcount number:=0;
v_tablename varchar2(100):='ph_wc_view';
xmldoc clob;
errorNum number;
errorMsg varchar2(200);
begin
begin
select data
into xmldoc
from cic.cic_temp
where data_id = 2;
exception when others then
dbms_output.put_line('Error getting xmldoc. '||sqlerrm(sqlcode));
end;
insCtx := dbms_xmlsave.newcontext(v_tablename);
dbms_xmlsave.setIgnoreCase(insCtx,1);
dbms_xmlsave.clearupdatecolumnlist(insCtx);
dbms_xmlsave.setupdatecolumn(insCtx,'customer_claim_no');
dbms_xmlsave.setupdatecolumn(insCtx,'claim_date');
dbms_xmlsave.setupdatecolumn(insCtx,'repair_shop_site_name');
dbms_xmlsave.setupdatecolumn(insCtx,'failed_part_no');
dbms_xmlsave.setupdatecolumn(insCtx,'other_part');
rowcount := dbms_xmlsave.insertXML(insCtx,xmldoc);
dbms_xmlsave.closecontext(insCtx);
commit;
dbms_output.put_line('Rows inserted: '||rowcount);
end;Hi,
For your XML file I think you just need to enclose XML elemnts in ROWSET AND ROW TAGS - so xml should look like :
<ROWSET>
<ROW>
<DEPT>
</DEPT>
and just pass it as CLOB to dbms_xmlsave.insertXML proc.
I hope it should work.
I am also trying to insert XML file but with a bit complex structure having multiple nested elements.
I am not sure how to transform the external XML file to wrap it in ROWSET/ROW using XSLT. It's mandatory to use ROWSET/ROW tags to be able to insert in oracle tables. I am facing this problem right now. I am using object views to accomplish the purpose but still needs to figure out the way to apply stylesheet to incoming XML file.
If you come to know of any way, pls do let me know also.
Thanks -
DBMS_XMLQuery and DBMS_XMLSave package
I have Oracle 8.1.7
Where can I get DBMS_XMLQuery and DBMS_XMLSave package using samples
The Documentation I have doesn't contain any.I did what you asked, but still get the following error when running my statement to create xml from a sql statement.
SQL> @xml01
declare
ERROR at line 1:
ORA-29541: class SYS.oracle/xml/sql/query/OracleXMLStaticQuery could not be
resolved
ORA-06512: at "SYS.DBMS_XMLQUERY", line 46
ORA-06512: at line 7
Below is copy of the contents of catxsu.sql script.
call sys.dbms_java.loadjava ('-v -r -s -grant PUBLIC rdbms/jlib/xsu12.jar');
@@dbmsxsu.sql
@@xmlgen.sql
create public synonym dbms_xmlsave for dbms_xmlsave;
create public synonym dbms_xmlquery for dbms_xmlquery;
create public synonym xmlgen for xmlgen;
Below is output from catxsu.sql run this time.
SQL> @catxsu
Call completed.
Package created.
No errors.
Package body created.
No errors.
Grant succeeded.
Package created.
No errors.
Package body created.
No errors.
Grant succeeded.
Package created.
No errors.
Package body created.
No errors.
Grant succeeded.
create public synonym dbms_xmlsave for dbms_xmlsave
ERROR at line 1:
ORA-00955: name is already used by an existing object
create public synonym dbms_xmlquery for dbms_xmlquery
ERROR at line 1:
ORA-00955: name is already used by an existing object
create public synonym xmlgen for xmlgen
ERROR at line 1:
ORA-00955: name is already used by an existing object
SQL> exit
I appreciate your help. Any more ideas? This is working for me on another server and database, but not sure what the difference is with this one.
Thanks,
Tim Gerringer -
DBMS_XMLSave.insertXML Fails on decimal format
DBMS_XMLSave.insertXML Fails on decimal format
The following example fails when using collections of complex elements. The error is:
java.lang.NumberFormatException: 1.0'
Example is:
create table test_parent(p_id NUMBER(18),
test_col number(10))
alter table test_parent add constraint pk1 primary key(p_id)
create table test_child(t_id NUMBER(18),
test_col number(10),
p_id NUMBER(18))
alter table test_child add constraint pk2 primary key(t_id)
alter table test_child add constraint fk1 foreign key (p_id) references test_parent(p_id)
insert into test_parent values(1,1)
insert into test_child values(1,1,1)
insert into test_child values(2,2,1)
insert into test_child values(3,3,1)
create type test_c AS OBJECT (t_id NUMBER(18),test_col NUMBER(10));
CREATE OR REPLACE TYPE test_cs AS TABLE OF test_c
CREATE OR REPLACE VIEW test_view(parent_id,parent_num,child)
AS SELECT p.P_id,
p.test_col,
CAST(MULTISET(SELECT c.t_id,
c.test_col
FROM test_child c
WHERE p.p_id = c.p_id) AS test_cs) AS child
FROM test_parent P
CREATE OR REPLACE TRIGGER test_trig INSTEAD OF INSERT ON test_view
BEGIN
DBMS_OUTPUT.PUT_LINE('Trigger proccessing');
END;
SHOW ERRORS
DECLARE
insCtx DBMS_XMLSave.ctxType;
rows number;
xmlDoc CLOB := '<ROWSET>
<ROW>
<PARENT_ID>2.0</PARENT_ID>
<PARENT_NUM>2.0</PARENT_NUM>
<CHILD>
<T_ID>1.0</T_ID>
<TEST_COL>1.0</TEST_COL>
</CHILD>
</ROW>
</ROWSET>';
BEGIN
insCtx := DBMS_XMLSave.newContext('TEST_VIEW');
rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc);
DBMS_XMLSave.closeContext(insCtx);
END;
DECLARE
insCtx DBMS_XMLSave.ctxType;
rows number;
xmlDoc CLOB := '<?xml version="1.0"?>
<ROWSET>
<ROW>
<PARENT_ID>1</PARENT_ID>
<PARENT_NUM>1</PARENT_NUM>
<CHILD>
<TEST_C>
<T_ID>1.0</T_ID>
<TEST_COL>1</TEST_COL>
</TEST_C>
<TEST_C>
<T_ID>2</T_ID>
<TEST_COL>2</TEST_COL>
</TEST_C>
<TEST_C>
<T_ID>3</T_ID>
<TEST_COL>3</TEST_COL>
</TEST_C>
</CHILD>
</ROW>
</ROWSET>';
BEGIN
insCtx := DBMS_XMLSave.newContext('TEST_VIEW');
rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc);
DBMS_XMLSave.closeContext(insCtx);
END;If you have access to ON, check out document 119140.1.
Apparently it's a bug in the jdbc driver in pre-Oracle 8.1.7 databases...the workaround looks messy though.
Maybe you are looking for
-
BI Publisher Merge PDF and print documents through Java
We need our reports in merged and printed (collated). Is this possible with BI Publisher . If yes, how? The reports will be called from Java. So far I found the Web Service provided by BI Publisher handy in printing and creating reports but not combi
-
Hi, I have a report where i'm selecting values based on parameter entered by user. There are only 2 options e.g A or B. If A then select * where name = A or if B then select * where name != A basically select everything apart from A. Can anyone pleas
-
Settings that I make for the the Panel such as Size/Position and launchers are not saved after a reboot, also settings made for Xterm are not saved. I'm asuming these settings are simply saved in some file in my home directory? So I'm not sure what c
-
I just bought macbook air yesterday. Do I need to buy OS X Moutain Lion from App store?
Please becase I saw from app store there hv a osx lion. Do i need to buy it to my new macbook air?
-
I get the error when I reinstalled CS5.5. It shows "the installer failed to initialize". Then I downloaded Adobe Support Advisor but that didn't say anything was wrong. Also, I used Adobe Creative Suite Cleaner Tool to clear all the services installe