Generic XML to SQL translator
We are working on a project where we need to push blobs of XML data into a DB with an unknown schema. We are looking for a tool that defines it's own XML-to-SQL protocol that would allow it to accept XML data in a format known to it and then translate it into SQL statements to store the info. Our thought is to take the data in our "internal" XML format and supply an XSL document to translate to whatever the end schema is. So if we had this data:
<MyDataObject>
<Member1>foo</Member1>
<Member2>bar</Member2>
</MyDataObject>
the XSL would translate it into a format that the tool would understand, like:
<Table name=DataObjects>
<Column name=Member1>foo</Column>
<Column name=Member2>bar</Column>
</Table>
the tool would then know to create an INSERT statement to add this data to the DataObjects table. The key is that we don't know the name or setup of any of the tables or columns at compile time. These may vary at each installation. It's easy to provide a new XSL translation for each install. It's harder (i.e. not feasible) to write whole new classes to match each schema.
The normal "XML to DB" tools/architectures like Castor, Torque, and JDOs don't seem to support this sort of dynamic binding to a DB. Does anyone know of a tool that does, or do we have to write our own?
Thanks,
Eric
Why don't you translate the XML directly to an SQL statement or use XSL to generate the SQL?
Franco
Similar Messages
-
Generic XML Parser for PL/SQL
Is there a generic XML parser written in PL/SQL that does not
rely on java that will run against a 7.3.4 database?
If please let me know where I can locate it.
Thanks,
Tim
nullTim (guest) wrote:
: Is there a generic XML parser written in PL/SQL that does not
: rely on java that will run against a 7.3.4 database?
: If please let me know where I can locate it.
: Thanks,
: Tim
There is not one currently but there are plans to provide the
PL/SQL one on top of our C version. You can also check out the
PLXML Utilities that have a limited version.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
null -
How to generate XML from SQL query
possible ways to generate XML from SQL qury.
i want to generate XML of following query. "Select * from emp,dep wher emp.deptno=dept.deptno"Hello.
Can you try:
SQL> set pages 0
SQL> set linesize 150
SQL> set long 9999999
SQL> set head off
SQL> select dbms_xmlgen.getxml('Select * from emp,dep wher emp.deptno=dept.deptno') from dual;
It works fine for me.
Octavio -
This is reports 11g
I've got a clob column. Reports seems to recognize its type, but if I try to reference it in a format trigger, I get this error at compile time:
"No pl/sql translation for the blind type given for this bind variable"Actually, Reports is in something better than Forms.
Neither Forms nor Reports do not have "complete" SQL engine (both have only "complete" PL/SQL engine), but have their own SQL parser, which does not understand SQL commands after the database 8.0.
But, in Reports Data Model - SQL Query Statement, we can write "modern" SQL statement (> database 8.0), because Reports sent it directly to the database, without using their own SQL parser.
For example, in Reports Data Model - SQL Query Statement, we can write this (scalar subquery expressions, in bold):
select empno,
ename,
deptno,
(select dname from dept where deptno = emp.deptno) dname
from emp
order by empno;
although scalar subquery expressions was introduced in the database 9.0.1, and in databases 8.0 and 8.1 we should write someting like this:
select emp.empno,
emp.ename,
emp.deptno,
dept.dname
from emp,
dept
where dept.deptno = emp.deptno
order by empno;
Regards,
Zlatko -
how can we view xml on sql*plus?
when xmltype is viewed on sql*prompt it shows incomplete xml.
example:
SQL> select xmlelement("ROOT",xmlforest(1 as A, 2 as B, 3 as C)) from dual;
XMLELEMENT("ROOT",XMLFOREST(1ASA,2ASB,3ASC))
<ROOT>
<A>1</A>
<B>2</B>
<C>3</C>
</ROOT>
but i generate an xml from table so it becomes quite huge. say a forest is populated with 6-8 tags. it shows broken output.
SQL> /
ID LIST
<DEPT>
<EMPLOYEE>
<ID>2109</ID>
<ID>3108</ID>
<ID>4107</ID>
<ID>5106</ID>
<ID
i have tried increasing bufferwidth and bufferlength tp max value (1000 and 2000 respectively) eventhen it displays the output as shown above.
how can i view my xml?use this sql plus command:
set long 2000000
You can increase\decrease the value as required. -
We have a new client that we need to send multiple xml file's to and I want to create a generic xml writer so I can pass in the data along with mapping document an be able to create the nodes off of the mapping document, I hope this makes sense, so if anyone has any examples or can point me in the right direction I would appreciate it
thevig wrote:
can point me in the right directionDesign first. Program and test next. Ask questions here if you have specific problems. -
Peter Fabian from Ottawa – Wants to learn XML and SQL
Hi There,
I am Peter Fabian from Ottawa. I want to learn XML and SQL. I have basic knowledge of HTML. Please provide me necessary tutorial which can help me to learn XML and SQL.
Thanks
Peter FabianSome starting points based on existing Oracle documentation
[url http://www.oracle.com/technetwork/indexes/documentation/index.html]Oracle Documentation
SQL - [url http://docs.oracle.com/cd/E11882_01/appdev.112/e10766/toc.htm]2 Day Developer's Guide
XML DB - [url http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb01int.htm#ADXDB0100]XML DB Developer's Guide
If you are going for the basics of XML, here is a place to start at [url http://www.w3schools.com/xml/]XML Tutorial
You can also just google for tutorials on both SQL and XML and find the basics as well. -
Strip off markups of generic XML data with E4X
I have a generic XML file:
<nodes>
<node1 att1='abc' att2='xyz'>
<ele1> Hello </ele1>
<ele2> Hi </ele2>
</node1>
</nodes>
The tag and attribute names above can be anything. I need a
generic method to strip off the XML markups and display the
contents as:
node1@att1: abc
node1@att2: xyz
node1.ele1: Hello
node1.ele2: Hi
How can E4X do this?e4x is for manipulating/navigating your xml. But you can use
it inside a for/each loop to look at your xml nodes and extract the
strings without the xml tags using toString().
Search the help docs for "XML type conversion" and see the
toString() method in action. -
Generating XML from SQL queries and saving to an xml file?
Hi there,
I was wondering if somebody could help with regards to the following:
Generating XML from SQL queries and saving to a xml file?
We want to have a procedure(PL/SQL) that accepts an order number as an input parameter(the procedure
is accessed by our software on the client machine).
Using this order number we do a couple of SQL queries.
My first question: What would be our best option to convert the result of the
queries to xml?
Second Question: Once the XML has been generated, how do we save that XML to a file?
(The XML file is going to be saved on the file system of the server that
the database is running on.)
Now our procedure will also have a output parameter which returns the filename to us. eg. Order1001.xml
Our software on the client machine will then ftp this XML file(based on the output parameter[filename]) to
the client hard drive.
Any information would be greatly appreciated.
Thanking you,
FrancoisIf you are using 9iR2 you do not need to do any of this..
You can create an XML as an XMLType using the new SQL/XML operators. You can insert this XML into the XML DB repository using DBMS_XDB.createResource. You can then access the document from the resource. You can also return the XMLType containing the XML directly from the PL/SQL Procedure. -
Generating XML from SQL queries and saving to a xml file?
Hi there,
I was wondering if somebody could help with regards to the following:
Generating XML from SQL queries and saving to a xml file?
We want to have a stored procedure(PL/SQL) that accepts an order number as an input parameter(the procedure
is accessed by our software on the client machine).
Using this order number we do a couple of SQL queries.
My first question: What would be our best option to convert the result of the
queries to xml?
Second Question: Once the XML has been generated, how do we save that XML to a file?
(The XML file is going to be saved on the file system of the server that
the database is running on.)
Now our procedure will also have a output parameter which returns the filename to us. eg. Order1001.xml
Our software on the client machine will then ftp this XML file(based on the output parameter[filename]) to
the client hard drive.
Any information would be greatly appreciated.
Thanking you,
FrancoisHi
Here is an example of some code that i am using on Oracle 817.
The create_file procedure is the one that creates the file.
The orher procedures are utility procedures that can be used with any XML file.
PROCEDURE create_file_with_root(po_xmldoc OUT xmldom.DOMDocument,
pi_root_tag IN VARCHAR2,
po_root_element OUT xmldom.domelement,
po_root_node OUT xmldom.domnode,
pi_doctype_url IN VARCHAR2) IS
xmldoc xmldom.DOMDocument;
root xmldom.domnode;
root_node xmldom.domnode;
root_element xmldom.domelement;
record_node xmldom.domnode;
newelenode xmldom.DOMNode;
BEGIN
xmldoc := xmldom.newDOMDocument;
xmldom.setVersion(xmldoc, '1.0');
xmldom.setDoctype(xmldoc, pi_root_tag, pi_doctype_url,'');
-- Create the root --
root := xmldom.makeNode(xmldoc);
-- Create the root element in the file --
create_element_and_append(xmldoc, pi_root_tag, root, root_element, root_node);
po_xmldoc := xmldoc;
po_root_node := root_node;
po_root_element := root_element;
END create_file_with_root;
PROCEDURE create_element_and_append(pi_xmldoc IN OUT xmldom.DOMDocument,
pi_element_name IN VARCHAR2,
pi_parent_node IN xmldom.domnode,
po_new_element OUT xmldom.domelement,
po_new_node OUT xmldom.domnode) IS
element xmldom.domelement;
child_node xmldom.domnode;
newelenode xmldom.DOMNode;
BEGIN
element := xmldom.createElement(pi_xmldoc, pi_element_name);
child_node := xmldom.makeNode(element);
-- Append the new node to the parent --
newelenode := xmldom.appendchild(pi_parent_node, child_node);
po_new_node := child_node;
po_new_element := element;
END create_element_and_append;
FUNCTION create_text_element(pio_xmldoc IN OUT xmldom.DOMDocument, pi_element_name IN VARCHAR2,
pi_element_data IN VARCHAR2, pi_parent_node IN xmldom.domnode) RETURN xmldom.domnode IS
parent_node xmldom.domnode;
child_node xmldom.domnode;
child_element xmldom.domelement;
newelenode xmldom.DOMNode;
textele xmldom.DOMText;
compnode xmldom.DOMNode;
BEGIN
create_element_and_append(pio_xmldoc, pi_element_name, pi_parent_node, child_element, child_node);
parent_node := child_node;
-- Create a text node --
textele := xmldom.createTextNode(pio_xmldoc, pi_element_data);
child_node := xmldom.makeNode(textele);
-- Link the text node to the new node --
compnode := xmldom.appendChild(parent_node, child_node);
RETURN newelenode;
END create_text_element;
PROCEDURE create_file IS
xmldoc xmldom.DOMDocument;
root_node xmldom.domnode;
xml_doctype xmldom.DOMDocumentType;
root_element xmldom.domelement;
record_element xmldom.domelement;
record_node xmldom.domnode;
parent_node xmldom.domnode;
child_node xmldom.domnode;
newelenode xmldom.DOMNode;
textele xmldom.DOMText;
compnode xmldom.DOMNode;
BEGIN
xmldoc := xmldom.newDOMDocument;
xmldom.setVersion(xmldoc, '1.0');
create_file_with_root(xmldoc, 'root', root_element, root_node, 'test.dtd');
xmldom.setAttribute(root_element, 'interface_type', 'EXCHANGE_RATES');
-- Create the record element in the file --
create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
parent_node := create_text_element(xmldoc, 'title', 'Mr', record_node);
parent_node := create_text_element(xmldoc, 'name', 'Joe', record_node);
parent_node := create_text_element(xmldoc,'surname', 'Blogs', record_node);
-- Create the record element in the file --
create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
parent_node := create_text_element(xmldoc, 'title', 'Mrs', record_node);
parent_node := create_text_element(xmldoc, 'name', 'A', record_node);
parent_node := create_text_element(xmldoc, 'surname', 'B', record_node);
-- write the newly created dom document into the buffer assuming it is less than 32K
xmldom.writeTofile(xmldoc, 'c:\laiki\willow_data\test.xml');
EXCEPTION
WHEN xmldom.INDEX_SIZE_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Index Size error');
WHEN xmldom.DOMSTRING_SIZE_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'String Size error');
WHEN xmldom.HIERARCHY_REQUEST_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Hierarchy request error');
WHEN xmldom.WRONG_DOCUMENT_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Wrong doc error');
WHEN xmldom.INVALID_CHARACTER_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Invalid Char error');
WHEN xmldom.NO_DATA_ALLOWED_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Nod data allowed error');
WHEN xmldom.NO_MODIFICATION_ALLOWED_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'No mod allowed error');
WHEN xmldom.NOT_FOUND_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Not found error');
WHEN xmldom.NOT_SUPPORTED_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Not supported error');
WHEN xmldom.INUSE_ATTRIBUTE_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'In use attr error');
WHEN OTHERS THEN
dbms_output.put_line('exception occured' || SQLCODE || SUBSTR(SQLERRM, 1, 100));
END create_file; -
HS ODBC connection to unidata SQL translation
Experts please help.
I successfully created a db link to unidata using HS ODBC. When I execute SQL for example "SELECT NAME FROM CUSTOMER@unidata", Oracle translates the SQL as "SELECT NAME AS C000 FROM CUSTOMER@unidata".
The issue is, unidata ODBC does not recoginize "as" keyword. So I am getting a syntax error. Is there a way or a parameter I can set to disable the "as" keyword during the SQL translation ?I have not worked on HS ODBC but you can try providing the alias yourself (if possible).
SELECT NAME NAME FROM CUSTOMER@unidata;
Does this work? -
Hi
I'm developing my first app for iOS using Flashbuilder 4.6 and need to have a database to keep track of certain items, probably no more than 20 items per record (including username and password) in a single table for a single user.
I don't want to use server technology but want to keep the data on the device. My question is should I use XML or SQL or some other way to store the data on the device.
Any guidance would be appreciated.
Thanks.Ok ... drop sitemesh and jmeter. So we have:
mysql + hibernate + log4j + ant + struts + tomcat (app server) + apache (web server) running on freebsd and tested using junit.
mysql - Half decent and free. Easy to setup.
hibernate - Provides OR mapping. Takes a bit of learning but keep it simple and you'll be ok.
log4j - Really easy to setup and use.
ant - Again will take a bit of learning but once you get going you can write a basic ant script in no time (it integrates really well with eclipse)
struts - Probably the most difficult technology to learn but it will keep your app well structured. (MVC)
tomcat + apache - You can probably get away with just tomcat but if you've got time use the jk2 connector stuff.
freebsd - Any unix based OS will do really.
junit - Will look really good if you show you've properly unit tested your work. And you can integrate with junit with ant.
How long have you got to do this btw ... -
XML to SQL (oracle) Parallel Processing Scenario
hi,
I have one scenario to load datas from XML to SQL but when this scenario runs in parallel duplicate information.
I have done tests with 5 xml file these xml file have unique header_id but when run in parallel , insert 5 record in target table but one is repeat.
the flow is the following,
1. My scenario recieved one variable (name xml file), this variable is sent for bpel.
2. Load datas from xml to sql(oracle), in this step I have concatenated to tables C$_, I$ and E$_ the session number how explain this link http://odiexperts.com/?p=1417.
3. Invoke web service with status finished.
I have tried the following.
after of first step I set a procedure with sentence "SYNCHRONIZE schema SO from file" and modify my topology to &ro=true some time run perfect but check the target table and datas are duplicated and other time catch the error ....
0 : null : java.sql.SQLException: class org.xml.sax.SAXException
class java.lang.NullPointerException said null.
Any suggestion o coment to execute my scenario in parallel?
Thanks a lot.
AntonioPlease repost in the Data Integrator forum Data Integrator
(this forum is for Data Service Integrator - an entirely different product). -
Hi I wan to create XML from SQL using XMLElement and XMLAttribute as per below Format
*<field name="AccountNumber">TEST01</field>*
is it possible?
Thanks in advance
waiting for yours positive replyParth Panjabi wrote:
Thanks in AdvanceWhy don't you open Oracle docs and read it. If you want to beautify, XMLSerialize supports INDENT:
SQL> SELECT XMLSerialize(document
2 XMLElement("ROWS",
3 XMLAgg(
4 XMLElement("ROW",
5 XMLElement("field",
6 XMLAttributes('AccountNumber' AS "name")
7 , ename
8 )
9 , XMLElement("field",
10 XMLAttributes('CBAccountNumber' AS "name")
11 , null
12 )
13 )
14 )
15 )
16 )
17 FROM EMP
18 WHERE deptno = 10
19 /
XMLSERIALIZE(DOCUMENTXMLELEMENT("ROWS",XMLAGG(XMLELEMENT("ROW",XMLELEMENT("FIELD
<ROWS><ROW><field name="AccountNumber">CLARK</field><field name="CBAccountNumber
"></field></ROW><ROW><field name="AccountNumber">KING</field><field name="CBAcco
untNumber"></field></ROW><ROW><field name="AccountNumber">MILLER</field><field n
ame="CBAccountNumber"></field></ROW></ROWS>
SQL> SELECT XMLSerialize(document
2 XMLElement("ROWS",
3 XMLAgg(
4 XMLElement("ROW",
5 XMLElement("field",
6 XMLAttributes('AccountNumber' AS "name")
7 , ename
8 )
9 , XMLElement("field",
10 XMLAttributes('CBAccountNumber' AS "name")
11 , null
12 )
13 )
14 )
15 )
16 INDENT
17 )
18 FROM EMP
19 WHERE deptno = 10
20 /
XMLSERIALIZE(DOCUMENTXMLELEMENT("ROWS",XMLAGG(XMLELEMENT("ROW",XMLELEMENT("FIELD
<ROWS>
<ROW>
<field name="AccountNumber">CLARK</field>
<field name="CBAccountNumber"/>
</ROW>
<ROW>
<field name="AccountNumber">KING</field>
<field name="CBAccountNumber"/>
</ROW>
<ROW>
<field name="AccountNumber">MILLER</field>
XMLSERIALIZE(DOCUMENTXMLELEMENT("ROWS",XMLAGG(XMLELEMENT("ROW",XMLELEMENT("FIELD
<field name="CBAccountNumber"/>
</ROW>
</ROWS>
SQL>
{code}
SY. -
How can I load this XML with sql loader ?
Hi,
Im try to load a XML file into a XML table:
Create table TEST of XMLTYPE;
XML file is something like this:
<!DOCTYPE list SYSTEM "myfile.dtd">
<list>
<item id = 1> lot of tags an info here </item>
<item id = 9000> lot of tags an info here </item>
</list>
I dont know how to exactly create an appropriate control file to my XML. All examples I saw in documentation are similar to this one:
this is an example control file
LOAD DATA
INFILE *
INTO TABLE test
APPEND
XMLTYPE (xmldata)
FIELDS
I dont know how to complete this control file. Can anyone help me ?
thank you!
Message was edited by:
pollopoleaWell I found this working code
LOAD DATA
INFILE *
INTO TABLE test APPEND
xmltype(xmldata)
FIELDS
ext_fname filler char(30),
xmldata LOBFILE (ext_fname) TERMINATED BY EOF
BEGINDATA
mifile.xml
mifile2.xml
mifile3.xml
the main diference I found is that when i use:
Insert into test values (XMLType(bfilename('XMLDIR', 'swd_uC000025127.xml'),nls_charset_id('AL32UTF8')));
tag <!DOCTYPE list SYSTEM "myfile.dtd"> is expanded
(I explain at DTD insertion and errors with long DTD entities
Now using sql loader the tag is not modified.
I dont know if is there any difference, between each case. did I lost performance?
Message was edited by:
pollopolea
Maybe you are looking for
-
Why cant I publish my websites with the same addresses as they have had before?
Here is the latest answer from Ethmoid to my question: Okay, so where are you publishing your sites to MobileMe or an external server? What were your sites named before? You do know that even if there is a site folder and you have a site name all you
-
can some 1 pls help i have just got a Apple I Mac Power PC G3 Processor Speed: 333 MHz Memory (RAM): 160 MB i only wanted it for itunes but its come with no software at all and i have got a clue about apple macs what so ever is there anyway of buying
-
MK contract and received quantity (GR through call off PO)
Hi, I have a MK (quantity) contract, and I call off with Purchase orders. Can somebody give me a transaction or a abap report name which is capable to show me: contract target quanity; PO order quantity AND GR quantity? The latter is the most importa
-
Installed programs "slow" to start and close
My OS is windows 8.1 pro. I have a dual-boot with win7 ultimate. Lately some of my installed programs, utorrent for one example takes longer to start than before. It also takes up to 45 seconds to close after clicking X button. Even my office2013 pro
-
Runnig the program in the task bar
hi all, i need to know what to do to run my apllication in the task bar when i close it , you know like the Yahoo messenger or MSN messenger when you close it it runs in the task bar . thanks