USING XSU TO BECOME XML
Hi to all,
I have a question using XSU to become XML.
I have the following query
query =""+
"SELECT "+
"anordnung.match as \"@MATCH\","+
"substr(datei,0,instr(datei,'/',-1)-1) as \"@PATH\", "+
"anordnung.rang as \"@RANG\" ,"+
"substr( "+
" substr( "+
" datei, "+
" 0, "+
" length(datei)-4 "+
" ), "+
" instr(substr( "+
" datei, "+
" 0, "+
" length(datei)-4 "+
" ),'/',-1)+1 "+
") ELEMENT "+
"FROM xsl_modul , anordnung "+
"WHERE "+
"xsl_modul.xsl_id = anordnung.xsl_id "+
"ORDER BY anordnung.match, anordnung.rang";
and the following settings:
qry.setRowsetTag("Anordnung"); // set the tags encapsulating the whole doc
qry.setRowTag("Modul");
I become the following result:
<ANORDNUNG>
<MODUL MATCH="amfcomm" PATH="/pifs/module/_standard" RANG="1">
<ELEMENT>region2</ELEMENT>
</MODUL>
<MODUL MATCH="amfcomm" PATH="/pifs/module/_standard" RANG="2">
<ELEMENT>header1</ELEMENT>
</MODUL>
<MODUL MATCH="amfcomm" PATH="/pifs/module/_standard" RANG="3">
<ELEMENT>text_a_b_c</ELEMENT>
</MODUL>
But I like to become the following result so that the XML-ELEMENT-->ELEMENT is the content of MODUL:
<MODUL MATCH="amfcomm" PATH="/pifs/module/_standard" RANG="1">
region2
</MODUL>
<MODUL MATCH="amfcomm" PATH="/pifs/module/_standard" RANG="2">
header1
</MODUL>
<MODUL MATCH="amfcomm" PATH="/pifs/module/_standard" RANG="3">
text_a_b_c
</MODUL>
HOW CAN I BECOME THIS?????
Thanks a lot.
Greetings from Frankfurt/Germany
Schoeib
You can also do this but it may fail on complex documents:
PS C:\scripts> $xml.computers.computerData
ip-Dir name
127.0.0.1 eth01
127.0.0.2 eth02
127.0.0.3 eth03
127.0.0.4 eth01
PS C:\scripts> $xml.computers.computerData.Name
eth01
eth02
eth03
eth01
PS C:\scripts> $xml.computers.computerData[2]
ip-Dir name
127.0.0.3 eth03
PS C:\scripts> $xml.computers.computerData[2].'ip-Dir'
127.0.0.3
You may also have to add namespace support.
¯\_(ツ)_/¯
Similar Messages
-
Using XSU for Storing XML data
Please how can I use the XSU API for storing XML documents in Oracle8i? I know part of the code to store a document but how do I import the XSU API?
Do I have to download it or use it via Oracle?
example:
String xmlDoc = "my_xml_document";
Connection conn = >>DriverManager.getConnection(...);
OracleXMLSave sav = new OracleXMLSave
(conn,"purchaseOrderTab");
sav.insertXML(xmlDoc);But how do I use OracleXMLSave? How do I import the XSU API?
thanks for your help
nullWhat is XSU? I think you question should be posted at the XML or XDK forum.
-
Generating XML with attributes using XSU
Oracle document claims if the sql is:
select empno as @empno from employee
Using XSU to generate XML will produce and XML document with EMPNO as an attribute instead of element name. But this does not seem to work. There is an exception:
<ERROR>oracle.xml.sql.OracleXMLSQLException: Character '&' is not allowed in an XML tag name.</ERROR
Is there anything wrong or is there a work aroundOracle document claims if the sql is:
select empno as @empno from employee
Using XSU to generate XML will produce and XML document with EMPNO as an attribute instead of element name. But this does not seem to work. There is an exception:
<ERROR>oracle.xml.sql.OracleXMLSQLException: Character '&' is not allowed in an XML tag name.</ERROR
Is there anything wrong or is there a work around -
Converting Oracle XML Query Result in Java String by using XSU
Hi,
I have a problem by converting Oracle XML Query Result in Java
String by using XSU. I use XSU for Java.
For example:
String datum=new OracleXMLQuery(conn,"Select max(ps.datum) from
preise ps where match='"+args[0]+"'");
String datum1=datum;
I become the following error:
Prototyp.java:47: Incompatible type for declaration. Can't
convert oracle.xml.sql.query.OracleXMLQuery to java.lang.String.
Can somebody tell me a method() for converting to solve my
problem??????
ThanksHmmm.. Pretty basic just look at the example:
OracleXMLQuery qry = new OracleXMLQuery(conn,"Select max(ps.datum) from preise ps where match='"+args[0]+"'");
String xmlString = qry.getXMLString();
Hi,
I have a problem by converting Oracle XML Query Result in Java
String by using XSU. I use XSU for Java.
For example:
String datum=new OracleXMLQuery(conn,"Select max(ps.datum) from
preise ps where match='"+args[0]+"'");
String datum1=datum;
I become the following error:
Prototyp.java:47: Incompatible type for declaration. Can't
convert oracle.xml.sql.query.OracleXMLQuery to java.lang.String.
Can somebody tell me a method() for converting to solve my
problem??????
Thanks -
Problem inserting value in CLOB column from an XML file using XSU
Hi,
When I try to insert CLOB value into Oracle9i database from an XML document using XSU, I get an exception as below.
09:37:32,392 ERROR [STDERR] oracle.xml.sql.OracleXMLSQLException: 'java.sql.SQLException: ORA-03237: Initial Extent of specified size cannot be allocated
ORA-06512: at "SYS.DBMS_LOB", line 395
ORA-06512: at line 1
' encountered during processing ROW element 0. All prior XML row changes were rolled back. in the XML document.
All Element tags in XML doc. is mapped to columns in the database. One of the table columns is CLOB. That is the one that gives the above exception. Here is the xml...
ID - is autogenerated value.
<?xml version="1.0" ?>
<ROWSET>
<ROW num="1">
<ID></ID>
<SEQ>
GCATAGTTGTTATGAAGAAATGGAAGAAAAATGCACTCAAAGTTGGGCTGTCAGGCTGTCTGGGGCTGAATTCTGGTGTGACAGTGTGATGAAGCCATCTTTGAGCCTAAATTTGATAATGAGCCAGTCATGATCTGGTTGTGATTACTATAACAAGATTAAATCTGAATAAGAGAGCCACAACTTCTTTAAAGACAGATTGTCAAGTCATTACATGGAAGAGGGAGATTGCTCCTTTGTAAATCAGGCTGTCAGGCCAACTGAATGAAGGACGTCATTGTACAGTAACCTGATGAAGATCAGATCAACCGCTCACCTCGCCG
</SEQ>
</ROW>
</ROWSET>
Can anyone identify what's the problem.. and suggest a solution for this..?
Thanks in advance..
VijiWould you please specify the XDK verison and database version?
-
How to apply XSLT to XML file while importing XML data using XSU plsql API
I need to load XML file with nested repeating elements into Oracle tables and I am using XSU PLSQL API utility package dbms_xmlSave.insertXML. Can use XMLGen package also!!
I found out through documentation that I need to have XML file with ROWSET/ROW tags around the elements. As I have no control of XML file coming from external source, so I wish to apply XSLT to XML. I found setXSLT/setStylesheet procedures but it's not working as expected.
Can you help me with some sample code for the purpose.
ThanksI'm new at XML and XSL as well, but maybe the following code I built can help:
CREATE OR REPLACE PACKAGE Xml_Pkg AS
/* this record and table type are used for the transformTags procedure */
TYPE TagTransform_t IS RECORD (
old_tag VARCHAR2(255),
new_tag VARCHAR2(255) );
TYPE TagTransformList_t IS TABLE OF TagTransform_t INDEX BY BINARY_INTEGER;
/* use DBMS_OUTPUT to print out a CLOB */
PROCEDURE printClobOut(p_clob IN OUT NOCOPY CLOB);
/* using a list of old/new tags, transform all old into new in XML2 */
PROCEDURE transformTags(
p_List TagTransformList_t,
p_XML1 IN OUT NOCOPY CLOB,
p_XML2 IN OUT NOCOPY CLOB);
END Xml_Pkg;
CREATE OR REPLACE PACKAGE BODY Xml_Pkg AS
/* print a CLOB using newlines */
PROCEDURE printClobOut(p_clob IN OUT NOCOPY CLOB) IS
buffer_overflow EXCEPTION;
PRAGMA EXCEPTION_INIT(buffer_overflow,-20000);
l_offset NUMBER;
l_len NUMBER;
l_o_buf VARCHAR2(255);
l_amount NUMBER; --}
l_f_amt NUMBER := 0; --}To hold the amount of data
l_f_amt2 NUMBER; --}to be read or that has been
l_amt2 NUMBER := -1; --}read
l_offset2 NUMBER;
l_amt3 NUMBER;
l_chk NUMBER := 255;
BEGIN
l_len := DBMS_LOB.GETLENGTH(p_clob);
l_offset := 1;
WHILE l_len > 0 LOOP
l_amount := DBMS_LOB.INSTR(p_clob,CHR(10),l_offset,1);
--Amount returned is the count from the start of the file,
--not from the offset.
IF l_amount = 0 THEN
--No more linefeeds so need to read remaining data.
l_amount := l_len;
l_amt2 := l_amount;
ELSE
l_f_amt2 := l_amount; --Store position of next LF
l_amount := l_amount - l_f_amt; --Calc position from last LF
l_f_amt := l_f_amt2; --Store position for next time
l_amt2 := l_amount - 1; --Read up to but not the LF
END IF;
/* divide the read into 255 character chunks for dbms_output */
IF l_amt2 != 0 THEN
l_amt3 := l_amt2;
l_offset2 := l_offset;
WHILE l_amt3 > l_chk LOOP
DBMS_LOB.READ(p_clob,l_chk,l_offset2,l_o_buf);
DBMS_OUTPUT.PUT_LINE(l_o_buf);
l_amt3 := l_amt3 - l_chk;
l_offset2 := l_offset2 + l_chk;
END LOOP;
IF l_amt3 != 0 THEN
DBMS_LOB.READ(p_clob,l_amt3,l_offset2,l_o_buf);
DBMS_OUTPUT.PUT_LINE(l_o_buf);
END IF;
END IF;
l_len := l_len - l_amount;
l_offset := l_offset+l_amount;
END LOOP;
EXCEPTION
WHEN buffer_overflow THEN
RETURN;
END printClobOut;
/* shortcut "writeline" procedure for CLOB buffer writes */
PROCEDURE wr(p_clob IN OUT NOCOPY CLOB, s VARCHAR2) IS
BEGIN
DBMS_LOB.WRITEAPPEND(p_clob,LENGTH(s)+1,s||CHR(10));
END;
/* the standard XSLT should include the identity template or the output XML will be malformed */
PROCEDURE newXsltHeader(p_xsl IN OUT NOCOPY CLOB, p_identity_template BOOLEAN DEFAULT TRUE) IS
BEGIN
DBMS_LOB.TRIM(p_xsl,0);
/* standard XSL header */
wr(p_xsl,'<?xml version="1.0"?>');
/* note that the namespace for the xsl is restricted to the w3 1999/XSL */
wr(p_xsl,'<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">');
IF p_identity_template THEN
/* create identity template (transfers all "other" nodes) */
wr(p_xsl,' <xsl:template match="node()">');
wr(p_xsl,' <xsl:copy>');
wr(p_xsl,' <xsl:apply-templates/>');
wr(p_xsl,' </xsl:copy>');
wr(p_xsl,' </xsl:template>');
END IF;
END newXsltHeader;
PROCEDURE newXsltFooter(p_xsl IN OUT NOCOPY CLOB) IS
BEGIN
/* standard xsl footer */
wr(p_xsl,'</xsl:stylesheet>');
END newXsltFooter;
/* using the stylesheet in p_xsl, transform p_XML1 into p_XML2 */
PROCEDURE transformXML(p_xsl IN OUT NOCOPY CLOB, p_XML1 IN OUT NOCOPY CLOB, p_XML2 IN OUT NOCOPY CLOB) IS
l_parser XMLPARSER.Parser;
l_doc XMLDOM.DOMDocument;
l_xsl_proc XSLPROCESSOR.Processor;
l_xsl_ss XSLPROCESSOR.Stylesheet;
BEGIN
/* parse XSL CLOB */
l_parser := XMLPARSER.newParser;
BEGIN
XMLPARSER.showWarnings(l_parser,TRUE);
XMLPARSER.parseClob(l_parser,p_xsl);
l_doc := XMLPARSER.getDocument(l_parser);
XMLPARSER.freeParser(l_parser);
EXCEPTION
WHEN OTHERS THEN
XMLPARSER.freeParser(l_parser);
RAISE;
END;
/* get Stylesheet from DOMDOC */
l_xsl_ss := XSLPROCESSOR.newStylesheet(l_doc,NULL);
BEGIN
/* parse XML1 CLOB */
l_parser := XMLPARSER.newParser;
BEGIN
XMLPARSER.showWarnings(l_parser,TRUE);
XMLPARSER.parseClob(l_parser,p_xml1);
l_doc := XMLPARSER.getDocument(l_parser);
XMLPARSER.freeParser(l_parser);
EXCEPTION
WHEN OTHERS THEN
XMLPARSER.freeParser(l_parser);
RAISE;
END;
/* process doc to XML2 */
l_xsl_proc := XSLPROCESSOR.newProcessor;
BEGIN
XSLPROCESSOR.processXSL(l_xsl_proc, l_xsl_ss, l_doc, p_xml2);
XSLPROCESSOR.freeProcessor(l_xsl_proc);
EXCEPTION
WHEN OTHERS THEN
XSLPROCESSOR.freeProcessor(l_xsl_proc);
RAISE;
END;
XSLPROCESSOR.freeStylesheet(l_xsl_ss);
EXCEPTION
WHEN OTHERS THEN
XSLPROCESSOR.freeStylesheet(l_xsl_ss);
RAISE;
END;
END transformXML;
/* transform XML1 into XML2 using list p_List of old/new tags */
PROCEDURE transformTags(p_List TagTransformList_t, p_XML1 IN OUT NOCOPY CLOB, p_XML2 IN OUT NOCOPY CLOB) IS
l_xsl CLOB;
BEGIN
/* create XSL CLOB */
DBMS_LOB.CREATETEMPORARY(l_xsl,TRUE);
/* create standard header with identity template */
newXsltHeader(l_xsl,TRUE);
/* create one template for each node translation */
FOR i IN 1..p_List.COUNT LOOP
wr(l_xsl,' <xsl:template match="'||p_List(i).old_tag||'">');
wr(l_xsl,' <'||p_List(i).new_tag||'><xsl:apply-templates/></'||p_List(i).new_tag||'>');
wr(l_xsl,' </xsl:template>');
END LOOP;
/* create standard footer */
newXsltFooter(l_xsl);
-- dbms_output.put_line('l_xsl:');
-- dbms_output.put_line('--------------------');
-- printClobOut(l_xsl);
-- dbms_output.put_line('--------------------');
transformXML(l_xsl, p_XML1, p_XML2);
DBMS_LOB.FREETEMPORARY(l_xsl);
/* -- unit testing
set serveroutput on size 100000
Declare
queryContext DBMS_XMLQUERY.ctxType;
xList XML_PKG.TagTransformList_t;
xmlCLOB CLOB;
xmlCLOB2 CLOB;
Begin
DBMS_LOB.CREATETEMPORARY(xmlCLOB,true);
DBMS_LOB.CREATETEMPORARY(xmlCLOB2,true);
xList(1).old_tag := 'A';
xList(1).new_tag := 'MyTag1';
xList(2).old_tag := 'B';
xList(2).new_tag := 'MyTag2';
queryContext := DBMS_XMLQUERY.newContext('Select * from t');
xmlCLOB := DBMS_XMLQUERY.getXML(queryContext);
DBMS_XMLQuery.closeContext(queryContext);
dbms_output.put_line('xmlCLOB:');
dbms_output.put_line('--------------------');
XML_PKG.printClobOut(xmlCLOB);
dbms_output.put_line('--------------------');
xml_pkg.transformTags(xList,xmlCLOB,xmlCLOB2);
dbms_output.put_line('xml2CLOB:');
dbms_output.put_line('--------------------');
XML_PKG.printClobOut(xmlCLOB2);
dbms_output.put_line('--------------------');
DBMS_LOB.FREETEMPORARY(xmlCLOB);
DBMS_LOB.FREETEMPORARY(xmlCLOB2);
End;
END transformTags;
END Xml_Pkg; -
Storing XML using XSU, object VIEW and INSTEAD OF trigger
Here is the point:
I've got 2 tables which are linked:
CREATE TABLE dept (
deptno NUMBER PRIMARY KEY,
deptname VARCHAR2(20)
CREATE TABLE emp (
empno NUMBER PRIMARY KEY,
empname VARCHAR2(20),
deptno NUMBER REFERENCES dept(deptno)
I've got the following message, which I want to insert in the tables using XSU (I already have a PL/SQL stored procedure which work perfectly for insertion into 1 table, using DBMS_XMLSave.insertXML or xmlgen.insertXML):
<DEPT>
<DEPTNO>10</DEPTNO>
<DEPTNAME>IT</DEPTNAME>
<EMP>
<EMPNO>1</EMPNO>
<EMPNAME>John</EMPNAME>
</EMP>
<EMP>
<EMPNO>1</EMPNO>
<EMPNAME>Phil</EMPNAME>
</EMP>
</DEPT>
So I've created the following object:
CREATE TYPE emp_t AS OBJECT
empno NUMBER,
empname VARCHAR2(20)
CREATE TYPE emplist_t AS TABLE OF emp_t;
CREATE TYPE dept_t AS OBJECT
deptno NUMBER,
deptname VARCHAR2(20),
emplist emplist_t
Now I understand that I should create an object VIEW and an INSTEAD OF trigger (That's what I read many times),
but I don't know how to structure the view and the trigger.
Could you help? (Example of a similar context, piece of code)
Thanks a lot
MarionHi John,
I have exactly the same issue as you experienced back in January. I have a complex data modelling requirement which requires the need to pivot rows into columns using ROW_NUMBER() and PARTITION clauses. To hide the complexity from the middle tier, I have created a database view and appropriate INSTEAD OF triggers and mapped my EO to the view. I have overriden the lock() method on the EO implementation class (to avoid ORA-02014) and would like to try the same solution you used with the pl/sql call to lock the record.
My question is, how did you manage the release of the lock if the transaction was not rolled back or committed by your application i.e. if the user closed the browser for instance.
In my naivity, I would like to think that the BC4J framework would release any locks for the database session when it found the servlet session to be terminated however my concern is that the lock would persist and cause complications.
Any assistance greatly appreciated (if you would be willing to supply your lock() method and pl/sql procedure logic I would be even more grateful!).
Many thanks,
Dave
London -
Creating Object views using XSU PL/SQL.Please SEE.
Hi,
I am presently using XSU PL/SQL utility with Oracle 9i and using the
DBMS_XMLQuery.newContext(<My Select clause goes here>,and the
DBMS_XMLQuery.getXML()which generates an XML document.
My query is:
I have 2 tables (One master and the other detail table.).
Table : DI_Master
di_num
00001
Table: DI_Details
di_num di_act
00001 ABCD
00001 ANCF
00001 IOPP
Now the XML I'd like is :
<di_num>00001</di_num>
<di_act>
<val>ABCD</val>
<val>ANCF</val>
<val>IOPP</val>
</di_act>
Do I need to create object tables for this,insert data into object tables
and then read this table? It will become an extremely tedious process
I guess an OBJECT view can do what I want.Can anyone please tell me how
to write an object view for the 2 tables please and the get the output as
desired.?Supposing you have further
nesting of the tables.Then how will you go about doing that.You can have multiple levels of CURSOR expressions (see an example below, not a real-life example, but illustrates the point).
SQL> set long 4000
SQL> select dbms_xmlquery.getXML('select deptno,' ||
2 'cursor(select empno, cursor(select losal, hisal from salgrade) salgrades '||
3 'from emp e where e.deptno = d.deptno and rownum < 3) EMPLOYEES ' ||
4 'from dept d where d.deptno = 10')
5 FROM DUAL;
DBMS_XMLQUERY.GETXML('SELECTDEPTNO,'||'CURSOR(SELECTEMPNO,CURSOR(SELECTLOSAL,HIS
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<DEPTNO>10</DEPTNO>
<EMPLOYEES>
<EMPLOYEES_ROW num="1">
<EMPNO>7782</EMPNO>
<SALGRADES>
<SALGRADES_ROW num="1">
<LOSAL>700</LOSAL>
<HISAL>1200</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="2">
<LOSAL>1201</LOSAL>
<HISAL>1400</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="3">
<LOSAL>1401</LOSAL>
<HISAL>2000</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="4">
<LOSAL>2001</LOSAL>
<HISAL>3000</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="5">
<LOSAL>3001</LOSAL>
<HISAL>9999</HISAL>
</SALGRADES_ROW>
</SALGRADES>
</EMPLOYEES_ROW>
<EMPLOYEES_ROW num="2">
<EMPNO>7839</EMPNO>
<SALGRADES>
<SALGRADES_ROW num="1">
<LOSAL>700</LOSAL>
<HISAL>1200</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="2">
<LOSAL>1201</LOSAL>
<HISAL>1400</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="3">
<LOSAL>1401</LOSAL>
<HISAL>2000</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="4">
<LOSAL>2001</LOSAL>
<HISAL>3000</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="5">
<LOSAL>3001</LOSAL>
<HISAL>9999</HISAL>
</SALGRADES_ROW>
</SALGRADES>
</EMPLOYEES_ROW>
</EMPLOYEES>
</ROW>
</ROWSET>
1 row selected.
SQL>
Also,isnt it a better option to create a VIEW of the
Select clause and pass a view to the select clause? At the end of the day, you could use whatever you feel comfortable with, provided that it produces your expected output and looks clean. We are just giving you the ideas, how you implement it actually in your situation, depends upon a lot of factors, that only you know about. -
Appication Server: 10g, Database: Oracle 9i and Oracle 10g
I have a table 'sw_icd2' in the database that has one column of XMLType.
The code below, attempts to query this table as 'select * from sw_icd2' and display the result. I was able to execute this query in sqlplus.
But when I run a program using XSU in JDeveloper:
OracleXMLQuery qry = new OracleXMLQuery(conn, "select * from sw_icd2");
XMLDocument domDoc = (XMLDocument)qry.getXMLDOM();
domDoc.print(System.out);
StringWriter s = new StringWriter(10000);
domDoc.print(new PrintWriter(s));
System.out.println(s.toString());
qry.close();
I get the following Error:
"oracle.xml.sql.OracleXMLSQLException: Conversion to String failed"
Any ideas on how I can resolve this issue? Your help would be appreciated.
Thanks!Okay, it looks like the problem has something to do with the TIMESTAMP data type in tables.
oracle.xml.sql.query.OracleXMLQuery can't seem to handle tables with the TIMESTAMP data type.
this code ran fine on my machine :
import oracle.jdbc.driver.*;
import oracle.xml.sql.query.OracleXMLQuery;
import java.lang.*;
import java.sql.*;
public class testXMLSQL {
public static void main(String[] args) {
try {
// Create the connection
System.out.println("before getConnection ");
Connection conn = getConnection("scott","tiger");
System.out.println("after getConnection ");
// Create the query class
OracleXMLQuery qry = new OracleXMLQuery(conn, "SELECT * FROM EMP");
System.out.println("after OracleXMLQuery object created ");
// Get the XML string
String str = qry.getXMLString();
// Print the XML output
System.out.println("The XML output is:\n"+str);
// Always close the query to get rid of any resources..
qry.close();
} catch(SQLException e) {
System.out.println(e.toString());
// Get the connection given the user name and password.!
private static Connection getConnection(String username,
String password)
throws SQLException
// register the JDBC driver..
DriverManager.registerDriver(new
oracle.jdbc.driver.OracleDriver());
// Create the connection using the OCI8 driver
Connection conn =
DriverManager.getConnection(
"jdbc:oracle:thin:@<server_name>:1521:<sid>",
username,password);
return conn;
Then I created another table :
create table emp_test as select * from emp;
added a timestamp to it :
alter table emp_test add (time timestamp(6));
and filled it with timestamp information :
update emp_test set time = timestamp'2005-09-22 09:26:50.124';
ran the same code but changed the SQL to :
"SELECT * FROM EMP_TEST"
and got the error message :
The XML output is:
<?xml version = '1.0'?>
<ERROR>oracle.xml.sql.OracleXMLSQLException: Conversion to String failed</ERROR>
looks like bug in OracleXMLQuery object?? -
Using XSU to process multiple record sets
Have a design question about XML, Java and Oracle's XSU. This is a common task when importing external data that should be of general interest.
I have an incoming XML document with multiple records with a known DTD. Before the records can be inserted into the database, part of
the record must be used to do a lookup for a foreign key. The resulting foreign key is then combined with the other part of the
record to create a valid input record for the database.
My question is what's the most efficient way to do this? I assume the general approach must go something like:
begin
while (records in xml doc)
1. parse the incoming XML to extract the next record
2. if the lookup data change, do a lookup for this record using XSL
3. combine the resulting foreign key with the data to create
an insert query
4. add the insert query as a document fragment to a second XML document.
use XSU to insert the second XML doc with multiple records.
end
I've figured out how to do most of this, except for step 1 above: is there an easy way to extract the next record from an XML doc if I know the row nodes and the DTD? Or do I just have to traverse all the XML nodes until I hit my next row tag?
Appreciate any suggestions; this is a handy discussion list!
--Rick Casey
Rick Casey, Graduate research assistant CADSWES, http://cadswes.colorado.edu
University of Colorado at Boulder [email protected] 303.492.0892
nullYes, typical behavior is that when you have multiple outputs it will create a one row IllumDoc to wrap them all together with OuputParameter=* (and the xml will be ignored unless it is the only output property or you've requested it by name).
How about just using "/Lighthammer/Illuminator?QueryTemplate=xxxx/yyyy&Content-Type=text/xml" or "/Lighthammer/Runner?Transaction=xxxx/yyyy&OutputParameter=OutputXML" which will both return your multi-rowset output?
I may be mistaken, but I believe the XacuteResponse was simplified to not include the Rowsets outer node because certain systems had problems digesting the layers, in fact you don't get the <Columns/> section either in the single Rowset.
Rick - any feedback to this SOAP simplification from Xacute? -
Multi heirarchy DOM tree using XSU ???
I'm not able to retrieve a A-->b-->C-->D-->E heirarchy representation of XML data(String or DOM)
My Data base is in terms of simple tables so when I try to use simple OracleXMLQquey I'm not able to secure my objective...
I wud appreciate if anybody can send me an example code to derive multi level DOM tree using XSU API'sUse the CURSOR() operator, or object views to accomplish your goal.
See the release notes for the XSQL Servlet for some hints in this area.
My soon-to-be released book, "Building Oracle XML Applications" from O'Reilly has many additional examples of using these techniques.
-- Steve Muench
-- Building Oracle XML Applications -
Creating Views using XSU PL/SQL API.Urgent please.
Folks,
I need some help in creating a View.
I am using XSU PL/SQL to generate an XML Document.
I have a table (SDI) with 2 cols CMPY_NUM and CPTY_BORG_NUM.
If the values in these 2 cols are equal then the xml
value to be returned is 'OURS' else return 'THEIRS'.
How do I Create this View please?
The XSU PL/SQL I am using to generate the XML is:
declare
queryCtx DBMS_XMLquery.ctxType;
xmlResult CLOB;
begin
queryCtx := DBMS_XMLQuery.newContext('select CMPY_NUM,CPTY_BORG_NUM from SDI');
xmlResult := DBMS_XMLQuery.getXML(queryCtx);
DBMS_XMLQuery.closeContext(queryCtx); -- you must close the query handle..
end;
Output
<?xml version='1.0'?>
<ROWSET>
<ROW num="1">
<CMPY_NUM>1</CMPY_NUM>
<CPTY_BORG_NUM>2/CPTY_BORG_NUM>
</ROW>
<!-- additional rows ... -->
</ROWSET>
Please can any one tell me how to create a view that will be used in place
of the select statement,and returns back OURS or THEIRS
Create View XML ASThis is a duplicate of this posting Creating a View to check for 2 conditions.. This is a particularly heinous case because some of our finest minds have already responded in that thread.
Lose ten culture points.
Regards, APC -
How can I use a 3rd party XML parser such as xerces with OC4J ?
Hi all tech experts,
I am using Oracle Application Server 10g Release 2 (10.1.2) and i have
installed Portal and Wireless and OracleAS Infrastructure on the same
computer.
i tried all the solutions on this thread
Use of Xerces Parser in out application with Oracle App Server 9.0.4
but still fighting.
I have also posted this query on OTN on following thread
How can I use a 3rd party XML parser such as xerces with OC4J?
but no reply....
Please help me on this issue.
Since OC4J is preconfigured to use the Oracle XML parser which is xmlparserv2.jar.
i have read the following article which states that
OC4J is preconfigured to use the Oracle XML parser. The Oracle XML parser is fully JAXP 1.1 compatible and will serve the needs of applications which require JAXP functionality. This approach does not require the download, installation, and configuration of additional XML parsers.
The Oracle XML parser (xmlparserv2.jar) is configured to load as a system level library of OC4J through it's inclusion as an entry in the Class-Path entry of the oc4j.jar Manifest.mf file. This results in the Oracle XML parser being used for all common deployment and packaging situations. You are not permitted to modify the Manifest.mf file of oc4j.jar.
It must be noted that configuring OC4J to run with any additional XML parser or JDBC library is not a supported configuration. We do know customers who have managed to successfully replace the system level XML parser and the Oracle JDBC drivers that ship with the product, but we do not support this type of configuration due to the possibility of unexpected system behavior and system errors that might occur from replacing the tested and certified libraries.
If you absolutely must use an additional XML parser such as xerces, then you have to start OC4J such that the xerces.jar file is loaded at a level above the OC4J system classpath. This can be accomplished using the -Xbootclasspath flag of the JRE.
i have also run the following command
java -Xbootclasspath/a:d:\xerces\xerces.jar -jar oc4j.jar
but no success.
How could i utilize my jar's like xerces.jar and xalan.jar for parsing instead of OC4J in-built parser ?
All reply will be highly appreciated.
Thnx in advance to all.
Neeraj Sidhaye
try_catch_finally @ Y !Hi Neeraj Sidhaye,
I am trying to deploy a sample xform application to the Oracle Application Server (10.1.3). However, I encountered the class loader issue that is similar to your stuation. I tried all the three solutions but the application is still use the Oracle xml paser class. I am wondering if you have any insight about this?
Thanks for your help.
Xingsheng Qian
iPass Inc.
Here is the error message I got.
Message:
java.lang.ClassCastException: oracle.xml.parser.v2.XMLElement
Stack Trace:
org.chiba.xml.xforms.exception.XFormsException: java.lang.ClassCastException: oracle.xml.parser.v2.XMLElement
at org.chiba.xml.xforms.Container.dispatch(Unknown Source)
at org.chiba.xml.xforms.Container.dispatch(Unknown Source)
at org.chiba.xml.xforms.Container.initModels(Unknown Source)
at org.chiba.xml.xforms.Container.init(Unknown Source)
at org.chiba.xml.xforms.ChibaBean.init(Unknown Source)
at org.chiba.adapter.servlet.ServletAdapter.init(ServletAdapter.java:153)
at org.chiba.adapter.servlet.ChibaServlet.doGet(ChibaServlet.java:303)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:719)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:299)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:187)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassCastException: oracle.xml.parser.v2.XMLElement
at org.chiba.xml.xforms.Instance.iterateModelItems(Unknown Source)
at org.chiba.xml.xforms.Bind.initializeModelItems(Unknown Source)
at org.chiba.xml.xforms.Bind.init(Unknown Source)
at org.chiba.xml.xforms.Initializer.initializeBindElements(Unknown Source)
at org.chiba.xml.xforms.Model.modelConstruct(Unknown Source)
at org.chiba.xml.xforms.Model.performDefault(Unknown Source)
at org.chiba.xml.xforms.XFormsDocument.performDefault(Unknown Source)
at org.chiba.xml.xforms.XFormsDocument.dispatchEvent(Unknown Source)
at org.apache.xerces.dom.NodeImpl.dispatchEvent(Unknown Source)
... 18 more -
How to use if condition in XML Publisher Desk Top
Hi..,
How to use if condition in XML Publisher desk Top.
Please guide me.
Thanks,
Suresh.What kind of condition you want to use?
You can use Condition like this:
<?xdofx:if condition then value1
else if condition then Value2
else Value3
end if?>
Please go thru XML Publisher User Guide.
Thanks
Ravi
[email protected] -
Using HAL to generate XML files
Greetings,<BR>I'd like to use HAL to build XML files and feeding certain variables while these files are generated. When the XML file is done being created, it will contain the variables passed. There are over 500 XML required to be build and for each of these files, only 2 or 3 variables must be passed to them. A template of the xml file was created using the Batch scheduler from Hyperion Reports, and this is the file I'd like to use as a template and build a HAL adapter based on that file.<BR><BR>Does any one have a sample of the XML adapter (via screen shot) that I can use a starting guide?<BR><BR>Many thanks in advance for your time.
Hi,
I'm running into the same problem deploying the classes generated by the class generator. Code works fine from JDeveloper, but had to put my DTD in the directory where my classes are. Deploying the classes with Apache's JServ gives me a NullPointer exception on the first addNode method. I guess it can't find the DTD. I tried to put the DTD in many locations but this didn't fix the problem. Any suggestions?
Steve,
Did you fix this problem? Thanx!
null
Maybe you are looking for
-
i can not seem to figure out why my phone will not turn on i have tried the master reset plugging it into a computer and the wall charger it does not seem to be doing anything can anyone help please
-
Dell Inspiron 7000 Windows 8 Dual Monitor Setup
Dell Inspiron 7000 Windows 8 DVI and HDMI video outputs. I want to connect two monitors. The Best Buy rep says use and DVI to VGA cable with splitter. However, I spoke to tech support reps here at work who set up and support computers and they said t
-
Password protect iMessges on iPod Touch
I want to password protect iMessges on my desktop and iPod. I looked into file vault (for the desktop), but it locks up the entire disk. I just want to lock up the application. I went through iMessages very carefully and found nothing on this. Very s
-
I want to update my adobe photoshop, but when I go to open the application it gives me an error code 6
-
Find blocking sessions based on forms
Hi, We use R12 applications and database 10g and wanted to kill blocking sessions that were created from forms in oracle applications. How to find out them?