Load xml data into an Oracle table
HelloI went through some threads in the forums itself, but for my requirement that nothing comes closer, I write my request. I have a XML like this
<? XML version = "1.0"? >
< ACCOUNT_HEADER_ACK >
< HEADER >
< STATUS_CODE > 100 < / STATUS_CODE >
Check < STATUS_REMARKS > < / STATUS_REMARKS >
< / Header >
< DETAILS >
< DETAIL >
< SEGMENT_NUMBER > 2 < / SEGMENT_NUMBER >
PR Polytechnic < REMARKS > < / COMMENTS >
< / DETAILS >
< DETAIL >
< SEGMENT_NUMBER > 3 < / SEGMENT_NUMBER >
< REMARKS > PR Polytechnic administration < / COMMENTS >
< / DETAILS >
< DETAIL >
< SEGMENT_NUMBER > 4 < / SEGMENT_NUMBER >
< REMARKS > rp Polytechnique finance < / COMMENTS >
< / DETAILS >
< DETAIL >
< SEGMENT_NUMBER > 5 < / SEGMENT_NUMBER >
< REMARKS > logistics Polytechnique rp < / COMMENTS >
< / DETAILS >
< / DETAILS >
< HEADER >
< STATUS_CODE > 500 < / STATUS_CODE >
< STATUS_REMARKS > process exception < / STATUS_REMARKS >
< / Header >
< DETAILS >
< DETAIL >
< SEGMENT_NUMBER > 20 < / SEGMENT_NUMBER >
Basic Polytechnique < REMARKS > < / COMMENTS >
< / DETAILS >
< DETAIL >
< SEGMENT_NUMBER > 30 < / SEGMENT_NUMBER >
< / DETAILS >
< DETAIL >
< SEGMENT_NUMBER > 40 < / SEGMENT_NUMBER >
Finance basic Polytechnique < REMARKS > < / COMMENTS >
< / DETAILS >
< DETAIL >
< SEGMENT_NUMBER > 50 < / SEGMENT_NUMBER >
Logistics base Polytechnique < REMARKS > < / COMMENTS >
< / DETAILS >
< / DETAILS >
< / ACCOUNT_HEADER_ACK >
Here is the xml structure of the master structure and child I want to insert data in Oracle tables using the sql * loader initially tried to create a control file, but I don't know how to terminate in the control file, so I created two control files
load data
INFILE 'acct.xml' ' str ' < / DETAIL >»»
TRUNCATE
in the xxrp_acct_detail table
TRAILING NULLCOLS
(
dummy fill finished by "< DETAIL >."
SEGMENT_NUMBER surrounded by '< SEGMENT_NUMBER >' and ' < / SEGMENT_NUMBER >, "
REMARKS framed by 'Of REMARKS <>' and ' < / COMMENTS >.
)
load data
ACCT.XML INFILE' "str" < / header > ' "»
TRUNCATE
in the xxrp_acct_header table
fields terminated by '< HEADER >.
TRAILING NULLCOLS
(
dummy fill finished by "< HEADER >."
STATUS_CODE framed by '< STATUS_CODE >' and ' < / STATUS_CODE >. "
STATUS_REMARKS surrounded by '< STATUS_REMARKS >' and ' < / STATUS_REMARKS >.
)
I refer to the same xml file in two control files, where with regard to the first control file, I was able to load the files but the second which I suppose as table header not able to load the records of rest. I get the below error.
Sheet 2: Rejected - error on the XXRP_ACCT_HEADER, column DUMMY table.
Field in the data file exceeds the maximum length
Sheet 3: Rejected - error on the XXRP_ACCT_HEADER, column DUMMY table.
Field in the data file exceeds the maximum length
In fact if its possible to seggrate a control file so it will be very useful for me. I'm also open for the external table as option. Please help me in this regard.
Thanks in advance.
Concerning
Mr. Nagendra
Here are two possible solutions:
(1) reading the headers and separate details using two XMLTables:
DECLARE
acct_doc xmltype := xmltype( bfilename('TEST_DIR','acct.xml'), nls_charset_id('AL32UTF8') );
BEGIN
insert into xxrp_acct_details (status_code, status_remarks, segment_number, remarks)
select x1.status_code,
x1.status_remarks,
x2.segment_number,
x2.remarks
from xmltable(
'/ACCOUNT_HEADER_ACK/HEADER'
passing acct_doc
columns header_no for ordinality,
status_code number path 'STATUS_CODE',
status_remarks varchar2(100) path 'STATUS_REMARKS'
) x1,
xmltable(
'$d/ACCOUNT_HEADER_ACK/DETAILS[$hn]/DETAIL'
passing acct_doc as "d",
x1.header_no as "hn"
columns segment_number number path 'SEGMENT_NUMBER',
remarks varchar2(100) path 'REMARKS'
) x2
;
END;
All first (alias X 1) retrieves all headers in separate lines. The HEADER_NO generated column is used to keep track of the position of the header into the document.
Then, we join a second XMLTable (X 2), passing HEADER_NO, so that we can access the corresponding items in DETAIL.
(2) reading with one XMLTable, but somewhat more complex XQuery:
DECLARE
acct_doc xmltype := xmltype( bfilename('TEST_DIR','acct.xml'), nls_charset_id('AL32UTF8') );
BEGIN
insert into xxrp_acct_details (status_code, status_remarks, segment_number, remarks)
select x.*
from xmltable(
'for $i in /ACCOUNT_HEADER_ACK/HEADER
return
for $j in $i/following-sibling::DETAILS[1]/DETAIL
return element r {$i, $j}'
passing acct_doc
columns status_code number path 'HEADER/STATUS_CODE',
status_remarks varchar2(100) path 'HEADER/STATUS_REMARKS',
segment_number number path 'DETAIL/SEGMENT_NUMBER',
remarks varchar2(100) path 'DETAIL/REMARKS'
) x
;
END;
Here, we use an XQuery query to extract the information that we need.
Basically it's the same logic as above, but with two nested loops which access each header, then each RETAIL location immediately after in the order of the documents.
Here is the link to the documentation XMLTable and XQuery in Oracle:
http://download.Oracle.com/docs/CD/B28359_01/AppDev.111/b28369/xdb_xquery.htm#CBAGCBGJ
Tags: Oracle Development
Similar Questions
-
Hi all
I have an XML (emp.xml) with data below:
-< root >
-< row >
< name > steve < / lastname >
< 30 > < / Age >
< / row >
-< row >
< name > Paul < / lastname >
<>26 < / Age >
< / row >
< / root >
I would like to create a stored procedure to store the xml data into the EMP table.
EMP
LastName age
Steve 30
Paul 26
I tried to watch all threads related to this forum, but cannot find the right wire. Any help is greatly appreciated. Thank youWith
SQL> select * from xmltable('root/row' passing xmltype('
steve 30 Paul 26 You can now just make a
Insert into emp as select...
-
How to consume a web service in ODI and put data into an oracle table
Hello
Is someone can please help me with this or just give me some advice.
Thanks in advanceYou must now read this XML file using XML ODI driver and load the data into tables using interfaces.
-
Download the XML data in an oracle table
I need to download data from an XML file to the oracle table.
I use 10.1.0.3.0 database.Refer to the Oracle XML DB Developer's Guide - loading XML in Oracle XML DB content
-
LOAD CSV DATA INTO A NEW TABLE
I have a basic csv file-12 columns, 247 lines I tried to import or paste it into a new table and with each try, not all records get downloaded in the new table. Using the "Load Data" tool, I tried text data load, load the worksheet data, by import .csv and copy/paste. I put the records in the order PK ID of the table, I added dummy entries in all fields are null (that is, I added the word "None" for empty fields). But nothing works. I get about half of existing records.
Why?The Max Size for VARCHAR2 is 4000. If you have a text which is longer, you must type clob column.
If you wann download the entire file you need of a blob column you need to implement a uploadscript like this: http://www.dba-oracle.com/t_easy_html_db_file_browse_item.htm
-
How to import the XML file into an oracle table using a BPEL process
Hi friends
How can I import XML file in the db oracle table using a BPEL process
(1) I have generated an XML file in my local system with a field
(2) I created a temporary table in my oracledb with the same field in the XML file
(3) that I want to import these XML files which is the local host to my db oracle using a BPEL process
(4) for that what steps should I me fallow please suggest me if there is no document for this?
Thanks in advance
ATHi to
Here you go...
http://blogs.Oracle.com/ajaysharma/2011/03/using_file_adapter_database_adapter_and_mediator_component_in_soa_11g.html
I hope that helps!
Thank you
AJ -
help to load xml data into a loop
Hola amigos, acudo a ustedes porque estoy doing a small application that muestre archivos para mi nueva zona of descargas, esta take utilizando diagramacion paint (gracias por los slideshows as against aqui) y los archivos los carga desde los datos a xml file.
I have a movieclip cargado con addChild, y knew vez dentro carga tambien con addChild varios insert utilizando UN loop, the cosa are what who use ese mismo loop para as cada vez shouts the panel of the United Nations, are the cargue los datos xml, pero no puedo hacerlo, sale me el error 1009 respond el object are nulo. ACA the dejo parte del codigo, por if any of ustedes me can help con eso.
Por adelantado the agradesco.Hello people, I come to you because I do a small application that shows the files for my new download area, it is made using liquid layout and files information loading from a xml file.
I have a movieclip loaded with addChild and Interior load also with addChild several panels by using a loop, the thing is that I wanted to use the same loop for each time to add a new Panel, also load information to an xml file, but I can't do it every time show my 1009 error saying that the object is null (void). Here I leave you a part of the code for them if anyone of you can help me with this.
Thank you in advance for the help, and here is a sample of the API: http://nesmothdesign.com/Media/home.swfset the XML
var imgLoader:Loader;
var xml;
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load (new URLRequest ("listado.xml"));
xmlLoader.addEventListener (Event.COMPLETE, xmlLoaded);
function xmlLoaded(event:Event):void
{
XML = XML (event.target.data);
xmlList = xml.children ();
trace (xmlList.length ());
}Add counter to the panns
var miContenedor:contenedor;
miContenedor = new contenedor();
addChild (miContenedor);
Tweener.addTween(miContenedor,{x:stage.stageWidth/2-465,time:1,transition:"easeIn"});)
miContenedor.y = body_mc.y + 10;
Add container´s children-
var miPartA:panelTipoA;
var miPartB:panelTipoB;
for (var a: int = 0; has < = 3; a ++)
{
miPartA = new panelTipoA();
miPartB = new panelTipoB();
miContenedor.addChild (miPartA);
miContenedor.addChild (miPartB);
miPartA.y = a * miPartA.height + (a * 10);
miPartB.y = a * miPartB.height + (a * 10);
miPartB.x = miPartB.width + 15;
imgLoader = new Loader();
imgLoader.load (new URLRequest (xmlList [a] .attribute ("thumb")));
miContenedor.miParteA.addChild (imgLoader);
}Atention: las 3 of code lines should add the respective to the pannel xml file data.
miContenedor.miParteA.addChild (imgLoader);
is the problem. There is no miContenedor.miParteA. use:
miParteA.addChild (imgLoader);
-
Can anyone help on how to load the XML data into the oracle table.
If there is a tutorial, I can talk through will be great. As I can see instant and draw my mapping.Hello
What version do you use?
There is a lever XDB here text that allows a better understanding;
http://blogs.Oracle.com/warehousebuilder/2007/09/leveraging_xdb.htmlSee you soon
David -
Insert data as XML into the Oracle Table
Hi all
I have a requirement where the data in XML format, and I need to insert into the Oracle Table. For example, I get XML data in the following format,
< results >
< row >
< BANK_ACCOUNT_ID > 10010 < / BANK_ACCOUNT_ID >
< BANK_ID > 300968 < / BANK_ID >
Vision operations < LEGAL_ENTITY > < / LEGAL_ENTITY >
< BANK_NAME > BofA < / BANK_NAME >
< BANK_ACCOUNT_NUM > 10271-17621-619 < / BANK_ACCOUNT_NUM >
< BANK_ACCOUNT_NAME > BofA-204 < / BANK_ACCOUNT_NAME >
< BRANCH_NAME > New York < / BRANCH_NAME >
USD < CURRENCY_CODE > < / CURRENCY_CODE >
< BALANCE_DATE > 2007 - 11 - 09 < / BALANCE_DATE >
< LEDGER_BALANCE > 432705900.56 < / LEDGER_BALANCE >
< / row >
< row >
< BANK_ACCOUNT_ID > 10091 < / BANK_ACCOUNT_ID >
< BANK_ID > 300984 < / BANK_ID >
Vision industries < LEGAL_ENTITY > < / LEGAL_ENTITY >
Barclay Bank < BANK_NAME > < / BANK_NAME >
< BANK_ACCOUNT_NUM > 70986798 < / BANK_ACCOUNT_NUM >
Bank Multi currency-626 < BANK_ACCOUNT_NAME > Barclays < / BANK_ACCOUNT_NAME >
Reading < BRANCH_NAME > < / BRANCH_NAME >
GBP < CURRENCY_CODE > < / CURRENCY_CODE >
< BALANCE_DATE > 2007 - 11 - 14 < / BALANCE_DATE >
< LEDGER_BALANCE > 24244085.24 < / LEDGER_BALANCE >
< / row >
< row >
< BANK_ACCOUNT_ID > 10127 < / BANK_ACCOUNT_ID >
< BANK_ID > 300968 < / BANK_ID >
< LEGAL_ENTITY > SSC U.S. 01 < / LEGAL_ENTITY >
< BANK_NAME > BofA < / BANK_NAME >
< BANK_ACCOUNT_NUM > 4898744 < / BANK_ACCOUNT_NUM >
< BANK_ACCOUNT_NAME > BofA SSC U.S. 02-7188 < / BANK_ACCOUNT_NAME >
< BRANCH_NAME > New York < / BRANCH_NAME >
USD < CURRENCY_CODE > < / CURRENCY_CODE >
< BALANCE_DATE > 2007 - 11 - 28 < / BALANCE_DATE >
< LEDGER_BALANCE > 10783815.28 < / LEDGER_BALANCE >
< / row >
< / results >
I like to write PLSQL code that will receive these data with XML tags and insert it into the Oracle Table. Is this possible with built-in XML features provided in the Oracle database?
Please Guide...
Kind regards
PriyankaBut the problem is the file XML is to have the details of the records if you carefully observed the XML file. But by using more high statement select I get output in the following format.
ORG_ID REQ_LINE PO_NUMBER EXPECTED_REC_QTY USER_NAME REQ_NUMBER
204204 1444714450 11 64446445 11 OPERATIONSOPERATIONSThe table has only one row, so you get a single row as output.
I'm surprised that you find useful examples showing how to divide the data into several lines.(1) create the table with the following option, it will optimize the performance of storage and query for large XML documents:
CREATE TABLE xxios_xml_data_test(xml_data XMLTYPE) XMLTYPE COLUMN xml_data STORE AS SECUREFILE BINARY XML ;
(2) interview table with:
SQL> select x.* 2 from xxios_xml_data_test t 3 , xmltable( 4 '/Results/Row' 5 passing t.xml_data 6 columns ORG_ID number path 'ORG_ID' 7 , REQ_NUMBER number path 'REQ_NUMBER' 8 , REQ_LINE number path 'REQ_LINE' 9 , PO_NUMBER number path 'PO_NUMBER' 10 , EXPECTED_REC_QTY number path 'EXPECTED_REC_QTY' 11 , USER_NAME varchar2(30) path 'USER_NAME' 12 ) x 13 ; ORG_ID REQ_NUMBER REQ_LINE PO_NUMBER EXPECTED_REC_QTY USER_NAME ---------- ---------- ---------- ---------- ---------------- ------------------------------ 204 14447 1 6444 1 OPERATIONS 204 14450 1 6445 1 OPERATIONS
-
Not able to load the data into ODI
Team,
I get the error when I am trying to load some data from the Oracle source to the target Oracle table.
SOure: I have col1 and target I row_wid, col1. For Row_wid I created the sequence and mapping is the other Col 2
I get error during a stage, wherei captures the code:
/ * DETECTION_STRATEGY = NOT_EXISTS * /.
insert into CONFIG_NBN_BIW. I _WC_EAM_STATUS_D $
(
STATUS_NAME,
IND_UPDATE
)
Select
STATUS_NAME,
IND_UPDATE
de)
Select
SEPARATE
C1_STATUS_NAME STATUS_NAME,
'I' IND_UPDATE
of CONFIG_NBN_BIW. C$ _0WC_EAM_STATUS_D
where (1 = 1)
) S
If NOT EXISTS
(select 1 from CONFIG_NBN_BIW. WC_EAM_STATUS_D T
where T.ROW_WID = S.ROW_WID
and ((T.STATUS_NAME = S.STATUS_NAME) or (T.STATUS_NAME IS NULL and S.STATUS_NAME IS NULL))
)
The above query fails with an error: ORA-00904: "S". "' ROW_WID ': invalid identifier.
Since the S.ROW_WID in T.ROW_WID = S.ROW_WID is incorrect. IT is supposed to be T.ROW_WID = S.IND_UPDATE.
Now, can someone tell me where exactly I'm incorrect in ODI. OR need additional information.
Thank youHello
What is happening because you check the KEY field against the column is populated in a sequence.
Uncheck this option, make sure you also UPDATE filed is also uncheck for that particular column.According to the request stuck by you, I think STATUS_NAME should be marked as KEY.
Thank you
Fati -
Loading the data into the order of series of Timestamp
I need to load data into the target table in the order of series of timestamp. How to do it.
ex:
2015-12-10 02:14:15
2015-12-10 03:14:15
2015-12-10 04:14:15
After you follow the how to use the Direct-Path INSERT ordered by your "timestamp column" series described here above, you can sort the lines in ODI (order of) this way:
- The "ORDER BY" clause in an interface - handling ODIExperts.com
- ODI KM adding order by Option - ETL and DWH Blog
- You can change your knowledge used Module and the code inside. As a best practice, keep a copy of the KM, then change the steps. (Designer-> project-> knowledge Modules) double click on the Knowledge Module, go to the tab tasks and select one, then click the button change and change...
-
Loading the data into Essbase is slow
Loading the data into Essbase is slow.
Loading speed of 10 seconds on a record.
It is used standard KM.
How it is possible to optimize the loading of data into Essbase?
Thank you
--
GeloJust for you say the patch was released
ORACLE DATA INTEGRATOR 10.1.3.5.2_02 UNIQUE PATCH
Patch ID - 8785893
8589752: IKM SQL data Essbase - loading bulk instead of rank by rank treatment mode when an error occurs during the loading
See you soon
John
http://John-Goodwin.blogspot.com/ -
How to insert 10,000 records test data into the emp table
Hi I am new to oracle can someone please help me write a program so that I can insert the test data into the emp tableSELECT LEVEL empno, DBMS_RANDOM.string ('U', 20) emp_name, TRUNC (DBMS_RANDOM.VALUE (10000, 100000), 2) sal, DBMS_RANDOM.string ('U', 10) job, TO_DATE ('1990-01-01', 'yyyy-mm-dd') + TRUNC (DBMS_RANDOM.VALUE (1, 6000), 0) hiredate, CASE WHEN LEVEL > 10 THEN TRUNC (DBMS_RANDOM.VALUE (1, 11), 0) ELSE NULL END mgr, TRUNC (DBMS_RANDOM.VALUE (1, 5), 0) deptno FROM DUAL CONNECT BY LEVEL <= 10000
-
How to insert the legacy data into the QP_RLTD_MODIFIERS table?
How insert Legacy data into the QP_RLTD_MODIFIERS table in the instance of R12.
I would use the QP_Modifiers_PUB API. Process_Modifiers to push the old data on prices in R12. QP_RLTD_MODIFIERS is only used for certain types of discounts (in my prod environment, only the promos are given in this table).
-
How to load the demilited hose to Oracle table text file
Hi all
I have a file (filaname.txt) I want to load into oracle table.
This file is pipe delimited.
Some examples of filename.txt data...
SOURCE_SYSTEM_NAME | ACCOUNT_NUMBER | BILL_TO_LOCATION | SHIP_TO_LOCATION
SMS US | 0001 | 1. 1
SMS US | 0001 | 1. 2
SMS US | 0001 | 1. 4
SMS US | 0002 | 1. 1
could you please suggest what are the parametrs to create a data store for a pipe delimited txt file.
Thank youWhen you create him data store for the file in the files tab to define the field as separator. or Hex 7 c
See you soon
John
http://John-Goodwin.blogspot.com/
Maybe you are looking for
-
Satellite 1800-400 and USB Bluetooth adapter
I ask a large part of this laptop, on the installation of the software for the adapter and re-boot to complete installation, the computer comes up with a fatal error about a dll file, it happens that fast I can't get all the details.Anyone with any e
-
I need a disk recovery for SATELLITEL300-135 PSLB0E-02H01HAR
HelloHow can I get recover cd for IT l300-135Model number PSLB0E-02H01HARI format the drive & I don't have the cd recoverWhat can I [email protected]
-
Error code while upgrading windows... 0x800706BA
Error code while upgrading windows... 0x800706BA Best regards, Sohail Patel "MCSE 2003 | ITILv3 | "A journey of a thousand miles begins with a first step."
-
EF 16-35 2.8 L II USM - discussion questions
I am a photographer amauter. I have acquirede the objective 16-35 earlier - back in 2012. My intentions, after reading the reviews, had to have a flexible suddenly both inside and outside. I use the body of the 60 d. I quite often focus problems wh
-
Good afternoon Laptop of my administrator has a file tcpmon.ini which is apparently corrupt. When I ran ' sfc/scannow' and then checked the logfile C:\Windows\Logs\CBS\CBS, I found 4 lines that State tcpmon.ini is not repairable. I copied these 4 li