Writing XML to oracle table
Hi All,
Help! Could someone tell me how to insert an empty string ( not null ) in a table using XML?
e.g if I had this table TEST
Name Null? Type
COL1 NOT NULL CHAR(5)
COL2 NOT NULL CHAR(1)
and this xml
<?xml version="1.0"?>
<tests>
<test>
<COL1>PPPPP</COL1>
<COL2> </COL2>
<test>
<tests>
I use OracleXmlSave to insert this xml into the database and I get this error
"Cannot insert null into TEST.COL2"
but I am actually trying to insert a blank.
Anybody came across this problem and knows how to fix it?
Thanks a lot!!!!
I fixed my problem;
I changed my xml to this
<?xml version="1.0"?>
<tests>
<test>
<COL1>PPPPP</COL1>
<COL2><![CDATA[ ]]></COL2>
<test>
<tests>
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by pearlph:
Hi All,
Help! Could someone tell me how to insert an empty string ( not null ) in a table using XML?
e.g if I had this table TEST
Name Null? Type
COL1 NOT NULL CHAR(5)
COL2 NOT NULL CHAR(1)
and this xml
<?xml version="1.0"?>
<tests>
<test>
<COL1>PPPPP</COL1>
<COL2> </COL2>
<test>
<tests>
I use OracleXmlSave to insert this xml into the database and I get this error
"Cannot insert null into TEST.COL2"
but I am actually trying to insert a blank.
Anybody came across this problem and knows how to fix it?
Thanks a lot!!!!
<HR></BLOCKQUOTE>
null
Similar Messages
-
Generating xml from oracle table
Hi,
I want to generate xml form an oracle table and using sql developer, oracle express 10g, xdk forler is also unzipped under oracle express folder, still getting following error: code used
var g_clob clob;
declare
l_ctx dbms_xmlquery.ctxHandle;
l_clob clob;
begin
l_ctx := dbms_xmlquery.newContext('select * from scott.emp');
dbms_lob.createtemporary(:g_clob,true,dbms_lob.session);
:g_clob := dbms_xmlquery.getXml(l_ctx);
end;
/ORA-06550: line 2, column 14:
PLS-00201: identifier 'DBMS_XMLQUERY.CTXHANDLE' must be declared
Thanks in advanceHi,
DBMS_XMLQUERY is a wrapper for methods from the Java class "oracle.xml.sql.query.OracleXMLStaticQuery".
The problem is that Oracle 10g XE doesn't have a JVM, so you can't use this package.
Use DBMS_XMLGEN instead, it provides similar functionalities and is more efficient (C-based) :
SQL> var g_clob clob
SQL> DECLARE
2 l_ctx dbms_xmlgen.ctxHandle;
3 BEGIN
4 l_ctx := dbms_xmlgen.newContext('select * from scott.emp');
5 :g_clob := dbms_xmlgen.getXML(l_ctx);
6 dbms_xmlgen.closeContext(l_ctx);
7 END;
8 /
PL/SQL procedure successfully completed.
SQL> set long 5000
SQL> set pages 1000
SQL> print g_clob
G_CLOB
<?xml version="1.0"?>
<ROWSET>
<ROW>
<EMPNO>7369</EMPNO>
<ENAME>SMITH</ENAME>
<JOB>CLERK</JOB>
<MGR>7902</MGR>
<HIREDATE>17/12/80</HIREDATE>
<SAL>800</SAL>
<DEPTNO>20</DEPTNO>
</ROW>
<ROW>
<EMPNO>7499</EMPNO>
<ENAME>ALLEN</ENAME>
<JOB>SALESMAN</JOB>
<MGR>7698</MGR>
<HIREDATE>20/02/81</HIREDATE>
<SAL>1600</SAL>
<COMM>300</COMM>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7521</EMPNO>
<ENAME>WARD</ENAME>
<JOB>SALESMAN</JOB>
<MGR>7698</MGR>
<HIREDATE>22/02/81</HIREDATE>
<SAL>1250</SAL>
<COMM>500</COMM>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7566</EMPNO>
<ENAME>JONES</ENAME>
<JOB>MANAGER</JOB>
<MGR>7839</MGR>
<HIREDATE>02/04/81</HIREDATE>
<SAL>2975</SAL>
<DEPTNO>20</DEPTNO>
</ROW>
<ROW>
<EMPNO>7654</EMPNO>
<ENAME>MARTIN</ENAME>
<JOB>SALESMAN</JOB>
<MGR>7698</MGR>
<HIREDATE>28/09/81</HIREDATE>
<SAL>1250</SAL>
<COMM>1400</COMM>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7698</EMPNO>
<ENAME>BLAKE</ENAME>
<JOB>MANAGER</JOB>
<MGR>7839</MGR>
<HIREDATE>01/05/81</HIREDATE>
<SAL>2850</SAL>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7782</EMPNO>
<ENAME>CLARK</ENAME>
<JOB>MANAGER</JOB>
<MGR>7839</MGR>
<HIREDATE>09/06/81</HIREDATE>
<SAL>2450</SAL>
<DEPTNO>10</DEPTNO>
</ROW>
<ROW>
<EMPNO>7839</EMPNO>
<ENAME>KING</ENAME>
<JOB>PRESIDENT</JOB>
<HIREDATE>17/11/81</HIREDATE>
<SAL>5000</SAL>
<DEPTNO>10</DEPTNO>
</ROW>
<ROW>
<EMPNO>7844</EMPNO>
<ENAME>TURNER</ENAME>
<JOB>SALESMAN</JOB>
<MGR>7698</MGR>
<HIREDATE>08/09/81</HIREDATE>
<SAL>1500</SAL>
<COMM>0</COMM>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7900</EMPNO>
<ENAME>JAMES</ENAME>
<JOB>CLERK</JOB>
<MGR>7698</MGR>
<HIREDATE>03/12/81</HIREDATE>
<SAL>950</SAL>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7902</EMPNO>
<ENAME>FORD</ENAME>
<JOB>ANALYST</JOB>
<MGR>7566</MGR>
<HIREDATE>03/12/81</HIREDATE>
<SAL>3000</SAL>
<DEPTNO>20</DEPTNO>
</ROW>
<ROW>
<EMPNO>7934</EMPNO>
<ENAME>MILLER</ENAME>
<JOB>CLERK</JOB>
<MGR>7782</MGR>
<HIREDATE>23/01/82</HIREDATE>
<SAL>1300</SAL>
<DEPTNO>10</DEPTNO>
</ROW>
</ROWSET>Or, using SQL/XML functions :
SELECT XMLElement("ROWSET",
XMLAgg(
XMLElement("ROW",
XMLForest(empno, ename, job, mgr, hiredate, sal, comm, deptno)
).getClobVal()
FROM scott.emp
; -
Data from xml to oracle tables
Hi All,
I need to store data from the XML documents into appropriate tables in ORACLE. Note: I dont need to store the document itself, but the data in the document needs to be stored in the tables. What is the right way of doing this?
I previoulsy used SQLXML3.0 to load data from the XML documents to SQL server database ( .xsd will take care of the mapping), but we now need to store data into Oracle tables.
Thanks,There is a XMLDB demo authored by Mark Drake. This will explain a lot about Oracle XMLDB.
AFter reading, if you still have questions post back to the list
http://www.oracle.com/ultrasearch/wwws_otn/searchotn.jsp?p_Action=Search&p_Query=demo+xml -
Search a CLOB column(contains XML) in Oracle table
Hi,
I need help on how will i be able to search the data in a clob column that contains XML in an ORACLE table.
Thanks,
PSSWe are using 10g.. and database in which the table is located.. i just have a read only access .. so i am pulling all the data into a flat file (im using a shell script) and from there on i need to process the data... and my problem is how to pull the data in the CLOB using sql or whichever way.. if you can explain me with an example i would really appreciate it...
Thanks,
PSS -
Hi,
How can I read an xml.file read in an oracle table (invoice varchar2(20), invoice_line number, ship_date date, country varchar2(100))?
The xml looks like this:
<?xml version="1.0" encoding="utf-8" ?>
- <dataset xmlns="http://developer.cognos.com/schemas/xmldata/1/" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
- <!--
<dataset
xmlns="http://developer.cognos.com/schemas/xmldata/1/"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://developer.cognos.com/schemas/xmldata/1/ xmldata.xsd"
>
-->
- <metadata>
<item name="Invoice #" type="xs:string" length="42" />
<item name="Invoice Line" type="xs:string" length="10" />
<item name="Ship Date" type="xs:date" />
<item name="COUNTRY" type="xs:string" length="8" />
</metadata>
- <data>
- <row>
<value>26623</value>
<value>0001</value>
<value>2010-05-03</value>
<value>USA</value>
</row>
- <row>
<value>26624</value>
<value>0001</value>
<value>2010-05-03</value>
<value>USA</value>
</row>
- <row>
<value>26624</value>
<value>0003</value>
<value>2010-05-03</value>
<value>USA</value>
</row>
- <row>
<value>26625</value>
<value>0001</value>
<value>2010-05-03</value>
<value>USA</value>
</row>
</data>
</dataset>
Thnx, RobbertHi,
Possible solutions will depend on your db version, which you didn't give.
The following example assumes you're using 10gR2 :
CREATE TABLE invoices (
invoice varchar2(20),
invoice_line number,
ship_date date,
country varchar2(100)
DECLARE
xmldoc xmltype := xmltype(
'<?xml version="1.0" encoding="utf-8" ?>
<dataset xmlns="http://developer.cognos.com/schemas/xmldata/1/" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
<metadata>
<item name="Invoice #" type="xs:string" length="42" />
<item name="Invoice Line" type="xs:string" length="10" />
<item name="Ship Date" type="xs:date" />
<item name="COUNTRY" type="xs:string" length="8" />
</metadata>
<data>
<row>
<value>26623</value>
<value>0001</value>
<value>2010-05-03</value>
<value>USA</value>
</row>
<row>
<value>26624</value>
<value>0001</value>
<value>2010-05-03</value>
<value>USA</value>
</row>
<row>
<value>26624</value>
<value>0003</value>
<value>2010-05-03</value>
<value>USA</value>
</row>
<row>
<value>26625</value>
<value>0001</value>
<value>2010-05-03</value>
<value>USA</value>
</row>
</data>
</dataset>'
BEGIN
INSERT INTO invoices (invoice, invoice_line, ship_date, country)
SELECT invoice, invoice_line, to_date(ship_date, 'YYYY-MM-DD'), country
FROM XMLTable(
XMLNamespaces(default 'http://developer.cognos.com/schemas/xmldata/1/'),
'/dataset/data/row'
passing xmldoc
columns
invoice varchar2(20) path 'value[1]',
invoice_line number path 'value[2]',
ship_date varchar2(10) path 'value[3]',
country varchar2(100) path 'value[4]'
END;
/If your XML document resides outside the database, you may also access it directly through a DIRECTORY object :
CREATE OR REPLACE DIRECTORY xmldir AS 'C:\oracle\invoices\xml';
INSERT INTO invoices (invoice, invoice_line, ship_date, country)
SELECT invoice, invoice_line, to_date(ship_date, 'YYYY-MM-DD'), country
FROM XMLTable(
XMLNamespaces(default 'http://developer.cognos.com/schemas/xmldata/1/'),
'/dataset/data/row'
passing xmltype( bfilename('XMLDIR', 'invoices.xml'), nls_charset_id('AL32UTF8') )
columns
invoice varchar2(20) path 'value[1]',
invoice_line number path 'value[2]',
ship_date varchar2(10) path 'value[3]',
country varchar2(100) path 'value[4]'
);Some docs about XMLTable and XML querying with Oracle :
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions228.htm#CIHGGHFB
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb_xquery.htm#ADXDB1700
Edited by: odie_63 on 24 juin 2010 20:07 -
Create XML from oracle table if not null
Hello dear community,
I have a problem by creating an XML file in oracle and hope you could help me.
What I have is an table named "description" with three rows there:
person varchar2(50)
adress varchar2(50)
Nr number
Reading this table I am going to create an XML file like that:
Procedure Create_XML (iNr IN number, cXmlFile OUT clob) is
varPerson varchar2(50);
varAdress varchar2(50);
Begin
varPerson := ... ;
varAdress := ... ;
select
xmlserialize
content
xmlelement
"Head",
xmlelement
"Node",
xmlelement
"Line",
xmlelement("ATNAM", 'PERSON'),
xmlelement("ATWRT", PERSON),
xmlelement("ATFOR", varPerson)
xmlelement
"Line",
xmlelement("ATNAM", 'ADRESS'),
xmlelement("ATWRT", ADRESS),
xmlelement("ATFOR", varAdress)
indent
) as xml
into cXmlFile
from description
where Nr = iNr;
End Create_XML;
What I want to do, is just to take the value from the both rows "person" and "adress" and fill the xml file with additional info.
1. My first question is, if it is possible to create any kind of routine for the xmlelement "Line" instead of doing it all over and over again? How?
2. An other issue is very important to me: how can I check here if f.i. the row person is empty or not? If it is, the xmlelement "Line" with person information in it should not be created at all.
Any answer would really help me!
Thank you a lot in advance!Hi,
Could you elaborate a little on your first question?
Are you looking for something like :
SELECT xmlquery(
'<head>
<node>
for $i in ora:view("DESCRIPTION")/ROW[NR=$nr]/*[local-name()!="NR"]
return element Line {
element ATNAM {local-name($i)},
element ATWRT {$i/text()}
</node>
</head>'
passing sys_xmlgen(1) as "nr"
returning content
FROM dual;but since you use a specific variable for each "line" type, I don't see how we can generalize the construction of the line element. -
Error trying to insert xml into Oracle table
Hi -
I am trying to (a)read a row from emp table and output the results in xml format
and (b) insert this row to another emp_new table (same structure as emp).
When I run it here is what I get:
OUTPUT IS:
<?xml verions='1.0'?>
<Employee>
<Emp num="1">
<EMPNO>7369</EMPNO>
<ENAME>Smith</ENAME>
<JOB>Clerk</JOB>
<MGR>7902</MGR>
<HIREDATE>12/7/1980</HIREDATE>
<SAL>800</SAL>
<DEPTNO>20</DEPTNO>
</Emp>
</Employee>
Exception in thread "main" oracle.xml.sql.OracleXMLSQLException:
No rows to modify -- the row enclosing tag is missing. Specify
the correct row enclosing tag.
etc...
The row enclosing tag is given by setRowTag("Emp").
What's wrong here? Any ideas?
PS: To Ambrose Padilla: Your response was helpful. Thank you.
Program
import java.sql.*;
import oracle.xml.sql.query.*;
import oracle.jdbc.driver.*;
import oracle.xml.sql.dml.*;
class testXML
public static void main(String[] args) throws SQLException
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//initialize a JDBC connection
Connecton conn = DriverManager.getConnection("jdbc:oracle:thin:mytest:1521:acme", "scott", "tiger");
//initialize the OracleXMLQuery
OracleXMLQuery qry =
new OracleXMLQuery(conn,"select * from emp where rownum < 2");
// set the document name
qry.setRowsetTag("Employee");
// set the row element name
qry.setRowTag("Emp");
// get the XML result
String xmlString = qry.getXMLString();
// print result
System.out.println(" OUPUT IS:\n"+xmlString);
OracleXMLSave sav = new OracleXMLSave(conn,"emp_new");
sav.insertXML(xmlString);
sav.close();
}Try inserting
sav.setRowTag("emp");
before calling insertXML. -
Generate XML from Oracle Table Data
Hi All,
I am new to this network. I am also new to oracle XML package. I want a help for the below query.
CREATE TABLE EMP(ID NUMBER PRIMARY KEY, NAME VARCHAR2(10), PHONE NUMBER);
INSERT INTO EMP(ID,NAME,PHONE) VALUES (11,'Joy',1234);
INSERT INTO EMP(ID,NAME,PHONE) VALUES (22,'Mike',5678);
INSERT INTO EMP(ID,NAME,PHONE) VALUES (33,'Jason',NULL);
COMMIT;
I want to export the EMP table data in a XML file with the below format.
Required Output:
<?xml version="1.0" encoding="UTF-8"?><STATICDATA><EMP><ID>11</ID><NAME>Joy</NAME></EMP></STATICDATA>
<?xml version="1.0" encoding="UTF-8"?><STATICDATA><EMP><ID>22</ID><NAME>Mike</NAME></EMP></STATICDATA>
<?xml version="1.0" encoding="UTF-8"?><STATICDATA><EMP><ID>33</ID><NAME>Jason</NAME></EMP></STATICDATA>
I have used some XML functions and have written the below query.
select XMLROOT(XMLELEMENT(staticdata,XMLELEMENT(EMP,XMLELEMENT(ID,ID),XMLELEMENT(NAME,NAME))), version '1.0" encoding="UTF-8') xml FROM EMP;
output of my query:
<?xml version="1.0" encoding="UTF-8"?>
<STATICDATA>
<EMP>
<ID>11</ID>
<NAME>Joy</NAME>
</EMP>
</STATICDATA>
<?xml version="1.0" encoding="UTF-8"?>
<STATICDATA>
<EMP>
<ID>22</ID>
<NAME>Mike</NAME>
</EMP>
</STATICDATA>
<?xml version="1.0" encoding="UTF-8"?>
<STATICDATA>
<EMP>
<ID>33</ID>
<NAME>Jason</NAME>
</EMP>
</STATICDATA>
But i want the out as the required output above. every record in a single line. can any one help me in achieving the required output. also can i export all the columns of the table by some thing like select * from the table in XML file ?
Thanks,
Sartajuser13683418 wrote:
Hi All,
I am new to this network. I am also new to oracle XML package. I want a help for the below query.
CREATE TABLE EMP(ID NUMBER PRIMARY KEY, NAME VARCHAR2(10), PHONE NUMBER);
INSERT INTO EMP(ID,NAME,PHONE) VALUES (11,'Joy',1234);
INSERT INTO EMP(ID,NAME,PHONE) VALUES (22,'Mike',5678);
INSERT INTO EMP(ID,NAME,PHONE) VALUES (33,'Jason',NULL);
COMMIT;
I want to export the EMP table data in a XML file with the below format.
Required Output:
<?xml version="1.0" encoding="UTF-8"?><STATICDATA><EMP><ID>11</ID><NAME>Joy</NAME></EMP></STATICDATA>
<?xml version="1.0" encoding="UTF-8"?><STATICDATA><EMP><ID>22</ID><NAME>Mike</NAME></EMP></STATICDATA>
<?xml version="1.0" encoding="UTF-8"?><STATICDATA><EMP><ID>33</ID><NAME>Jason</NAME></EMP></STATICDATA>
I have used some XML functions and have written the below query.
select XMLROOT(XMLELEMENT(staticdata,XMLELEMENT(EMP,XMLELEMENT(ID,ID),XMLELEMENT(NAME,NAME))), version '1.0" encoding="UTF-8') xml FROM EMP;
output of my query:
<?xml version="1.0" encoding="UTF-8"?>
<STATICDATA>
<EMP>
<ID>11</ID>
<NAME>Joy</NAME>
</EMP>
</STATICDATA>
<?xml version="1.0" encoding="UTF-8"?>
<STATICDATA>
<EMP>
<ID>22</ID>
<NAME>Mike</NAME>
</EMP>
</STATICDATA>
<?xml version="1.0" encoding="UTF-8"?>
<STATICDATA>
<EMP>
<ID>33</ID>
<NAME>Jason</NAME>
</EMP>
</STATICDATA>
But i want the out as the required output above. every record in a single line.Why?
Some things output XML all as one stream, some things naturally display it structured. It doesn't matter as the XML is still the same because by it's very nature it is a structured data definition. Anything that reads XML will be able to read it whether it's on one line (streamed) or structured.
also can i export all the columns of the table by some thing like select * from the table in XML file ?A couple of ways of exporting XML to a file...
-- DBMS_XSLPROCESSOR.clob2file
-- outputs a clob to a file
DECLARE
ctx DBMS_XMLGEN.ctxtype;
BEGIN
ctx := DBMS_XMLGEN.newcontext ('select * from emp');
DBMS_XSLPROCESSOR.clob2file (DBMS_XMLGEN.getxml (ctx), 'TEMP', 'emp.xml');
DBMS_XMLGEN.closecontext (ctx);
END;
PL/SQL procedure successfully completed.or
..snip..
v_xml XMLTYPE;
v_doc XMLDOM.DOMDocument;
v_dir VARCHAR2(2000);
v_file VARCHAR2(2000);
BEGIN
v_xml := ... populate with XML ...;
v_dir := 'TEST_DIR'; -- directory object name (in UPPER CASE)
v_file := 'myfile.xml';
v_doc := DBMS_XMLDOM.NEWDOMDOCUMENT(v_xml);
DBMS_XMLDOM.WRITETOFILE(v_doc, v_dir||'\'||v_file, 'UTF-8');
DBMS_XMLDOM.FREEDOCUMENT(v_doc);
..snip.. -
Creating XML from Oracle Tables
Would it be possible to post me a snapshot of the ODI Flow diagram for an Oracle to XML conversion? Does the staging area have to be on the Target (XML)? What KMs & CM should be used? Can the XML be written straight back to an .xml file? What should the XML Schema look like?
These are the KMs I use: LKM-SQL to SQL; IKM-SQL Incremental Update; CKM-SQL.
My flow is straight from source (oracle) to target (xml), with staging area on target (doesn't feel right).
My Oracle Dataserver & Schema work fine. Not sure about the XML dataserver setup though - I think this is where the problem lies. These are my JDBC settings:
- com.sunopsis.jdbc.driver.xml.SnpsXmlDriver
- jdbc:snps:xml?f=E:\Oracle ODI\Member.xsd
I am evaluating ODI for a client and I wanted to throw together a quick demo showing how easily ODI can generate XML from any source. I know this is the case as I understand the concept of ODI's components - just haven't had time to read manuals thoroughly.
Many thanks for your help,
SteveHello,
1. Try to test the connection to the XML dataserver.
2. Create a model and reverse-engineer this dataserver. You'll see what the XML structure is mapped to immediately.
3. Integrate data to this model (using standard KM targeting "SQL").
You can put the staging area on the Oracle source or in the XML driver if you want. Both solutions will work.
just haven't had time to read manuals thoroughly.I think you should quickly read the "Sunopsis ODI with... XML" section in the manual.
It is not very long and very helpful. Have also a quick look at the XML driver documentation.
Regards,
-FX -
XML data into Oracle Tables. XML file on Application Server.Oracle Apps R12
Hi All,
My Database version : 11.2.0.2.0
I have an XML file which needs to be loaded into the Database Tables. How ever i do not want to use the XMLTYPE as given below
insert into test1 (
SELECT PrcDate, PmtType, PmtStatus, PmtTypeCount, PmtTypeAmt
FROM XMLTABLE(
'/WFPaymentAck/RejectedDom1ACH'
PASSING XMLTYPE( BFILENAME('ECX_UTL_LOG_DIR_OBJ','wf_test_xml.XML'), NLS_CHARSET_ID('UTF8') )
COLUMNS
PrcDate VARCHAR2(2000) PATH '@PrcDate' ,
PmtType VARCHAR2(2000) PATH '@PmtType' ,
PmtStatus VARCHAR2(100) PATH '@PmtStatus' ,
PmtTypeCount VARCHAR2(100) PATH 'PmtTypeCount' ,
PmtTypeAmt VARCHAR2(100) PATH 'PmtTypeAmt'
Because this way the XML file needs to reside on the DB server.
I am looking into other option of loading the XML file into a CLOB column of a table and reading it from that column.
I did a couple of tests and feel that this way also the XML file has to reside on the Database Server itself. I am not sure if this is correct or if there is any problem with our TEST instance.
++Can anyone let me know if i need to have the XML file on the DB server instead of the Application server to load into a CLOB column of table ??++
++Or++
++Is there any other workaround for me to load XML into Oracle Tables, while having the XML file on Application Server.++
Your immediate help is appreciated. I need to get past this ASAP.
Thanks in Advance.
VJ1) Are you asking me to create a folder on Database directory which points to a folder on the Apps server ?I suggest creating an Oracle directory object (a database object) pointing to a real location (folder) on Application server.
we DONOT want a hand shake between the DB Server and the APPS server.I don't see where the problem is.
I'm not familiar with Apps R12 but there's no doubt the two servers are already communicating, at least App server should be able to access the DB for the whole thing to run.
As I said :
One way or another, the data has to make its way to the database, there's no workaround to that.How do you imagine the data will end up in a database table if it doesn't come to the DB server?
There's no magical method out there, both servers have to communicate at some point.
About client-server approaches (client being here the App server), you can read about accessing the XML DB repository in the XML DB Developer's Guide : http://download.oracle.com/docs/cd/E11882_01/appdev.112/e23094/toc.htm
Other option : SQL*Loader can load a CLOB, or an XMLType column too
Edited by: odie_63 on 19 déc. 2011 20:22 -
Insert data into oracle table from XML file
I need to insert data into oracle table from XML file
If anybody handled this type of scenario, Please let me know how to insert data into oracle table from XML file
Thanks in advanceThe XML DB forum provides the best support for XML topics related to Oracle.
Here's the FAQ on that forum:
XML DB FAQ
where there are plenty of examples of shredding XML into Oracle tables and such like. ;) -
Parsing XML file & insert into Oracle Tables
Hi,
Following is a sample xml file which is an input for a oracle procedure :
<Sales ID="1" CreatedDate="16-Jan-2007" CreatedTime="16:09:40">
<Customer ID="1" Name="Scott" Address="City1">
<Order ID="1" Date="15-Jan-2007" TotItems="2" Value="200">
<Item ID="01" Name="Chocolate" Qty="2" Amount="80" />
<Item ID="03" Name="Biscuit" Qty="5" Amount="120" />
</Order>
</Customer>
<Customer ID="2" Name="Tiger" Address="City2">
<Order ID="1" Date="15-Jan-2007" TotItems="1" Value="500">
<Item ID="01" Name="Pizza" Qty="3" Amount="500" />
</Order>
</Customer>
<User ID="ABC" Name="TestUser" LastLogin="16-Jan-2007" />
<City Code="NY" Name="New York" />
<City Code="NJ" Name="New Jersy" />
</Sales>
I have individual tables for Sales, Customer, Order, Item, User & City tags with proper referential constraints. I have to parse the xml & have to insert the corresponsing tables for each & every tag if the ID in individual tag does not exists in the table. If the ID already exist, then, I have to update other attributes in the table for the corresponding ID.
Can anyone suggest me the simplest way to perform the above said scenario?Dera Michael,
Sorry for the confusing previous reply. I went through your solution again and tried for my XML File.
I have stored the XML File in table XXLF_DS_XML.Should I make use of the table in the below query.
Here is my SQL Query erroring Out
SQL> SELECT EXTRACTVALUE(s.COLUMN_VALUE,
2 '/Header@orderID') ID
3 ,EXTRACTVALUE(c.COLUMN_VALUE,
4 '/Detail@lineNumber') lienum
5 ,EXTRACTVALUE(t.COLUMN_VALUE,
6 '/Detail/Tax@currency') currency
7 ,EXTRACTVALUE(t.COLUMN_VALUE,
8 '/Detail/Tax/Money') customer_name
9 FROM TABLE(XMLSEQUENCE(EXTRACT(XMLTYPE('- <Recordset>
10 - <Header dueDate="2007-01-17T16:09:05" orderDate="2004-01-17" orderID="0009" transactionID="1389"
type="new">
11 <KeyIndex>2</KeyIndex>
12 - <BillTo>
13 - <Address addressID="5619" isoCountryCode="US">
14 <Name>fMat</Name>
15 - <PostalAddress name="default">
16 <Street>34545</Street>
17 <City>dfgfg</City>
18 <State>AZ</State>
19 <PostalCode>85086-1693</PostalCode>
20 <County>Maricopa</County>
21 <Country>US</Country>
22 </PostalAddress>
23 <Email name="default">[email protected]</Email>
24 </Address>
25 </BillTo>
26 <PromotionCode />
27 - <SubTotal>
28 <Money currency="USD">32.49</Money>
29 </SubTotal>
30 - <Tax>
31 <Money currency="USD">2.32</Money>
32 <Description />
33 </Tax>
34 - <Shipping>
35 <Money currency="USD">8.95</Money>
36 <Description />
37 </Shipping>
38 </Header>
39 - <Detail lineNumber="1" quantity="1">
40 - <ItemDetail>
41 - <UnitPrice>
42 <Money currency="USD">29.99</Money>
43 </UnitPrice>
44 <ShortName>Little;reg; pxxxx® Learning System</ShortName>
45 </ItemDetail>
46 - <Tax>
47 <Money currency="USD">1.68</Money>
48 <Description />
49 - <TaxDetail category="sales">
50 - <TaxAmount>
51 <Money currency="USD">1.68</Money>
52 </TaxAmount>
53 <TaxLocation>AZ</TaxLocation>
54 </TaxDetail>
55 </Tax>
56 </Detail>
57 - <Detail lineNumber="2" quantity="1">
58 - <ItemDetail>
59 - <UnitPrice>
60 <Money currency="USD">29.99</Money>
61 </UnitPrice>
62 <ShortName>Little;reg; pxxxx® Learning System</ShortName>
63 </ItemDetail>
64 - <Tax>
65 <Money currency="USD">1.68</Money>
66 <Description />
67 - <TaxDetail category="sales">
68 - <TaxAmount>
69 <Money currency="USD">1.68</Money>
70 </TaxAmount>
71 <TaxLocation>AZ</TaxLocation>
72 </TaxDetail>
73 </Tax>
74 - <Tax>
75 <Money currency="USD">0.68</Money>
76 <Description />
77 - <TaxDetail category="sales">
78 - <TaxAmount>
79 <Money currency="USD">0.68</Money>
80 </TaxAmount>
81 <TaxLocation>DISTRICT</TaxLocation>
82 </TaxDetail>
83 </Tax>
84 </Detail>
85 </Recordset>'),'/Recordset/Header'))) s
86 ,TABLE(XMLSEQUENCE(EXTRACT(c.COLUMN_VALUE,
87 '/Recordset/Detail'))) c
88 ,TABLE(XMLSEQUENCE(EXTRACT(t.COLUMN_VALUE,
89 '/Recordset/Detail/Tax'))) t
90 /
,TABLE(XMLSEQUENCE(EXTRACT(c.COLUMN_VALUE,
ERROR at line 86:
ORA-00904: "C"."COLUMN_VALUE": invalid identifier
Here is my XML Data
<Recordset>
<Header dueDate="2007-01-17T16:09:05" orderDate="2004-01-17" orderID="0009" transactionID="1389"
type="new">
<KeyIndex>2</KeyIndex>
<BillTo>
<Address addressID="5619" isoCountryCode="US">
<Name>fMat</Name>
<PostalAddress name="default">
<Street>34545 </Street>
<City>dfgfg</City>
<State>AZ</State>
<PostalCode>85086-1693</PostalCode>
<County>Maricopa</County>
<Country>US</Country>
</PostalAddress>
<Email name="default">[email protected]</Email>
</Address>
</BillTo>
<PromotionCode/>
<SubTotal>
<Money currency="USD">32.49</Money>
</SubTotal>
<Tax>
<Money currency="USD">2.32</Money>
<Description/>
</Tax>
<Shipping>
<Money currency="USD">8.95</Money>
<Description/>
</Shipping>
</Header>
<Detail lineNumber="1" quantity="1">
<ItemDetail>
<UnitPrice>
<Money currency="USD">29.99</Money>
</UnitPrice>
<ShortName>Little;reg; pxxxx® Learning System </ShortName>
</ItemDetail>
<Tax>
<Money currency="USD">1.68</Money>
<Description/>
<TaxDetail category="sales">
<TaxAmount>
<Money currency="USD">1.68</Money>
</TaxAmount>
<TaxLocation>AZ</TaxLocation>
</TaxDetail>
</Tax>
</Detail>
<Detail lineNumber="2" quantity="1">
<ItemDetail>
<UnitPrice>
<Money currency="USD">29.99</Money>
</UnitPrice>
<ShortName>Little;reg; pxxxx® Learning System </ShortName>
</ItemDetail>
<Tax>
<Money currency="USD">1.68</Money>
<Description/>
<TaxDetail category="sales">
<TaxAmount>
<Money currency="USD">1.68</Money>
</TaxAmount>
<TaxLocation>AZ</TaxLocation>
</TaxDetail>
</Tax>
<Tax>
<Money currency="USD">0.68</Money>
<Description/>
<TaxDetail category="sales">
<TaxAmount>
<Money currency="USD">0.68</Money>
</TaxAmount>
<TaxLocation>DISTRICT</TaxLocation>
</TaxDetail>
</Tax>
</Detail>
</Recordset>
Thanks -
Hello friends,
Can you please help me with the following requirements?
I have a xml structure like this
<?xml version="1.0"?>
<data>
<var name="document">
<string>Sales Order</String>
</var>
<var name="results">
<recordset rowcount="2">
<field name="sales_num">
<string>12345</string>
<string>A0192</string>
</field>
<field name="ord_qty">
<string>10</string>
<string>50</string>
</field>
</recordset>
</var>
</data>
I have to read this xml file and copy the data to the Oracle table
Sales Table
CREATE TABLE SALES
SALES_NUM VARCHAR2(20 BYTE),
ORD_QTY NUMBER(4)
Expected Result
x. Sales Num Ord Qty
1. 12345 10
2. A0192 50
I tried to follow the approach provided in this link http://www.oracle-base.com/articles/9i/ParseXMLDocuments9i.php . But it doesn't work with the XML structure I have.
Thanks,
Maheshplease let me know the solution as well. i need this
-
How to extract data from xml and insert into Oracle table
Hi,
I have a large xml file. which will have hundreds of the following transaction tags having column names and there values.
There is a table one of the schema with coulums "actualCostRate","billRate"....etc.
I need to extract the values of these columns and insert into the table
<Transaction actualCostRate="0" billRate="0" chargeable="1" clientID="NikuUK" chargeCode="LCOCD1" externalID="L-RESCODE_UK1-PROJ_UK_CNT_GBP-37289-8" importStatus="N" projectID="TESTPROJ" resourceID="admin" transactionDate="2002-02-12" transactionType="L" units="11" taskID="5017601" inputTypeCode="SALES" groupId="123" voucherNumber="ABCVDD" transactionClass="ABCD"/>
<Transaction actualCostRate="0" billRate="0" chargeable="1" clientID="NikuEU" chargeCode="LCOCD1" externalID="L-RESCODE_US1-PROJ_EU_STD2-37291-4" importStatus="N" projectID="TESTPROJ" resourceID="admin" transactionDate="2002-02-04" transactionType="L" units="4" taskID="5017601" inputTypeCode="SALES" groupId="124" voucherNumber="EEE222" transactionClass="DEFG"/>Re: Insert from XML to relational table
http://www.google.ae/search?hl=ar&q=extract+data+from+xml+and+insert+into+Oracle+table+&btnG=%D8%A8%D8%AD%D8%AB+Google&meta= -
How to insert Serialised Object(XML DOM) into Oracle Table(as BLOB or CLOB)
we need a urgent help. How can we insert and retrieve the XML Document DOM Object into Oracle Table.Actually we used BLOB for insert the DOM Object,its inserted finely but we have a problem in retrieving that object, we got error when v're retrieving. so could you anyone tell us what's this exact problem and how can we reslove this problem If anyone knows or used this kind operation, pls let us know immediately.
Thanks in advance.Please repost your question in the appropriate XML forum, http://forums.oracle.com/forums/index.jsp?cat=51
Maybe you are looking for
-
Just got the FIOS service this Friday. I'm very happy with the internet. Very fast! The TV, I'm not so happy about. Having come from AT&T U-Verse, and Time Warner Cable before that, I've gotten used to having the HBO channel lineup (or any premium ch
-
Need advice about migrating data
I just bought my daughter a new MacBook. She launched the Migration Assistant tool to transfer her data from her iMAC. Both computers are running Leopard, and the iMAC is just 1 year old. The problem is that she set up the transfer to go through our
-
How do i migrate my emails and favorites from Yahoo?
I want to switch to Foxfire as my browser and homepage. However, all my favorites are on YAHOO as well as all past emails I've decided to keep and any folders I've created to hold emails of certain catergories. What I want to know is how do I bring a
-
Music not showing up on 4S, but shows up in iTunes
I have the iPhone 4S. My music is not syncing properly. All of my music is on my itunes. My music shows up as on my phone when look at my library when the phone is connected to itunes via my cord. But when I look at my library on my phone, my rec
-
Hello All, are there out of Broadcast safe warnings in AE? I started doing some color correction and I don't want to end up with colors that are not safe Thanks