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=
Similar Messages
-
How to extract data from CLOB and insert them into DB?
Hi PL/SQL Gurus,
I have no experience in PL/SQL, but I have a requirement now where I have to use it.
We have a table with 10 columns, one of them is a CLOB and it holds XML data. The XMLs are very huge in size.
Two new columns are added to the table and the data has to be filled for the existing records from the corresponding XML. The XML has all the data as attributes. I started searching on the internet and tried if I could extract the data out of XML.
SELECT extractValue(value(x), '/Order/Package/@Code',
'xmlns:ns0="http://mycompany.com/Order/OrderType.xsd"' )
FROM ORDER_TABLE A
, TABLE(
XMLSequence(
extract(
xmltype(A.XML_DATA)
, '/ns0:Root'
, 'xmlns:ns0="http://mycompany.com/Order/OrderType.xsd"'
) x;
But this isn't working. Could anyone please provide some ideas.
I just want to confirm that I am able to extract data. Once this is done I would like to create a procedure so that all the existing records can be updated.
Thanks in advance.
Regards,
FazzyCan this be acheived using a SQL statement.Yes, you can do it with the DML error logging clause.
Here's a quick example I've just set up :
Base table
SQL> create table order_table (
2 order_id number,
3 package_code varchar2(30),
4 package_desc varchar2(100),
5 xml_data clob
6 );
Table created
SQL> alter table order_table add constraint order_table_pk primary key (order_id);
Table altered
Adding data...
SQL> insert into order_table (order_id, xml_data)
2 values (1, '<?xml version="1.0" encoding="UTF-8"?>
3 <ns0:Root xmlns:ns0="http://mycompany.com/Order/OrderType.xsd" BookingDate="2009-06-07">
4 <ns1:OrderKey xmlns:ns1="http://mycompany.com/Order/OrderKeyTypes.xsd" SystemCode="THOMAS" Id="458402-TM1" Version="1"/>
5 <ns0:Package Code="0001" Desc="ProductName1"/>
6 <ns0:PromotionGroup Code="DSP" Name="OrderThomasPortal"/>
7 <ns0:Promotion Code="TH902" Name="OrderThomasPortal" SellingName="OrderThomasPortal" BackOfficeName="OrderThomasPortal"/>
8 <ns0:FinancialSupplier Code="HHT" Name="NYOrdSupp"/>
9 <ns0:SellingCurrency Code="EUR" Name="Euro"/>
10 <ns0:Owner ClientId="02654144" ClientMandator="T" ClientSystem="ROSY"/>
11 <ns0:Agent PersonInAgency="5254" AgentCode="000009" CommissionAmount="2.8" CommissionDueDate="2009-07-01+02:00" VatOnCommission="0"/>
12 </ns0:Root>');
1 row inserted
SQL> insert into order_table (order_id, xml_data)
2 values (2, '<?xml version="1.0" encoding="UTF-8"?>
3 <ns0:Root xmlns:ns0="http://mycompany.com/Order/OrderType.xsd" BookingDate="2009-06-07">
4 <ns1:OrderKey xmlns:ns1="http://mycompany.com/Order/OrderKeyTypes.xsd" SystemCode="THOMAS" Id="458402-TM1" Version="1"/>
5 <ns0:Package Code="0002" Desc="ProductName2/>
6 <ns0:PromotionGroup Code="DSP" Name="OrderThomasPortal"/>
7 <ns0:Promotion Code="TH902" Name="OrderThomasPortal" SellingName="OrderThomasPortal" BackOfficeName="OrderThomasPortal"/>
8 <ns0:FinancialSupplier Code="HHT" Name="NYOrdSupp"/>
9 <ns0:SellingCurrency Code="EUR" Name="Euro"/>
10 <ns0:Owner ClientId="02654144" ClientMandator="T" ClientSystem="ROSY"/>
11 <ns0:Agent PersonInAgency="5254" AgentCode="000009" CommissionAmount="2.8" CommissionDueDate="2009-07-01+02:00" VatOnCommission="0"/>
12 </ns0:Root>');
1 row inserted
SQL> commit;
Commit complete
{code}
Note that the second row inserted contains a not well-formed XML (no closing quote for the /Root/Package/@Desc attribute).
*Creating the error logging table...*
{code}
SQL> create table error_log_table (
2 ora_err_number$ number,
3 ora_err_mesg$ varchar2(2000),
4 ora_err_rowid$ rowid,
5 ora_err_optyp$ varchar2(2),
6 ora_err_tag$ varchar2(2000)
7 );
Table created
{code}
*Updating...*
{code}
SQL> update (
2 select extractvalue(doc, '/ns0:Root/ns0:Package/@Code', 'xmlns:ns0="http://mycompany.com/Order/OrderType.xsd"') as new_package_code
3 , extractvalue(doc, '/ns0:Root/ns0:Package/@Desc', 'xmlns:ns0="http://mycompany.com/Order/OrderType.xsd"') as new_package_desc
4 , package_code
5 , package_desc
6 from (
7 select package_code
8 , package_desc
9 , xmltype(xml_data) doc
10 from order_table t
11 )
12 )
13 set package_code = new_package_code
14 , package_desc = new_package_desc
15 log errors into error_log_table ('My update process')
16 reject limit unlimited
17 ;
1 row updated
SQL> select order_id, package_code, package_desc from order_table;
ORDER_ID PACKAGE_CODE PACKAGE_DESC
1 0001 ProductName1
2
{code}
One row has been updated as expected, the other has been rejected and logged into the error table :
{code}
SQL> select * from error_log_table;
ORA_ERR_NUMBER$ ORA_ERR_MESG$ ORA_ERR_ROWID$ ORA_ERR_OPTYP$ ORA_ERR_TAG$
31011 ORA-31011: XML parsing failed AAAF6PAAEAAAASnAAB U My update process
ORA-19202: Error occurred in XML processing
LPX-00244: invalid use of less-than ('<') character (use <)
Error at line 5
ORA-06512: at "SYS.XMLTYPE", line 272
ORA-06512: at line 1
{code} -
Extract Data from XML and Load into table using SQL*Loader
Hi All,
We have a XML file (sample.xml) which contains credit card transaction information. We have a standard SQL*Loader control file which loads the data from a flat file and the control file code is written as position based method. Our requirement is to use this control file as per our requirement(i.e) load the data into the table from our XML file), But we need help in converting the XML to a flat file or Extract the data from the XML tags and pass the information to the control file and in turn it loads the table.
Your suggestion is highly appreciated.
Thanks in advanceHi,
First of all go to PSA maintanance ( Where you will see PSA records ).
Goto list---> Save-> File---> Spreadsheet (Choose Radio Button)
> Give the proper file name where you want to download and then-----> Generate.
You will get ur PSA data in Excel Format.
Thanks
Mayank -
Hi to all,
I have flat files in different location through FTP i need to fetch those files and load in the relavant table of the database.
Please share me the query to do it ..You would need a ForEach Loop to iterate though the files. Initially the FTP task will pull the files from locations to a landing folder. Once thats done the ForEachLoop will iterate through files in the folder and will have a data flow task inside to transfer
file data to tables.
If you want a more secure option you can also use SFTP (Secured FTP) and can implement it using free WinSCP clinet. I've explained a method of doing it fo dynamic files here
http://visakhm.blogspot.in/2012/12/implementing-dynamic-secure-ftp-process.html
for iterating through files see this example
http://visakhm.blogspot.in/2012/05/package-to-implement-daily-processing.html
you may not need the validation step inside the loop in your case
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to extract data from XML file with JavaScript
HI All
I am new to this group.
Can anybody help me regarding XML.
I want to know How to extract data from XML file with JavaScript.
And also how to use API for XML
regards
NagarajuThis is a Java forum.
JavaScript is something entirely different than Java, even though the names are similar.
Try another website with forums about JavaScript.
For example here: http://www.webdeveloper.com/forum/forumdisplay.php?s=&forumid=3 -
Get the data from excel and insert into the database
I want to read the data from excel file, get the data from excel and insert into the database.
You can use the Apache POI HSSF API to read data from Excel files and you can use the Sun JDBC API to insert data in database.
This has nothing to do with JSP/JSTL. -
Read data from Excel and write into oracle database
Hi
I want to know how can i read data from excel and write into oracle database using java.Kindly help me out to find a solution.
Thanks and Regards
NeetaHai,
I am suggesting the solution.
I will try out and let u know soon.
Make a coma separated file from your excel file.
Assuming that your requirement allows to make a csv file.
This file may be passed as an file object to be read by java.Using JDBC you must be able to populate the data base.You can also use String Tokenizer if needed.
You do not want to go via sql Loader?
For reading the excel file itself do you want java? -
How to Extract Data from SAP and Load it into Essbase
Hi All,
Can you recommend some ways to extract data from SAP and load it into Essbase?. I have no knowledge about SAP, not sure how I can perform this task. Can I use ODI for this job?
Thankshi,
Not sure if this helps but give a try
you can create connection from EAS to SAP .. using a plug-in .. if you have access to oracle Support go for [ID 968961.1]
or
below are steps
1. In EASPATH\console, open components.xml in a text editor.
2. Under <PluginList>, enter <Plugin archiveName="SAP" packageName="com.essbase.eas.sap.ui"/> before the closing </PlugIn> tag.
3. Save and close the file.
4. In EASPATH\console\bin, open admincon.lax in a text editor.
5. Search for lax.class.path= and append ;..\lib\sap_client.jar;..\lib \sap_common.jar to the entry. Save and close the file.
6. In EASPATH\server\bin, open adminsvr.lax in a text editor.
7. Search for lax.nl.java.option.additional, and append -DRFC_INI=EASPATH\server\saprfc.ini. Save and close the file.
8. Create a new environment variable, RFC_INI, with a value of EASPATH\server\saprfc.ini
9. Copy librfc.dll andsapjcorfc.dll to EASPATH\server\bin. You may need to obtain these files from SAP.
let me know if it works :) -
How to fetch data from XML and store it in internal table
Hi All,
Can anyone help me out, in fetching data from xml and store it in an internal table. Is there any standard function module is there?
Regards,
Karthickto do this you can either develop a XSLT program and use it with CALL TRNSFORMATION key word to tranform the XML into itab .
(search the ABAP General forum, i have posted few samples)
or simply use the following FM which converts your XML into a itab of name value pair (name would holw the element name and value would hold the value of the element) which you can then loop and read it to your itb.
data: xmldata type xstring .
data: result_xml type standard table of smum_xmltb .
data: return type standard table of bapiret2 .
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = xmldata
TABLES
xml_table = result_xml
return = return .
Regards
Raja -
How to extract data from SAP and COBOL using ODI
Hi Folks,
Can you please let me know the procedures in ODI to extract data from SAP and COBOL?
Thank you all for the help.Hi
You can download Patch 8571830 from Oracle metalink.
It has a new technology "SAP ABAP" and KMs to extract and load data -
RKM SAP ERP and LKM SAP ERP to Oracle.
Thanks -
How to read ecel sheet and insert into oracle table
hi all,
am working on forms builder 6i. and i want , from a trigger to read from a a sheet excel file the data and insert into a table that i had aleady created.
i whrite a code that can till now open the excel file but i cant read the data to insert it into the table.
am using TEXT_IO.IS_OPEN to open the file
TEXT_IO.GET_LINE to take each line
and subst(x as variable) to read the first line , but the subsrt return nohing
any solution??There's already a topic made on this: how to copy data from excel to oracle forms
-
Best Practice to fetch SQL Server data and Insert into Oracle Tables
Hello,
I want to read sqlserver data everry half an hour and write into oracle tables ( in two different databases). What is the best practice for doing this?
We do not have any database dblinks from oracle to sqlserver and vice versa.
Any help is highly appreciable?
ThanksWell, that's easy:
use a TimerTask to do the following every half an hour:
- open a connection to sql server
- open two connections to the oracle databases
- for each row you read from the sql server, do the inserts into the oracle databases
- commit
- close all connections -
How to extract data from xml file and store that data inti data base table
Hii All
I have one table that table contains one column that column contain an XML file
I want to extract data from that XML file and want to store that extracted data into an other table.
That xml file has different different values
I want to store that values into table in diff diff columnsHi,
I am also facing the same problem.I have a .xml file and i need to import the data into the custom table in oracle database.
Can you please let me know if you know the solution how to do it in oracle apps.
Thanks, -
How to - Extract data from Cloud For Customer into SAP HANA system
Hello Community,
I have a requirement for extracting the existing data from Cloud for Customer into separate SAP HANA Box.
Is it possible to achieve the same ? If yes, Please guide me for the same.
Awaiting quick response.
Regards
KumarHi Kumar,
In addition to what Thierry mentioned you could also use the C4C integration via standard Operational Data Provisioning (ODP) interfaces. This integration was acutally built for SAP BW and allows you to access any C4C data sources. From my perspective you can also build upon that for a native SAP HANA integration. Please also have a look at this guide: How To... load SAP Business Suite data into SAP... | SAP HANA.
Besides that question let me also add the following: SAP Cloud for Customer already runs on SAP HANA since Nov. 2013. You may also use the powerful built-in analytics within C4C for analyzing data and any of your reporting demands. If your report should consider external data as well, you can combined the existing C4C data source with an external, so-called Cloud Data Source. More infomation is published in the C4C Analytics Guide: http://help.sap.com/saphelp_sapcloudforcustomer/en/PDF/EN-3.pdf.
I hope this helps...
Best regards,
Sven -
Reading xml data from url and insert into table
CREATE TABLE url_tab2
URL_NAME VARCHAR2(100),
URL SYS.URIType
INSERT INTO url_tab2 VALUES
(’This is a test URL’,
sys.UriFactory.getUri(’http://www.domain.com/test.xml’)
it is giving error as invalid characterCheck if your single quotes are the correct single quotes.
The principle works as advertised in the XMLDB Developers Guide...
C:\>sqlplus / as sysdba
SQL*Plus: Release 11.1.0.7.0 - Production on Tue Nov 25 21:44:46 2008
Copyright (c) 1982, 2008, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create user OTN identified by OTN account unlock;
User created.
SQL> grant dba, xdbadmin to OTN;
Grant succeeded.
SQL> conn OTN/OTN
Connected.
SQL> CREATE TABLE uri_tab (docUrl SYS.URIType, docName VARCHAR2(200));
Table created.
SQL> -- Method SYS.URIFACTORY.getURI() with absolute URIs
SQL> -- Insert an HTTPUri with absolute URL into SYS.URIType using URIFACTORY.
SQL> -- The target is Oracle home page.
SQL> INSERT INTO uri_tab VALUES
2 (SYS.URIFACTORY.getURI('http://www.oracle.com'), 'AbsURL');
1 row created.
SQL> -- Insert an HTTPUri with relative URL using constructor SYS.HTTPURIType.
SQL> -- Note the absence of prefix http://. The target is the same.
SQL> INSERT INTO uri_tab VALUES (SYS.HTTPURIType('www.oracle.com'), 'RelURL');
1 row created.
SQL> -- Insert a DBUri that targets employee data from database table hr.employees.
SQL>
SQL> INSERT INTO uri_tab VALUES
2 (SYS.URIFACTORY.getURI('/oradb/HR/EMPLOYEES/ROW[EMPLOYEE_ID=200]'), 'Emp200');
1 row created.
SQL> SELECT e.docUrl.getCLOB(), docName FROM uri_tab e;
E.DOCURL.GETCLOB()
DOCNAME
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN
">
<html>
<head>
AbsURL
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN
">
<html>
E.DOCURL.GETCLOB()
DOCNAME
<head>
RelURL
<?xml version="1.0"?>
<ROW>
<EMPLOYEE_ID>200</EMPLOYEE_ID>
<FIRST_NAME>Jenn
Emp200
SQL> set long 1000
SQL> select HTTPURITYPE('www.oracle.com').getCLob() from dual;
HTTPURITYPE('WWW.ORACLE.COM').GETCLOB()
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN
">
<html>
<head>
<title>Oracle 11g, Siebel, PeopleSoft |
Oracle, The World's Largest Enterprise S
oftware Company</title>
<meta name="title" content="Enterprise Applications | D
atabase | Fusion Middleware | Applicatio
ns Unlimited | Business | Oracle, The Wo
rld's Largest Enterprise Software CompanEdited by: Marco Gralike on Nov 25, 2008 10:13 PM
Maybe you are looking for
-
A slight issue for a game im creating
im creating a game. NOTHING HUGE but a basic game just something to start off with im only 14. but i haveing some trouble with my background for login. this is what i have import java.awt.*; import java.awt.event.*; import javax.swing.*; public class
-
Blank I have a problem. I would want to know because a menu on the bar of the menu in mac when it is attempted to open from keyboard is opened from the tops of the frame and do not give menu the bar?
-
How do you message a rep about and iphone 6 order?
I would like to know how to message a rep about my pre order TIA!
-
I opened my mail program, opened ten emails with four or five images each, and clicked on each image. I clicked Save Image. I went to Photos/Camera Roll and mine of the pics are saved there. Where are they? I'm used to Windows where I can click Sta
-
[iOS 7] Alerts and typing played in earphones at ringer volume
Hello all, ever since upgrading to iOS 7 yesterday I've noticed an annoying ear-drum bursting audio bug; now whenever a video or music is not playing on your iPhone alerts and typing (the tap-tap noise) come through my earbuds at ringer volume, which