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
Similar Messages
-
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= -
Hi all,
I have some xml data which i would like to insert into oracle tables.
Where to start up with this?Hi,
Here's another good place to start: [XML DB FAQ|http://forums.oracle.com/forums/thread.jspa?threadID=410714&tstart=0]
You seem to be especially interested in second post in there.
Regards
Peter -
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
-
Incorrect data value when insert into oracle table
Would like to ask expert here, how could I insert data into oracle table where the value is 03 ? The case is like that, the column was defined as varchar2(50) data type, and I have a csv file where the value is 03 but when load into oracle table the value become 3 instead of 03.
user11432758 wrote:
Would like to ask expert here, how could I insert data into oracle table where the value is 03 ? The case is like that, the column was defined as varchar2(50) data type, and I have a csv file where the value is 03 but when load into oracle table the value become 3 instead of 03.
implicit datatype conversion to NUMBER can result in leading zero to be eliminated.
How do I ask a question on the forums?
https://forums.oracle.com/message/9362002#9362002 -
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 -
Can select, but cannot insert into oracle tables using php.
I am having trouble inserting data into a tables in oracle using PHP. I can insert into the tables using baninst1, but nothing else. I can't even insert using the tables' owner. Every time I try I get the ORA-00492 error of table or view does not exist. However, I can run a select statement just fine. So far, baninst1 is the only user that can actually do inserts. I've triple checked all the table grants and everything is fine. Also, I can copy/paste the exact insert statement into SQL*Plus and it works with the correct user. It doesn't have to be baninst1. I've tried everything I can think of. I've tried putting the table name in quotes, adding the schema name to the table, checking public synonyms, but everything appears to be ok. I would greatly appreciate any suggestions others may have.
I'm using PHP 5.2.3 with an oracle 9i DB.Here is the code that doesn't work. It works only with baninst1, no other username will work and all I do is change the my_username/my_password to something different. This is one example function where I try to do an insert, but it doesn't work on any of the tables I try.
Thanks for looking.
class Oracle {
private $oracleUser = "my_username";
private $oraclePassword = "my_password";
private $oracleDB = "MY_DB";
private $c = null;
function Connect() {
if ( !($this->c = ocilogon( $this->oracleUser, $this->oraclePassword, $this->oracleDB ) ) )
return false;
return true;
function AddNewTest($testName, $course, $section, $term, $maxAttempts, $length, $startDate, $startTime, $endDate, $endTime)
$result = "";
if( $this->c == null )
$this->Connect();
$splitIndex = strpos($course, " ");
$subjectCode = substr($course, 0, $splitIndex);
$courseNumber = substr($course, $splitIndex + 1);
$insertStatment = "insert into szbtestinfo(szbtestinfo_test_name,
szbtestinfo_course_numb,
szbtestinfo_section,
szbtestinfo_max_attempts,
szbtestinfo_length_minutes,
szbtestinfo_start,
szbtestinfo_end,
szbtestinfo_id,
szbtestinfo_subj_code,
szbtestinfo_eff_term)
values( '" . $testName .
"', '" . $courseNumber .
"', '" . $section .
"', " . $maxAttempts .
", " . $length .
", to_date('" . $startDate . " " . $startTime . "', 'MM/DD/YYYY HH24:MI')" .
", to_date('" . $endDate . " " . $endTime . "', 'MM/DD/YYYY HH24:MI')" .
", szsnexttest.nextval" .
", '" . $subjectCode .
"', '" . $term . "')";
//return $insertStatment;
$s = OCIParse($this->c, $insertStatment);
try
$result = OCIExecute($s);
catch(exception $e)
return $result;
} -
INSERT into Oracle table as SELECT from MS Access table
I'm trying to pull some data across from an MS Access database. I really need to pick and choose what is coming across, so migration isn't what I need. I can connect to the Access DB from SQL Developer, export data and so forth. However, I can't seem to find a way to directly access data in the MDB file from an Oracle connection. The two options that I can think of which would be perfect (if they are possible) are:
1. If it's possible to SELECT between two open connections in SQL Developer. I can (and have) had both my Oracle conection where I want the data to go and the source Access connection opened simultaneously, but I can't see any way to address a query from one connection to another.
2. If it's possible to create the equivalent of a database link to the Access MDB file from within my Oracle database so that I can address the query via that.
Right now I'm exporting individual tables from Access to files, then doing a bunch of Search and Replace operations to convert them to SQL scripts with INSERT statements in the format required, then running those scripts in my Oracle connection. It works, but is very slow and tedious.You need to create a database link based on Database Gateway for ODBC. This gateway allows you to connect from an Oracle database to a foreign data store using a 3rd party ODBC driver.
A suitable 3rd party ODBC driver which allows you to connect from Oracle to MS Access is the ODBC driver from Microsoft available on Windows platforms - I'm not aware of any 3rd party ODBC driver for MS Access available on Unix platforms.
So when using DG4ODBC on Windows you can connect from your Oracle database (even when the database resides on Unix) to DG4ODBC on Windows which then connects to the Ms Access database using the MS Access ODBC driver.
There's a separate Forum for those configs:
Heterogeneous Connectivity -
Problem with XML doc inserting into oracle 10g
Hi Guys, I have some knowledge in oracle 10g.
We are doing an application, when we were trying to insert XML document (I was trying to insert XML as un-structured way.) into oracle 10g as a datatype called XMLTYPE column.
My XML is having namespace attributes(Target namespaces) in that. So when i was trying to insert that into database , it is giving some error ,and not letting me to push that into database.
So Can any body please help me in this. My constraint is that I have to insert the document as un-structured way.
You help would be appriciated.
Vish
Message was edited by:
user567405
Message was edited by:
user567405
Message was edited by:
user567405
Message was edited by:
user567405
Message was edited by:
user567405, it is giving some error Hmmm, six attempts and you still didn't manage to tell us what the actuall error message and number was. Oracle has thousands of error messages. If you would like us to help you, make it easy for us to figure out what's going on. Don't make us guess.
Regards, APC -
Upload XML file data into internal table
Hi,
I need help from you.
I am uploading XML file from Application server.
1.In application server under directory it may have several XML files and i need to upload all the XML files when we gave only directory name. So, what is the function module for that logic . If possible code also.
2.Once we get the files into some internal table we need to upload data from that files to internal table.
So what is the logic for that , if possible code also.
I am giving sample directory:
For example in this directory assume 3 xml files are there.
I need to upload those files and data from that in to internal table.
Thanks & Regards
VSRBelow code will give you an idea.
TYPE-POOLS: ixml. "iXML Library Types
*TABLES : rbkp.
TYPE DECLERATIION
TYPES: BEGIN OF type_tabpo,
ebeln TYPE ekko-ebeln, "PO document number
ebelp TYPE ekpo-ebelp, "PO line item
END OF type_tabpo.
TYPES: BEGIN OF type_ekbe,
belnr TYPE rbkp-belnr, "Invoice document
gjahr TYPE rbkp-gjahr, "fiscal year
END OF type_ekbe.
TYPES: BEGIN OF type_invoice,
belnr TYPE rbkp-belnr, "PO document number
gjahr TYPE rbkp-gjahr, "Fiscal Year
rbstat TYPE rbkp-rbstat, "invoice status
END OF type_invoice.
TYPES: BEGIN OF t_xml_line, "Structure for holding XML data
data(256) TYPE x,
END OF t_xml_line.
INTERNAL TABLE DECLERATIION
DATA: gi_tabpo TYPE STANDARD TABLE OF type_tabpo,
gi_ekbe TYPE STANDARD TABLE OF type_ekbe,
gi_invoice TYPE STANDARD TABLE OF type_invoice,
gi_bapiret2 TYPE STANDARD TABLE OF bapiret2.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory.
DATA: l_xml_table TYPE TABLE OF t_xml_line, " XML Table of the structure
l_xml_line TYPE t_xml_line, " Record of structure t_xml_line
l_xml_table_size TYPE i. " XML table size
DATA: l_filename TYPE string.
WORK AREA DECLARATION
DATA: gw_tabpo TYPE type_tabpo,
gw_ekbe TYPE type_ekbe,
gw_invoice TYPE type_invoice,
gw_bapiret2 TYPE bapiret2.
BEGIN OF SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
PARAMETERS: p_file TYPE pathintern LOWER CASE DEFAULT '/usr/sap/tmp/'.
Validation of XML file: Only DTD included in XML document is supported
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION SCREEN VALIDATION
AT SELECTION-SCREEN.
To validate p_file is not initial
PERFORM sub_validate_file.
PERFORM sub_validate_path.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
Request for filename for xml file from the application server
PERFORM sub_get_filename_appl USING p_file.
START OF SELECTION SCREEN
START-OF-SELECTION.
PERFORM sub_fetch_po_details.
PERFORM sub_get_invoice.
PERFORM sub_rel_invoice.
END OF SELECTION SCREEN
END-OF-SELECTION.
*& Form sub_validate_file
To Validate the file
FORM sub_validate_file .
IF p_file IS INITIAL.
MESSAGE e000. "specify the file path
ENDIF.
ENDFORM. " sub_validate_file
*& Form sub_get_filename_appl
form sub_get_filename_appl USING l_fname TYPE any.
DATA: l_fname TYPE filename-fileintern. " File name
*GET THE FILENAME FROM THE APPLICATION SERVER
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = l_fname
filemask = '*'
IMPORTING
serverfile = l_fname
EXCEPTIONS
canceled_by_user = 1
OTHERS = 2.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " sub_get_filename_appl
*& Form sub_fetch_po_details
To fetch the PO details from the application server
Format of file is XML
FORM sub_fetch_po_details .
TYPE DECLERATIION
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
PERFORM get_xml_table.
LOOP AT gi_tabpo INTO gw_tabpo.
WRITE:/ gw_tabpo.
ENDLOOP.
ENDFORM. " sub_fetch_po_details
*& Form get_xml_table
Read from the xml file
FORM get_xml_table .
Local variable declarations
DATA: l_len TYPE i,
l_len2 TYPE i,
l_tab TYPE tsfixml,
l_content TYPE string,
l_str1 TYPE string,
c_conv TYPE REF TO cl_abap_conv_in_ce,
l_itab TYPE TABLE OF string.
l_filename = p_file.
code to upload data from application server
OPEN DATASET l_filename FOR INPUT IN BINARY MODE.
IF sy-subrc 0.
WRITE:/ 'invalid file path'.
ENDIF.
DO.
READ DATASET l_filename INTO l_xml_line.
IF sy-subrc EQ 0.
APPEND l_xml_line TO l_xml_table.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET l_filename.
code to find the table size
DESCRIBE TABLE l_xml_table.
l_xml_table_size = ( sy-tleng ) * ( sy-tfill ).
*code to convert hexadecimal to XML
LOOP AT l_xml_table INTO l_xml_line.
c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data
replacement
= space ).
c_conv->read( IMPORTING data = l_content len = l_len ).
CONCATENATE l_str1 l_content INTO l_str1.
ENDLOOP.
l_str1 = l_str1+0(l_xml_table_size).
SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN
l_str1 WITH space.
ENDLOOP.
CALL TRANSFORMATION ('ID') " code to put in internal table
SOURCE XML l_str1
RESULT tab = gi_tabpo[].
ENDFORM. " get_xml_table -
Trying to create XML file from 1 oracle table .
I'M NEW IN ODI
Step1: Target XML format
- <Customers>
- <UserInfo>
<UserID>0000000000202406</UserID>
<LegalEntityCode>0USAL</LegalEntityCode>
<BranchCode>001</BranchCode>
<LegalEntity>>0USAL</LegalEntity>
<BranchCode>001</BranchCode>
<TypeOfChange>123jkl</TypeOfChange>
- <CustomerDetails>
- <MasterData>
<RelationshipManager>jkiu123</RelationshipManager>
<CustomerID />
<GroupCustomerID>0000000000202406</GroupCustomerID>
<FirstName>sdfgh</FirstName>
<LastName>dhgfs</LastName>
<CustomerType>c</CustomerType>
<CustomerSubType>fitz</CustomerSubType>
<SAE>430</SAE>
<DoubleCitizenship>NA</DoubleCitizenship>
<TelephoneNumber>NA</TelephoneNumber>
<Citizenship>NA</Citizenship>
<TIN>NA</TIN>
<Language>GB</Language>
<BirthCountryCode>AL</BirthCountryCode>
<BirthCountry>ALB</BirthCountry>
<DateOfBirth>NA</DateOfBirth>
</MasterData>
</CustomerDetails>
</UserInfo>
</Customers>
Step 2. Specified the logical and physical schema FOR XML.
jdbc:snps:xml?f=V:\MYFILE.xml&d=V:\MYFILE.DTD&s=FXML
where schema and work schema are the same: FXML
Step3.Logged into Designer and reverse engineered from the the schema created in step2.
step 4. Following Hierarchy is created:
CUSTOMERS USERINFO CUSTOMERDETAILS MASTERDATA
PLEASE HELP ME WITH EXPLANATIONS IN DETAILS!!!
T.Y. IN ADVANCEHi Ayush!
Thnx for your help.
But know i have this:
ODI-1228: Task ISPBA_FATCA_XML_MASTERDATA_FINAL (Integration) fails on the target XML connection FATCA_FINAL.
Caused By: java.sql.SQLException: data exception: numeric value out of range
at com.sunopsis.jdbc.driver.xml.SnpsXmlPreparedStatementRedirector.execute(SnpsXmlPreparedStatementRedirector.java:211)
at com.sunopsis.jdbc.driver.xml.SnpsXmlPreparedStatement.execute(SnpsXmlPreparedStatement.java:48)
at oracle.odi.runtime.agent.execution.sql.SQLCommand.execute(SQLCommand.java:163)
at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:102)
at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:1)
at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:50)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2913)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2625)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:580)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:468)
at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2128)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:366)
at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:292)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:855)
at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)
at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:83)
at java.lang.Thread.run(Thread.java:662)
All the values for source and target have the same size and type. Can you help me? -
How to read the data from XML file and insert into oracle DB
Hi All,
I have below require ment.
I will receive data in the XML file. then i need to read that data and insert into oracle tables. please let me know how this can be handled.
Many Thanks.Sounds a lot like this question, only with less details.
how to read data from XML variable and insert into table variable
We can only help if you provide us details to help as we cannot see what you are doing and only know what you tell us. Plenty of examples abound on the forums that cover the topics you seek as well. -
I have xml data in this format and need to store in the lineitem table by generating three new values for each row ie line identifier(sys_guid),begin_date and end_date.
<LineItems>
<LineItem>
<BASE_TYPE>SRV</BASE_TYPE>
<ORDER_NUM>124089304</ORDER_NUM>
<WIP_STATUS>S</WIP_STATUS>
<WIP_STATUS_DATE>8/1/2006 8:44:55 PM</WIP_STATUS_DATE>
<order_date>6/21/2006 12:00:00 AM</order_date>
<IP_DATE>6/21/2006 12:00:00 AM</IP_DATE>
</LineItem>
<LineItem>
<BASE_TYPE>SRV</BASE_TYPE>
<ORDER_NUM>124089304</ORDER_NUM>
<WIP_STATUS>S</WIP_STATUS>
<WIP_STATUS_DATE>8/1/2006 8:44:55 PM</WIP_STATUS_DATE>
<order_date>6/21/2006 12:00:00 AM</order_date>
<IP_DATE>6/21/2006 12:00:00 AM</IP_DATE>
</LineItem>
</LineItems>
and using this method to insert
SELECT EXTRACTVALUE(VALUE(T), 'LineItem/BASE_TYPE'),
EXTRACTVALUE(VALUE(T), 'LineItem/ORDER_NUM'),
EXTRACTVALUE(VALUE(T), 'LineItem/WIP_STATUS'),
EXTRACTVALUE(VALUE(T), 'LineItem/WIP_STATUS_DATE')),
EXTRACTVALUE(VALUE(T), 'LineItem/ORDER_DATE')),
EXTRACTVALUE(VALUE(T), 'LineItem/IP_DATE')),
EXTRACTVALUE(VALUE(T), 'LineItem/SHIP_BY_DATE')),
EXTRACTVALUE(VALUE(T), 'LineItem/CUSTOMER_SRC'),
EXTRACTVALUE(VALUE(T), 'LineItem/CUSTOMER_LOC'),
EXTRACTVALUE(VALUE(T), 'LineItem/CUSTOMER_NUM'),
EXTRACTVALUE(VALUE(T), 'LineItem/ACCOUNT_TYPE'),
EXTRACTVALUE(VALUE(T), 'LineItem/OVERPACK_FLAG'),
EXTRACTVALUE(VALUE(T), 'LineItem/INTERNATIONAL_FLAG'),
EXTRACTVALUE(VALUE(T), 'LineItem/MULTIPLE_SYSTEM_TIES'),
EXTRACTVALUE(VALUE(T), 'LineItem/ORDER_TIE_NUM'),
EXTRACTVALUE(VALUE(T), 'LineItem/TIE_STATUS'),
EXTRACTVALUE(VALUE(T), 'LineItem/PK_GEN'),
EXTRACTVALUE(VALUE(T), 'LineItem/QTY_REQD'),
EXTRACTVALUE(VALUE(T), 'LineItem/WORKCENTER_ID'),
EXTRACTVALUE(VALUE(T), 'LineItem/SI_NUMBER'),
EXTRACTVALUE(VALUE(T), 'LineItem/MFG_SCHED_FACILITY_ID'),
EXTRACTVALUE(VALUE(T), 'LineItem/MFG_FACILITY_ID'),
EXTRACTVALUE(VALUE(T), 'LineItem/PILOT_NAME'),
EXTRACTVALUE(VALUE(T), 'LineItem/ENG_HOLD_FLAG'),
EXTRACTVALUE(VALUE(T), 'LineItem/SHORT_FLAG'),
EXTRACTVALUE(VALUE(T), 'LineItem/OVR_SHORTAGE'),
EXTRACTVALUE(VALUE(T), 'LineItem/USER_HOLD_FLAG'),
EXTRACTVALUE(VALUE(T), 'LineItem/SHIP_TO_ADDRESS_SEQ_NUM'),
EXTRACTVALUE(VALUE(T), 'LineItem/CALICO_REF_NUM'),
EXTRACTVALUE(VALUE(T), 'LineItem/CONFIG_ID'),
EXTRACTVALUE(VALUE(T), 'LineItem/TOTAL_UNITS_QTY'),
EXTRACTVALUE(VALUE(T), 'LineItem/ORDER_TYPE'),
EXTRACTVALUE(VALUE(T), 'LineItem/SKU'),
EXTRACTVALUE(VALUE(T), 'LineItem/SUB_ASSEMBLY_NUMBER'),
EXTRACTVALUE(VALUE(T), 'LineItem/BASE_ASM_FLAG'),
EXTRACTVALUE(VALUE(T), 'LineItem/QTY_REQ'),
EXTRACTVALUE(VALUE(T), 'LineItem/ORIGINAL_PART_NUMBER'),
EXTRACTVALUE(VALUE(T), 'LineItem/SUBSTITUTE_PART_NUMBER'),
EXTRACTVALUE(VALUE(T), 'LineItem/QTY_EXTENDED'),
EXTRACTVALUE(VALUE(T), 'LineItem/ISSUE_CODE'),
EXTRACTVALUE(VALUE(T), 'LineItem/ORIG_PART_DESC'),
EXTRACTVALUE(VALUE(T), 'LineItem/ORIG_COMMODITY_CODE'),
EXTRACTVALUE(VALUE(T), 'LineItem/ORIG_PRINT_ON_TRAVELER_FLAG'),
EXTRACTVALUE(VALUE(T), 'LineItem/ORIG_BOX_CODE'),
EXTRACTVALUE(VALUE(T), 'LineItem/SUBST_PART_DESC'),
EXTRACTVALUE(VALUE(T), 'LineItem/SUBST_COMMODITY_CODE'),
EXTRACTVALUE(VALUE(T), 'LineItem/SUBST_PRINT_ON_TRAVELER_FLAG'),
EXTRACTVALUE(VALUE(T), 'LineItem/SUBST_BOX_CODE')
BULK COLLECT INTO
V_BASE_TYPE,
V_ORDER_NUM,
V_WIP_STATUS,
V_WIP_STATUS_DATE,
V_ORDER_DATE,
V_IP_DATE,
V_SHIP_BY_DATE,
V_CUSTOMER_SRC,
V_CUSTOMER_LOC,
V_CUSTOMER_NUM,
V_ACCOUNT_TYPE,
V_OVERPACK_FLAG,
V_INTERNATIONAL_FLAG,
V_MULTIPLE_SYSTEM_TIES,
V_ORDER_TIE_NUM,
V_TIE_STATUS,
V_PK_GEN,
V_QTY_REQD,
V_WORKCENTER_ID,
V_SI_NUMBER,
V_MFG_SCHED_FACILITY_ID,
V_MFG_FACILITY_ID,
V_PILOT_NAME,
V_ENG_HOLD_FLAG,
V_SHORT_FLAG,
V_OVR_SHORTAGE,
V_USER_HOLD_FLAG,
V_SHIP_TO_ADDRESS_SEQ_NUM,
V_CALICO_REF_NUM,
V_CONFIG_ID,
V_TOTAL_UNITS_QTY,
V_ORDER_TYPE,
V_SKU#,
V_SUB_ASSEMBLY_NUMBER,
V_BASE_ASM_FLAG,
V_QTY_REQ,
V_ORIGINAL_PART_NUMBER,
V_SUBSTITUTE_PART_NUMBER,
V_QTY_EXTENDED,
V_ISSUE_CODE,
V_ORIG_PART_DESC,
V_ORIG_COMMODITY_CODE,
V_ORIG_PRINT_ON_TRAVELER_FLAG,
V_ORIG_BOX_CODE,
V_SUBST_PART_DESC,
V_SUBST_COMMODITY_CODE,
V_SUBST_PRINT_ON_TRAVELER_FLAG,
V_SUBST_BOX_CODE
FROM TABLE(XMLSEQUENCE(EXTRACT(P_PODETAILS_XML, '/LineItems/LineItem'))) T
but getting performace problem. I'm able to insert 100 lines items in 3 sec but requirement is further less.
Any help..... ????
thanks in adavance..hi..
me too having same type of XML data to be inserted into oracle table
i've to write procedure for this
can u help me plz..... -
Load XML file and transform to table in database
Hi All,
If I have a xml file as sample xml data
<EMPLOYEES>
- <EMP>
<EMPNO>7369</EMPNO>
<ENAME>SMITH</ENAME>
<JOB>CLERK</JOB>
<MGR>7902</MGR>
<HIREDATE>17-DEC-80</HIREDATE>
<SAL>800</SAL>
</EMP>
</EMPLOYEES>
And I need to import to Emplyees table
Create table Employees
( EMPNO number,
ENAME varchar2(100),
JOB varchar2(100),
MGR number,
HIREDATE date,
SAL number
How to import the xml file to the table?
Regards,
HikoWell, if it's a complex XML you can use register a Schema and shred the XML to tables as described on the following thread:
Re: XML file processing into oracle
Or if it's fairly simple XML, you can just use XMLTABLE to flatten the data out...
SQL> ed
Wrote file afiedt.buf
1 WITH xml_table AS
2 (SELECT xmltype('
3 <root>
4 <child name="name1">
5 <grandchild name="name11">
6 <greatgrandchild name="name111"/>
7 <greatgrandchild name="name112"/>
8 </grandchild>
9 <grandchild name="name12"/>
10 </child>
11 <child name="name2">
12 <grandchild name="name21"/>
13 <greatgrandchild name="name211"/>
14 <grandchild name="name22"/>
15 </child>
16 </root>') object_value FROM dual)
17 select po.child_name, gc.gchild_name, ggc.ggchild_name
18 from xml_table p
19 ,xmltable('/root/child'
20 passing p.object_value
21 columns child_name varchar2(100) path '@name'
22 ,gchild xmltype path 'grandchild'
23 ) po
24 ,xmltable('/grandchild'
25 passing po.gchild
26 columns gchild_name varchar2(100) path '@name'
27 ,ggchild xmltype path 'greatgrandchild'
28 ) (+) gc
29 ,xmltable('/greatgrandchild'
30 passing gc.ggchild
31 columns ggchild_name varchar2(100) path '@name'
32* ) (+) ggc
SQL> /
CHILD_NAME GCHILD_NAME GGCHILD_NAME
name1 name11 name111
name1 name11 name112
name1 name12
name2 name21
name2 name22and then insert the results into whatever table(s) you want. -
OWB11gR2 - simple and easy way to load XML formatted data into db tables?
Hi,
we're currently trying to load table data stored in XML files into our datawarehouse using OWB 11gR2.
However, we're finding this is not quite as trivial as loading flat files...
Most postings on this forum points to the blog-entry title "Leveraging XDB" found here (http://blogs.oracle.com/warehousebuilder/2007/09/leveraging_xdb.html).
This blog also references the zip-file owb_xml_etl_utils.zip, which seems to have disappeared from it's original location and can now be found on sourceforge.
Anyway, the solution described is for OWB 10g, and when trying to import experts from the zip-file etc. we end up not being able to run the "Create ETL from XSD" expert, as the 11gR2 client is different from the 10g and does not have the Experts menu et.al.
Also, this solution was published over 3 years ago, and it seems rather strange that importing XML-formatted data should still be so cumbersome in the newer warehouse builder releases.
The OWB 11gR2 documentation is very sparse (or rather - quite empty) on how to load XML data, all it has is a few lines on "XML Transformations", giving no clue as to how one goes about loading data.
Is this really the state of things? Or are we missing some vital information here?
We'd have thought that with 11g-releases, loading XML-data would be rather simple, quick and painless?
Is there somewhere besides the blog mentioned above where we can find simple and to the point guidelines for OWB 11gR2 on how to load XML-formatted data into Oracle tables?
Regards,
-Haakon-Yes it is possible to use SQL*Loader to parse and load XML, but that is not what it was designed for and so is not recommended. You also don't need to register a schema, just to load/store/parse XML in the DB either.
So where does that leave you?
Some options
{thread:id=410714} (see page 2)
{thread:id=1090681}
{thread:id=1070213}
Those talk some about storage options and reading in XML from disk and parsing XML. They should also give you options to consider. Without knowing more about your requirements for the effort, it is difficult to give specific advice. Maybe your 7-8 tables don't exist and so using Object Relational Storage for the XML would be the best solution as you can query/update tables that Oracle creates based off the schema associated to the XML. Maybe an External Table definition works better for reading the XML into the system because this process will happen just once. Maybe using WebDAV makes more sense for loading XML to be parsed (I don't have much experience with this, just know it is possible from what I've read on the forums). Also, your version makes a difference as you have different options available depending upon the version of Oracle.
Hope all that helps as a starter.
Edited by: A_Non on Jul 8, 2010 4:31 PM
A great example, see the answers by mdrake in {thread:id=1096784}
Maybe you are looking for
-
Create a link to a specific page, on the disc
Ok. I am creating a PDF that will need buttons to link to specific pages in other PDFs. I know how to do this if the PDFs are online but the boss needs a 'dvd delivered' SOOOooooo... -Root Main PDF (with button) -subfolder Target PDF (page 3
-
Just wanted to say "Wow" - the new "Coffee Corner" is a great idea.
Apart from solving certain difficult "policy" problems so well, the new "Coffee Corner" is living proof of the idea that SAP is a great company as well as a successful and rich company. To be a great company, a corporation must tolerate intense scru
-
Hi SAP expert/ Venkat I am working on cash mangement and liquidity forecast. Integration of MM covers PO , PR and scheduling agreement. I would like to know whether it is possible to separately show Goods received but not yet invoiced as separate it
-
"Invalid Export Option" Crystal 2008 SP3, Windows 7, Outlook 2010 (32 bit)
We have one client reporting that they get "Invalid Export Option" whenever they try to email a report. We used the supplied code with VS 2008 to implement the ability to view, print, export, and email reports. Our Windows 7 computers all work with
-
OSX 10.8.2 Tethering to iPhone4S wifi No Internet Connection
Hello, Since upgrading something (OSX or iOS), I now have headaches when tethering my Macbook to my iPhone (both with latest versions). I used to be able to select my iPhone in the wifi drop down, it would think about it for a few seconds, then conne