Exception when inserting a XML document into database
Hello.
I'm trying to insert the content of a XML document into a database. The problem consists on the exception that is raised when a FK in the XML is not in the database as a PK
How can i catch these exceptions and continuing inserting the rest of the data
Thanks in advance ...
I really hope for you this wasn't a production database, as mentioned in the URL, it has been some years ago for me fiddling around this which was btw a supported metalink workaround ONCE (during my Oracle 7 days), but now, I wouldn't be surprised if you now have mixed NLS content in your tables/database and more or less "corrupted" your content.
The initial issue was probably a client one.
BTW
I actually hope it was a production database, maybe then you would learn that way, that you SHOULD NEVER EVER UPDATE DATABASE BASE TABLES directly...
...unless (the only exception) you want to learn something about the internals and don't care that your TEST database gets corrupted....
Similar Messages
-
Help - Inserting an XML document into a Oracle 8i Column (CLOB Type)
Hi JavaGurus,
I am looking for a simple java code which will take my XML document as input and insert the same into a Oracle 8i database's column which is of type CLOB.
Insert statement won't work and I can not use SQL Loader.
Any one?
JKMaybe you can adapt some of the code in Oracle's "LOB Datatype" example, which is a complete working program that stores and retrieves BLOBs and CLOBs.
http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/advanced.html -
How to insert one XML document into another
Hi,
I've been working on a simple CMS.
There is a main template that is just a HTML page. The main template has a few extra 'module' tags that indicates places where individual modules have to be placed.
main template: template.xml
<html>
<body>
<div>
<module id="centre"/>
</div>
</body>
</html>module template: module_centre.xml
<div>
<a>This is a MODULE and it may be much more complex</a>
<div>My application has to detect every 'module' tag from the template.xml and insert there XML content from a proper module template.
The result file has to be generated dynamically on a request. The structures of 'modules' can be only defined in module_*.xml files.
The expected result
<html>
<body>
<div>
<div>
<a>This is a MODULE and it may be much more complex</a>
<div>
</div>
</body>
</html>What's the best practice do solve this case?
PawelI think I've came up with a better solution.
SRC file
<?xml version="1.0" encoding="utf-8"?>
<html>
<head>
<title></title>
<style type="text/css">
div.c4 {background-color:pink;width:400px;height:50px}
div.c3 {background-color:green}
div.c2 {background-color:blue;width:400px;height:299px}
div.c1 {background-color:red}
</style>
</head>
<body>
<module id="XXX"/>
<div id="main" class="c3">
<div id="top" class="c1"><module id="menu_test"/></div>
<div id="bottom" class="c2"><module id="menu_test2"/></div>
</div>
<div id="footer_container" class="c4"> <module id="menu_footer"/></div>
</body>
</html>MODULE src file
<?xml version="1.0" encoding="UTF-8"?>
<div id="admin_panel_module" style="background-color:orange;width:200px;height:50px">
<p>Control Panel TEST</p>
</div> @param source - NODES from MODULE document
*@param target - TEMPLATE document where MODULES are going to be inserted*
@throws Exception
public static void insertModules(Node source, Document target) throws Exception {
Node importedNodes = target.importNode(source, true);
// Use XPath to find all 'module' nodes in ''
XPath xpath = XPathFactory.newInstance().newXPath();
NodeList nodes = (NodeList) xpath.evaluate("//module", target, XPathConstants.NODESET);
// Remove MODULE node and insert there an XML content from MODULE template
for (int idx = 0; idx < nodes.getLength(); idx++) {
Node editedModuleElement = nodes.item(idx);
// parent of module mode
Node parentNode = editedModuleElement.getParentNode();
// replace <module/> node with imported nodes from 'module' XML document
parentNode.replaceChild(importedNodes, editedModuleElement);
// nodes.item(idx).appendChild(node);
importedNodes = target.importNode(source, true);
}Edited by: maestr0 on May 24, 2010 12:44 AM -
How to insert large xml data into database tables.
Hi all,
iam new to xml. i want to insert data in xml file to my database tables.but the xml file size is very large. performance is also one of the issue. can anybody please tell me the procedure to take xml file from the server and insert into my database tables.
Thanks in advanceUnfortunately posting very generic questions like this in the forum tends not to be very productive for you, me or the other people who read the forum. It really helps everyone if you take a little time to review existing posts and their answers before starting new threads which replicate subjects that have already been discussed extensively in previous threads. This allows you to ask more sensible questions (eg, I'm using this approach and encountering this problem) rather than extremely generic questions that you can answer yourself by spending a little time reviewing existings posts or using the forum's search feature.
Also in future your might want to try being a little more specific before posting questions
Eg Define "very large". I know of customers who thing very large is 100K, and customers who think 4G is medium. I cannot tell from your post what size your files are.
What is the content of the file. Is it going to be loaded into a single record, or a a single table, or will it need to be loaded into multiple records in a single table or multiple records in multiple tables ?
Do you really need to load the data into exsiting relational tables or could your application work with relational views of the XML Content.
Finally which release of the database are you working with.
Define performance. Is it reasonable to expect to process this kind of document on this machine (Make, memory, #number of CPUs, CPU Speed, number of discs) in this period of time.
WRT to your original question. If you take a few minutes to search this forum you will find a very large number of threads with very similar titles to yours. These theads document a number of different approaches that can be used to solve this problem.
I suggest you start by looking for threads that cover topics like DBMS_XMLSTORE, XMLTable(), Relational Views of XML content, loading XML content in relational tables. -
XML document into multiple tables
How to insert a xml document into multiple tables. Eg. Purchase Order having multiple line items. I have to insert xml document into Parent as well as child with different sets of columns.
I created the tables using the create_ch14_tables.sql. I call it using java -classpath .;C:\commerceone\xpc\lib\xmlparserv2.jar;C:\commerceone\xpc\lib\classes12.zip;C:\commerceone\xpc\lib\xsu12.jar XMLLoader -file deptempdepend.xml -connName default -transform deptempdepend.xsl. The code doesn't seem to like the "<xsl:for-each select="Department">" tags. If I remove them, the insDoc.getDocumentElement().getFirstChild() will find the element, but it still doesn't insert anything into the database.
Thank You,
Dave -
Got error message when store XML documents into XML DB repository, via WebD
Hi experts,
I am in I am in Oracle Enterprise Manager 11g 11.2.0.1.0.
SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 22 11:40:23 2011
I got error message when store XML documents into XML DB repository, via WebDAV.
I have successfully registered 5 related schemas and generated 1 table.
I have inserted 40 .xml files into this auto generated table.
using these data I created relational view successfully.
but since I couldn't store XML documents into XML DB repository, via WebDAV
when I query using below code:
SELECT rv.res.getClobVal()
FROM resource_view rv
WHERE rv.any_path = '/home/DEV/messages/4fe1-865d-da0db9212f34.xml';
I got nothing.
My ftp code is listed below:
ftp> open localhost 2100
Connected to I0025B368E2F9.
220- C0025B368E2F9
Unauthorised use of this FTP server is prohibited and may be subject to civil and criminal prosecution.
220 I0025B368E2F9 FTP Server (Oracle XML DB/Oracle Database) ready.
User (I0025B368E2F9:(none)): fda_xml
331 pass required for FDA_XML
Password:
230 FDA_XML logged in
ftp> cd /home/DEV/message
250 CWD Command successful
ftp> pwd
257 "/home/DEV/message" is current directory.
ftp> ls -la
200 PORT Command successful
150 ASCII Data Connection
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 .
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 ..
226 ASCII Transfer Complete
ftp: 115 bytes received in 0.00Seconds 115000.00Kbytes/sec.
250 SET_CHARSET Command Successful
ftp> put C:\ED\SPL\E_Reon_Data\loaded\4fe1-865d-da0db9212f34.xml
200 PORT Command successful
150 ASCII Data Connection
550- Error Response
ORA-00600: internal error code, arguments: [qmxConvUnkType], [], [], [], [], [], [], [], [], [], [], []
550 End Error Response
ftp: 3394 bytes sent in 0.00Seconds 3394000.00Kbytes/sec.
I have tried all suggestion from another thread such as:
alter system set events ='31150 trace name context forever, level 0x4000'
SQL> alter system set shared_servers = 1;
but failed.
is there anyone can help?
Thanks.
Edited by: Cow on Mar 29, 2011 12:58 AMHi experts,
I am in I am in Oracle Enterprise Manager 11g 11.2.0.1.0.
SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 22 11:40:23 2011
I got error message when store XML documents into XML DB repository, via WebDAV.
I have successfully registered 5 related schemas and generated 1 table.
I have inserted 40 .xml files into this auto generated table.
using these data I created relational view successfully.
but since I couldn't store XML documents into XML DB repository, via WebDAV
when I query using below code:
SELECT rv.res.getClobVal()
FROM resource_view rv
WHERE rv.any_path = '/home/DEV/messages/4fe1-865d-da0db9212f34.xml';
I got nothing.
My ftp code is listed below:
ftp> open localhost 2100
Connected to I0025B368E2F9.
220- C0025B368E2F9
Unauthorised use of this FTP server is prohibited and may be subject to civil and criminal prosecution.
220 I0025B368E2F9 FTP Server (Oracle XML DB/Oracle Database) ready.
User (I0025B368E2F9:(none)): fda_xml
331 pass required for FDA_XML
Password:
230 FDA_XML logged in
ftp> cd /home/DEV/message
250 CWD Command successful
ftp> pwd
257 "/home/DEV/message" is current directory.
ftp> ls -la
200 PORT Command successful
150 ASCII Data Connection
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 .
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 ..
226 ASCII Transfer Complete
ftp: 115 bytes received in 0.00Seconds 115000.00Kbytes/sec.
250 SET_CHARSET Command Successful
ftp> put C:\ED\SPL\E_Reon_Data\loaded\4fe1-865d-da0db9212f34.xml
200 PORT Command successful
150 ASCII Data Connection
550- Error Response
ORA-00600: internal error code, arguments: [qmxConvUnkType], [], [], [], [], [], [], [], [], [], [], []
550 End Error Response
ftp: 3394 bytes sent in 0.00Seconds 3394000.00Kbytes/sec.
I have tried all suggestion from another thread such as:
alter system set events ='31150 trace name context forever, level 0x4000'
SQL> alter system set shared_servers = 1;
but failed.
is there anyone can help?
Thanks.
Edited by: Cow on Mar 29, 2011 12:58 AM -
Repository event handler doesn't work when inserting an xml-doc via ftp
Hi,
I want to add a 'schemaLocation'-attribute to an XML-document when I load it in the repository. Therefore, I use the precreate-repository event and created a Repository Event Handler (see code extract below).
Everything works fine if I type the following code in SQL Plus:
Declare
v_return BOOLEAN;
Begin
v_return:=DBMS_XDB.createresource('/public/xml/test.xml', XMLType(bfilename('XMLDIR', 'test.xml'),nls_charset_id('AL32UTF8')));
end;Unfortunately, when I try to insert an XML-document via ftp into the /public/xml folder it doesn´t work as expected and no 'schemaLocation'-attribute is added to the new resource.
What's the reason for this strange behavior and how can I solve it?
For your information: I use the Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Thank you very much for your help!!!
Repository Event Handler code extract:_
create or replace
PACKAGE BODY schemalocation AS
PROCEDURE handlePreCreate (eventObject DBMS_XEVENT.XDBRepositoryEvent) AS
XDBResourceObj DBMS_XDBRESOURCE.XDBResource;
var XMLType;
l_return BOOLEAN;
l_xmldoc dbms_xmldom.DOMDocument;
l_docelem dbms_xmldom.DOMElement;
l_attr dbms_xmldom.DOMAttr;
c1 clob;
node dbms_xmldom.DOMNode;
txid varchar2(100);
dDoc DBMS_XMLDOM.DOMDocument;
nlNodeList DBMS_XMLDOM.DOMNodeList;
BEGIN
XDBResourceObj := DBMS_XEVENT.getResource(eventObject);
dbms_lob.createTemporary(c1,TRUE);
var:=DBMS_XDBRESOURCE.getcontentxml(XDBResourceObj);
l_xmldoc := dbms_xmldom.newDOMDocument(var);
l_docelem := DBMS_XMLDOM.getDocumentElement(l_xmldoc);
------ add schemaLocation attribute
l_attr := DBMS_XMLDOM.createAttribute(l_xmldoc, 'xsi:schemaLocation');
DBMS_XMLDOM.setValue(l_attr, 'urn:iso:std:iso:20022:tech:xsd:sese.023.001.01 http://www.test.com/Testswift.xsd');
l_attr := DBMS_XMLDOM.setAttributeNode(l_docelem, l_attr);
DBMS_XMLDOM.WRITETOCLOB(l_xmldoc, c1);
------- get the value of the TxId-tag
dDoc := DBMS_XMLDOM.NEWDOMDOCUMENT(c1);
nlNodeList := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(dDoc, 'TxId');
node := DBMS_XMLDOM.ITEM(nlNodeList, 0);
txid:= dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(node));
l_return:=DBMS_XDB.createresource('/public/ok/'||txid||'.xml', XMLType(c1));
END;Marco,
Here's an example of the problem :
create or replace package handle_events
as
procedure handlePreCreate(p_event dbms_xevent.XDBRepositoryEvent);
end;
create or replace package body handle_events
is
procedure handlePreCreate (p_event dbms_xevent.XDBRepositoryEvent)
is
XDBResourceObj dbms_xdbresource.XDBResource;
doc XMLType;
res boolean;
begin
XDBResourceObj := dbms_xevent.getResource(p_event);
doc := dbms_xdbresource.getContentXML(XDBResourceObj);
select insertchildxml(
doc
, '/root'
, '@xsi:schemaLocation'
, 'urn:iso:std:iso:20022:tech:xsd:sese.023.001.01 http://www.test.com/Testswift.xsd'
, 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
into doc
from dual;
res := dbms_xdb.CreateResource('/public/xml/result.xml', doc);
end;
end;
declare
res boolean;
begin
res := dbms_xdb.CreateFolder('/public');
res := dbms_xdb.CreateFolder('/public/tmp');
res := dbms_xdb.CreateFolder('/public/xml');
end;
declare
res boolean;
resconfig xmltype;
my_schema varchar2(30) := 'DEV';
resconfig_path varchar2(300) := '/public/ResConfig.xml';
resource_path varchar2(300) := '/public/tmp';
begin
resconfig := xmltype(
'<ResConfig xmlns="http://xmlns.oracle.com/xdb/XDBResConfig.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/XDBResConfig.xsd http://xmlns.oracle.com/xdb/XDBResConfig.xsd">
<event-listeners set-invoker="true">
<listener>
<description>My event handler</description>
<schema>'||my_schema||'</schema>
<source>HANDLE_EVENTS</source>
<language>PL/SQL</language>
<events>
<Pre-Create/>
</events>
<pre-condition>
<existsNode>
<XPath>/r:Resource[r:ContentType="text/xml"]</XPath>
<namespace>xmlns:r="http://xmlns.oracle.com/xdb/XDBResource.xsd"</namespace>
</existsNode>
</pre-condition>
</listener>
</event-listeners>
<defaultChildConfig>
<configuration>
<path>'||resconfig_path||'</path>
</configuration>
</defaultChildConfig>
</ResConfig>'
res := dbms_xdb.CreateResource(resconfig_path, resconfig);
dbms_resconfig.addResConfig(resource_path, resconfig_path, null);
end;
/Giving the following input XML file :
<?xml version="1.0" encoding="utf-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>This works :
SQL> declare
2 res boolean;
3 begin
4 res := dbms_xdb.CreateResource('/public/tmp/test.xml',
5 xmltype(bfilename('TEST_DIR','test.xml'), nls_charset_id('AL32UTF8')));
6 end;
7 /
PL/SQL procedure successfully completed.
SQL> select XMLSerialize(document xdburitype('/public/xml/result.xml').getXML()
as clob indent size = 2) result
2 from dual
3 ;
RESULT
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
urn:iso:std:iso:20022:tech:xsd:sese.023.001.01 http://www.test.com/Testswift.xsd
"/>With the same document loaded via FTP, we get :
SQL> select XMLSerialize(document xdburitype('/public/xml/result.xml').getXML()
as clob indent size = 2) result
2 from dual
3 ;
ERROR:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00283: document encoding is UTF-16-based but default input encoding is not
Error at line 1
no rows selectedand the content looks like :
< ? x m l v e r s i o n = " 1 . 0 " e n c o d i n g = " u t f - 8 " ? >
< r o o t x m l n s : x s i = " h t t p : / / w w w . w 3 . o r g / 2 0 0 1 / X M L S c h e m a - i n s t a n c e " / >As a workaround, I've found that serializing and re-parsing the document solves the problem :
select insertchildxml(
xmltype(doc.getclobval())
, '/root'
, '@xsi:schemaLocation'
, 'urn:iso:std:iso:20022:tech:xsd:sese.023.001.01 http://www.test.com/Testswift.xsd'
, 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
into doc
from dual;
...We then get the expected result after FTP transfer :
SQL> select XMLSerialize(document xdburitype('/public/xml/result.xml').getXML()
as clob indent size = 2) result
2 from dual
3 ;
RESULT
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
urn:iso:std:iso:20022:tech:xsd:sese.023.001.01 http://www.test.com/Testswift.xsd
"/>The workaround also works for the DOM version presented above.
Any ideas? -
Loading a XML-document into tables
Hi,
I have created a view for the tables below.
Table Book with columns:
- Book_ID
- Book_Name
- Ref_To_Price ( -> is a reference to Table Price (Price_ID))
Table Price with columns:
- Price_ID
- Price_DM
SQL-Syntax:
"create view Bookprice as select Book_ID, Book_Name, Ref_To_Price, Price_ID, Price_DM from Book, Price where Ref_To_Price = Price_ID; "
XML-Document:
<?xml version="1.0" encoding="UTF-16"?>
<!DOCTYPE ANWENDUNGEN SYSTEM "file:/E:/book.dtd">
<!-- ?xml-stylesheet href="book.xsl" type="text/xsl"? -->
<ROOTDOC>
<ROW>
<BOOK_ID>66-77</BOOK_ID>
<BOOK_NAME>JavaScript</BOOK_NAME>
<REF_TO_PRICE>12</REF_TO_PRICE>
<PRICE_ID>12</PRICE_ID>
<PRICE_DM>25.50DM</PPRICE_DM>
</ROW>
</ROOTDOC>
If I use the XML SQL Utility to insert the XML-Document, the following error message came up:
" Exception in thread "main" oracle.xml.sql.OracleXMLSQLException: java.sql.SQLException: ORA-01776: cannot modify more than one base table through a join view "
Can anyone help me, please ?
nullHi,
This is a classic join view problem, where u cannot update two tables in one shot. The main problem is that ur two tables are not normalized correctly. Why can't they be in just one table?
OK, if that is not possible, then the best way out is to create a simple INSTEAD OF trigger on the view which will insert correclty,
e.g.
CREATE TRIGGER bookprice_tr INSTEAD OF INSERT ON Bookprice FOR EACH ROW
BEGIN
insert into Book values (:NEW.Book_id,
:NEW.Book_name, :NEW.Ref_to_Price);
insert into Price
values(:NEW.Price_ID, :NEW.Price_DM);
END;
Hope this helps,
Murali -
To load an XML document into 40 tables
How do I load a large XML document into 40 tables. Most of the exmaples, I see only load one table into the Orcale database?
From the above document:
Storing XML Data Across Tables
Question
Can XML- SQL Utility store XML data across tables?
Answer
Currently XML-SQL Utility (XSU) can only store to a single table. It maps a canonical representation of an XML document into any table/view. But of course there is a way to store XML with the XSU across table. One can do this using XSLT to transform any document into multiple documents and insert them separately. Another way is to define views over multiple tables (object views if needed) and then do the inserts ... into the view. If the view is inherently non-updatable (because of complex joins, ...), then one can use INSTEAD-OF triggers over the views to do the inserts.
-- I've tried this, works fine. -
Insert a XSL document into XMLType
Hi dear reader
I want to insert a XSL document into XMLType field , but the length of the XSL is 5900 character and I have problem with loading and executing the INSERT statement in database.
for solving the load problem , I use binding variable and try to execute it with EXECUTE IMMEDIATE str.
and get the following error :
ORA-01704: string literal too long
please advice;
thankscreate directory object DIR_TEMP on the database pointing to the physical path where your xml files are available.
Note the path should be on the database server and not on the client and also your files should be present on the database server and not client for this to work.
create table xml_table (id number, xml_data xmltype)
CREATE OR REPLACE FUNCTION getClobDocument
( filename in varchar2,
charset in varchar2 default NULL,
dir IN VARCHAR2 default 'DIR_TEMP',
) RETURN CLOB deterministic is
file bfile := bfilename(dir,filename);
charContent CLOB := ' ';
targetFile bfile;
lang_ctx number := DBMS_LOB.default_lang_ctx;
charset_id number := 0;
src_offset number := 1 ;
dst_offset number := 1 ;
warning number;
BEGIN
IF charset is not null then
charset_id := NLS_CHARSET_ID(charset);
end if;
targetFile := file;
DBMS_LOB.fileopen(targetFile, DBMS_LOB.file_readonly);
DBMS_LOB.LOADCLOBFROMFILE(charContent, targetFile,
DBMS_LOB.getLength(targetFile), src_offset, dst_offset,
charset_id, lang_ctx,warning);
DBMS_LOB.fileclose(targetFile);
return charContent;
end;
insert into xml_table values(1, XMLTYPE(GetClobDocument('purchaseorder.xml')))
/The function GetClobDocument returns the content of the xml file in CLOB format.
Before insert this is converted into XMLTYPE. -
I have an iMac with Yosemite. I have Adobe Acrobat Pro van 8.3.1.
I am unable to insert a pdf document into a pdf document. I go to Document/Insert in the menu bar, get a spinning ball, can do nothing with the app except force-quit.
What's my upgrade? I cannot find one. Do I have to pay full price for a version that will work?Your version of Acrobat is quite old and not compatible with any current OS, so problems are to be expected. It is too old to qualify for an upgrade as well, so if you want the current version (XI) then you need to purchase a new license, which you can do via the Adobe Products Page.
-
How to insert a PDF document into a Word file?
I'm using Acrobat Standard 9 and Microsoft Word 2010 and I'm unable to insert a PDF document into a Word file. Operating system is Windows 7 Enterprize. Can someone help?
Thanks for the reply, Bill.
Yes, let me elaborate further:
I have a four page document in WORD with instructions. Examples of the instructions are in PDF files. I want to insert each PDF example next to or below each line item in WORD.The PDF will open when clicking on the icon without having a hyperlink attached to it. -
Can I append an XML Document into another?
I have a large xml document which I open into coldfusion (mx
7), and then a smaller group of files that are opened into thier
own xml objects. After some customization of xml text values, I
want to append the smaller xml documents into the larger document
at specific positions within the document tree.
I have the code that I thought would do this, using an
arrayappend function, but what happens is that only the root
element of the smaller (inserted) xml document is placed into the
main document.
Is this possible, or do I need to modify the code so that the
entire tree of xml data that I am appending is created on the
fly?Personally I do this with XSLT.
<cfxml variable="doc1">
<root>
<member id="10">
<name>Ian</name>
<sex>male</sex>
</member>
</root>
</cfxml>
<cfxml variable="doc2">
<root>
<member id="1">
<name>Joe</name>
<sex>male</sex>
</member>
<member id="2">
<name>John</name>
<sex>male</sex>
</member>
<member id="3">
<name>Sue</name>
<sex>female</sex>
</member>
</root>
</cfxml>
<cffile action="write" file="#expandPath("/")#\doc2.xml"
output="#ToString(doc2)#" nameconflict="overwrite">
<!--- METHOD ONE using a depreciated and undocumented
method --->
<cfset newNode = doc1.root.member.cloneNode(true)>
<cfset doc2.changeNodeOwner(newNode)>
<cfset doc2.root.appendChild(newNode)>
<cfdump var="#doc2#" label="Merged by hidden functions"
expand="no">
<!--- METHOD TWO using XSLT --->
<!--- create an xsl docutment--->
<cfoutput>
<cfsavecontent variable="transformer">
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml"/>
<!--load the merge file -->
<xsl:variable name="emps"
select="document('#expandPath("/")#\doc2.xml')"/>
<!--- this line references and XML file to be combined
with the main file,
I wonder if there is a way to use an XML document in memory
here? --->
<!-- combine the files -->
<xsl:template match="/">
<root>
<!-- select all the child nodes of the root tag in the
main file -->
<xsl:for-each select="root/child::*">
<!-- copy the member tag -->
<xsl:copy-of select="."/>
</xsl:for-each>
<!-- and all the child nodes of the root tag in the merge
file -->
<xsl:for-each select="$emps/root/child::*">
<!-- copy the member tag -->
<xsl:copy-of select="."/>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
</cfsavecontent>
</cfoutput>
<!--- create a combined xml document --->
<cfset doc2 = XMLparse(XMLtransform(doc1,transformer))>
<cfdump var="#doc2#" label="Merged by XSLT"
expand="no"> -
How to convert Xml Document into orcale tempary table
i am creating xml document into java and passing this xml into oracle database and i need to fetch this xml into result set | rowset.
Xml Structure
<Department deptno="100">
<DeptName>Sports</DeptName>
<EmployeeList>
<Employee empno="200"><Ename>John</Ename><Salary>33333</Salary>
</Employee>
<Employee empno="300"><Ename>Jack</Ename><Salary>333444</Salary>
</Employee>
</EmployeeList>
</Department>
i need like this format
Deptno DeptName empno Ename Salary
100 Sports 200 Jhon 2500
100 Sports 300 Jack 3000It does depend on your version as odie suggests.
Here's a way that will work in 10g...
SQL> ed
Wrote file afiedt.buf
1 with t as (select xmltype('<Department deptno="100">
2 <DeptName>Sports</DeptName>
3 <EmployeeList>
4 <Employee empno="200"><Ename>John</Ename><Salary>33333</Salary>
5 </Employee>
6 <Employee empno="300"><Ename>Jack</Ename><Salary>333444</Salary>
7 </Employee>
8 </EmployeeList>
9 </Department>
10 ') as xml from dual)
11 --
12 -- End of test data, Use query below
13 --
14 select x.deptno, x.deptname
15 ,y.empno, y.ename, y.salary
16 from t
17 ,xmltable('/'
18 passing t.xml
19 columns deptno number path '/Department/@deptno'
20 ,deptname varchar2(10) path '/Department/DeptName'
21 ,emps xmltype path '/Department/EmployeeList'
22 ) x
23 ,xmltable('/EmployeeList/Employee'
24 passing x.emps
25 columns empno number path '/Employee/@empno'
26 ,ename varchar2(10) path '/Employee/Ename'
27 ,salary number path '/Employee/Salary'
28* ) y
SQL> /
DEPTNO DEPTNAME EMPNO ENAME SALARY
100 Sports 200 John 33333
100 Sports 300 Jack 333444
SQL>If the XML is a string e.g. a CLOB then it can easily be converted to XMLTYPE using the XMLTYPE function. -
How to ftp XML document into a XML type which is not created by itself.
Hi,
1.
I have a table call SNPLEX_DESIGN which is created automaticly when I register a snplex_design.xsd XML schema.( Oracle creates it through the xdb:defaultTable="SNPLEX_DESIGN attribute). and it is created using SNPLEX user account.
2.
I also created a folder (resource) call /home/SNPLEX/Orders. which is used to hold all the incoming XML document.
3.
I created another user account call SNPLEX_APP, which is the only user account allowed to FTP XML document into /home/SNPLEX/Orders folder.
Isuues,
If I login as SNPLEX user, I can ftp XML document into the folder and TABLE (the file size = 0). But If I login as SNPLEX_APP user account, I can only ftp XML document into the folder, but Oracle doesn't store the document into the table( becuase the files size shows a number).
I have granted all the ACL privileges on the /home/SNPEX/Orders folder to SNPLEX_APP hrough OEM.
DO I miss anything. Any helps will be great appreciated. Resolve this issues is very import to us, sicne we are on a stage to roll system into production.
Regards,
JinsenIN order for a registered schema to be available to other users the schema must be registered as a GLOBAL, rather than a LOCAL Schema. This is controlled by the third agument passed to registerSChema, and the default is local. Note that you will also need to explicity grant appropriate permissions on any tables created by the schema registration process to other users who will be loading or reading data from these tables.
Maybe you are looking for
-
How to change code in MV50AFZZ
HI, i want change the code in Include MV50AFZZ (FORM USEREXIT_LGORT_DETERMINATION). this include is provided for user exits. can any one please help me how to change the code in this Include and what are the necessary actions i need to take.
-
Hi, I'm having an issue with respect to deploying my project application in weblogic application server 9.2. I'm creating a war file in which I'm packaging all application contents which includes the /WEBINF/classes contents. I deployed the war in ad
-
IPhoto: thumbnails, links, originals
Photo thumbnails do not distinguiish which are originals and which are links to originals. If one inadvertantly deletes and original, the thumbnail still looks fine but I know or no way of recreating an original from one. Two questions: 1 How does
-
How do you differentiate IDOC XML format and ordinary XML format
how do you differentiate IDOC XML format and ordinary XML format since they are used by IDOC adapter and RFC adapter???
-
How to get out of recovery mode
went to update my iPhone 4. it told me to connect it to iTunes. after I connected to iTunes It then told me it was in recovery mode and I need to restore it. is there anyway I can get it out of recovery mode with out restoring it and deleting everyth