Loading a falt file into table using sqlloader
I have a flat file (csv/txt) which has a header and a trailer record
I want to load it using SQLLoader , i want to skip this trailer/footer record.
Please suggest , due to some business rules i cannot use WHEN clause
I am on Oracle 11g
Well, maybe you'll get better help in theses spaces then, ODI is not really my cup of tea:
Data Integrator
https://forums.oracle.com/community/developer/english/oracle_database/export_import_sql_loader_%26_external_tables
Similar Messages
-
Load an XML file into table(s)
Hi ,
I have to load data from an xml file into an Oracle DB but I never used this king of process before. The purpose is to use as much as possible Oracle standard features ( stored procedures , functions , API's ).
Can someone explain me in simple explanations how to do it ? Thanks in advance for your help.
The XML must not be stored in the database , only the final tables
Values can be inserted , updated , or deleted from the final tables
Here are the versions of the tools I am using :
Oracle RDBMS : 10.2.0.4.0
Oracle Applications : 11.5.10.2
Toad : 9.5.0.31
SQL Plus : 8.0.6.0.0
The header of the xsd :
<?xml version="1.0" encoding="windows-1252" ?>
- <!-- edited with XMLSPY v2004 rel. 4 U (http://www.xmlspy.com) by erik de bruyn (Graydon)
-->
- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3schools.com" targetNamespace="http://www.w3schools.com" elementFormDefault="qualified">
An extract of the xml :
<?xml version="1.0" encoding="windows-1252" ?>
- <GraydonBeDialogue>
<TransactionCode>RTB</TransactionCode>
- <Table ClassTable="Country">
- <TableEntry>
<TableLanguage>N</TableLanguage>
<TableCode>AD</TableCode>
<TableValue>Andorra</TableValue>
</TableEntry>
- <TableEntry>
<TableLanguage>N</TableLanguage>
<TableCode>AE</TableCode>
<TableValue>Verenigde Arabische Emiraten</TableValue>
</TableEntry>
</Table>
- <Table ClassTable="Summons">
- <TableEntry>
<TableLanguage>N</TableLanguage>
<TableCode>D</TableCode>
<TableValue>De dagvaarding is het gevolg</TableValue>
</TableEntry>
- <TableEntry>
<TableLanguage>N</TableLanguage>
<TableCode>S</TableCode>
<TableValue>Doorgehaald bij de arbeidsrechtbank</TableValue>
</TableEntry>
</Table>
</GraydonBeDialogue>
The result I would have :
Two tables ( Country and Summons ) , each containing 3 columns ( TableLanguage , TableCode , TableValue ) :
Table Country : TableLanguage TableCode TableValue
N AD Andorra
N AE Verenigde Arabische Emiraten
Table Summons : TableLanguage TableCode TableValue
N D De dagvaarding is het gevolg
N S Doorgehaald bij de arbeidsrechtbankfor table Country
create table Country as
with t as (
select
xmltype (
'<?xml version="1.0" encoding="windows-1252" ?>
<GraydonBeDialogue>
<TransactionCode>RTB</TransactionCode>
<Table ClassTable="Country">
<TableEntry>
<TableLanguage>N</TableLanguage>
<TableCode>AD</TableCode>
<TableValue>Andorra</TableValue>
</TableEntry>
<TableEntry>
<TableLanguage>N</TableLanguage>
<TableCode>AE</TableCode>
<TableValue>Verenigde Arabische Emiraten</TableValue>
</TableEntry>
</Table>
<Table ClassTable="Summons">
<TableEntry>
<TableLanguage>N</TableLanguage>
<TableCode>D</TableCode>
<TableValue>De dagvaarding is het gevolg</TableValue>
</TableEntry>
<TableEntry>
<TableLanguage>N</TableLanguage>
<TableCode>S</TableCode>
<TableValue>Doorgehaald bij de arbeidsrechtbank</TableValue>
</TableEntry>
</Table>
</GraydonBeDialogue>') as xml
from dual
select x.TableLanguage, x.TableCode, x.TableValue
from t
,xmltable('/GraydonBeDialogue/Table[@ClassTable="Country"]/TableEntry'
passing t.xml
columns TableLanguage varchar2(50) path '/TableEntry/TableLanguage'
, TableCode varchar2(50) path '/TableEntry/TableCode'
, TableValue varchar2(50) path '/TableEntry/TableValue'
) x -
Trouble Loading a flat file into BPS using a Web Browser, Please help ?
Hi Gurus,
I'm in BW 3.5.
I did everything and also followed the How to .. paper to upload a flat file into BPS tran cube via a Web browser.
I created a Web Browser and generated a BSP application. When I run the BSP application I get the following error:
"The generated data is not contained in the selection condition" UPC204
The error message also says:
"The error message can appear when you use a planning function to generate data that is outside the data range specified by the selection conditions of the planning package"
When I save the variables that I select in the web interface they are getting saved in a table(UPC_VAR_CHA_ACT), but somehow the BSP application cannot look into those values, which I think is the cause of above issue.
Please help.
VenkatHi,
This type of error is quite common in BPS operations. This generally happens due to some missing values in the restriction of the planning levels and the packages.
The error message is "The generated data is not contained in the selection condition" UPC204
Check in the planning level and the package, all the restrictions that have been defined and verify whether the values which are getting uploaded through the flat file are present in the election condition of the level or in the package.
Please award points if helpful. -
Upload multiple excel files into tables using APEX
Hi folks,
I'm wondering if anyone has ever uploaded multiple .csv files simultaniously and store the data into the database using APEX XE before.
I can browse for a single file, and execute that okay and a good example of doing that can be found at http://advait.wordpress.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/
This works fine when the user browses to a specific file on their network and then uploads the data from that one file.
However I need the ability to 'grab' every file in a specific directory one after the other to process rather than having to specify which one to load everytime, and wondered if anyone has come across this before.
Many thanks
Graham.Just for completeness ...
Got this to work, but it's a pl/sql issue as opposed to an APEX issue.
Anyway, if anyone needs to have the ability to read multiple files then a quick easy way to do it (as lomg as they know the file names that will be read), is to create a directory on the database which points to the actual harddrive on your PC, then create a table (called an external table) and read from that external table as if it was an actual database table ...
1 - Log on as sys and grant CREATE ANY DIRECTORY to whatever user you are logging in as (assuming you are not using sys to create apps)
2 - Create a directory e.g....CREATE OR REPLACE DIRECTORY GB_TEST AS 'c:\gbtest';
3 - Create an external table as ...
CREATE TABLE gb_test
(file_name varchar2(10),
rec_date date
rec_name VARCHAR2(20),
rec_age number,
ORGANIZATION EXTERNAL
TYPE ORACLE_LOADER
DEFAULT DIRECTORY GB_TEST
ACCESS PARAMETERS
RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ','
LOCATION ('data1.csv','data2.csv','data3.csv','data4.csv')
PARALLEL 5
REJECT LIMIT 20000;
That's it then ...
select * from gb_test
where file_name = 'xxx'
will return all the data where the file_name = 'xxx'
very easy to use. -
How to load csv file to table using ssis
Hi,
i have loaded the csv file to table using ssis, it is working file but record is mismatch.
source data :
col1 col2 col3 col4
aa, bb, this is sample,data for the details, this is
column delimiter - comma
col3 - record contains comma. so col3 record after the comma is added with the as col4
i need the col3 record with comma.
so what is the column delimiter will use ?
Regards,
abdul KhadirHi Abdul,
Based on your description, you want to distinguish a comma is used for column separator or used in address column in a text file, then load the data from the text file to SQL Server table.
As per my understanding, if you can replace the comma column separator to another delimiter like semicolon (;), just do it. Then we can select Semicolon {;} as Column delimiter for the Flat File Connection Manager. Or ensure all columns are enclosed in double
quotes ("). Then we can set the double quotes (") as Text qualifier for the Flat File Connection Manager, and the commas will be loaded as part of the string fields.
If you can't have that done, because computers don't know the context of the data, you would have to come up with some kind of rules that decides when a comma represents a delimiter, and when it is just part of the text. I think a custom script component
would be necessary to pre-process the data, identify where a comma is part of an address, and then treat that as one field.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Loading this xml data into tables
Hello,
I am having a problem loading this XML file into tables. The xml file structure is
<FILE>
<ACCESSION>
some ids
<INSTANCE>
some data
<VARIATION
</VARIATION>
<VARIATION>
</VARIATION> variation gets repeated a number of times
<ASSEMBLY>
</ASSEMBLY>
<ASSEMBLY>
</ASSEMBLY> Assembly gets repeated a number of times.
</INSTANCE>
</ACCESSION>
</FILE>
I created a table which has the structure:
create table accession(
accession_id varchar2(20),
Instance instance_type);
create or replace type instance_type as object
(method varchar2(20),
class varchar2(20),
source varchar2(20),
num_char number(10),
variation variation_type,
assembly assembly_type)
create or replace type variation_type as object
(value varchar2(2),
count number(10),
frequency number(10),
pop_id varchar2(10)
Created a similiar type for assembly.
When I load it, I could only store the first variation data but not the subsequent ones. Similarly for assembly I could only store the first data but not the subsequent ones.
Could anyone let me know how I could store this data into tables? I have also included a sample XML file in this message.
Thank You for your help.
Rama.
Here is the sample xml file.
<?xml version="1.0" ?>
- <FILE>
- <ACCESSION>
<ACCESSION_ID>accid1</ACCESSION_ID>
- <INSTANCE>
<METHOD>method1</METHOD>
<CLASS>class1</CLASS>
<SOURCE>source1</SOURCE>
<NUM_CHAR>40</NUM_CHAR>
- <VARIATION>
<VALUE>G</VALUE>
<COUNT>5</COUNT>
<FREQUENCY>66</FREQUENCY>
<POP1>pop1</POP1>
<POP2>pop1</POP2>
</VARIATION>
<VARIATION>
<VALUE>C</VALUE>
<COUNT>2</COUNT>
<FREQUENCY>33</FREQUENCY>
<POP_ID1>pop2</POP_ID1>
</VARIATION>
- <ASSEMBLY>
<ASSEMBLY_ID>1</ASSEMBLY_ID>
<BEGIN>180</BEGIN>
<END>180</END>
<TYPE>2</TYPE>
<ORI>-</ORI>
<OFFSET>0</OFFSET>
</ASSEMBLY>
- <ASSEMBLY>
<ASSEMBLY_ID>2</ASSEMBLY_ID>
<BEGIN>235</BEGIN>
<END>235</END>
<TYPE>2</TYPE>
<ORI>-</ORI>
<OFFSET>0</OFFSET>
</ASSEMBLY>
</INSTANCE>
</ACCESSION>
</FILE>Hello,
I could figure out how to load this XML file by using cast(multiset(
So never mind.
Thank You.
Rama. -
How to load the data from excel file into table in oracle using UTL_FI
How to load the data from excel file into table in oracle
and from table to excel file
using UTL_FILE package
Please give me some exampleThis is something i tried in oracle apex
http://avdeo.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/
Regards,
CKLP -
Xml data upload into tables using loader
Hi,
I have to load XML file data into multiple tables using sqlloader. i wrote a cotrol file to execute this ,but i was not able to load the data into multiple tables at the same time, first loading table in control file is able to load the data ,rest of the load is giving error,please refer the below control file and log. Help me with your great efforts.
Have a great day!
Control file:
LOAD DATA
TRUNCATE
INTO TABLE Derivative_Security
WHEN DERIVATIVESECURITYID != ' '
FIELDS TERMINATED BY '</DerivativeSecurity>' optionally enclosed by '"'
TRAILING NULLCOLS
DUMMY1 filler char(50000) Terminated by '<DerivativeSecurity ',
DUMMY2 filler char(200) Terminated by WHITESPACE enclosed by 'FAS157Level="' and '"',
DUMMY3 filler char(200) Terminated by WHITESPACE enclosed by 'FAS157MVAdjustable="' and '"',
DUMMY4 filler char(200) Terminated by WHITESPACE enclosed by 'OriginalMV="' and '"',
DUMMY5 filler char(200) Terminated by WHITESPACE enclosed by 'FAS157MVDelta="' and '"',
DUMMY6 filler char(200) Terminated by WHITESPACE enclosed by 'FAS157AdjustedMV="' and '"',
DUMMY7 filler char(200) Terminated by WHITESPACE enclosed by 'PLCurrency="' and '"',
DERIVATIVESECURITYID Terminated by WHITESPACE enclosed by 'DerivativeSecurityID="' and '"',
METDERIVATIVEID Terminated by WHITESPACE enclosed by 'MetDerivativeID="' and '"',
MUREXTRANSNUMBER Terminated by WHITESPACE enclosed by 'MurexTransactionNumber="' and '"',
DUMMY8 filler char(200) Terminated by WHITESPACE enclosed by 'Trader="' and '"',
DUMMY9 filler char(200) Terminated by WHITESPACE enclosed by 'BuySell="' and '"',
DETAILTYPE Terminated by WHITESPACE enclosed by 'DetailType="' and '"',
DERIVATIVETYPE Terminated by WHITESPACE enclosed by 'DerivativeType="' and '"',
AL_MANAGEMENTSIDE Terminated by WHITESPACE enclosed by 'AL_ManagementSide="' and '"',
COUNTERPARTYCODE Terminated by WHITESPACE enclosed by 'CounterpartyCode="' and '"',
COUNTERPARTYNAME Terminated by WHITESPACE enclosed by 'CounterpartyName="' and '"',
CURRENCYCODE Terminated by WHITESPACE enclosed by 'CurrencyCode="' and '"',
DUMMY10 filler char(200) Terminated by WHITESPACE enclosed by 'Coupon="' and '"',
DUMMY11 filler char(200) Terminated by WHITESPACE enclosed by 'FixedFloatingIndicator="' and '"',
DUMMY12 filler char(200) Terminated by WHITESPACE enclosed by 'IndexMultiplier="' and '"',
DUMMY13 filler char(200) Terminated by WHITESPACE enclosed by 'IndexName="' and '"',
DUMMY42 filler char(200) Terminated by WHITESPACE enclosed by 'Margin="' and '"',
DUMMY14 filler char(200) Terminated by WHITESPACE enclosed by 'Comment11="' and '"',
DUMMY15 filler char(200) Terminated by WHITESPACE enclosed by 'Comment12="' and '"',
DUMMY16 filler char(200) Terminated by WHITESPACE enclosed by 'Comment13="' and '"',
DUMMY17 filler char(200) Terminated by WHITESPACE enclosed by 'Comment21="' and '"',
DUMMY18 filler char(200) Terminated by WHITESPACE enclosed by 'Comment22="' and '"',
DUMMY19 filler char(200) Terminated by WHITESPACE enclosed by 'Comment23="' and '"',
DUMMY20 filler char(2000) Terminated by WHITESPACE enclosed by 'TradeComment="' and '"',
DUMMY21 filler char(200) Terminated by WHITESPACE enclosed by 'OptionCallPut="' and '"',
DUMMY22 filler char(200) Terminated by WHITESPACE enclosed by 'OptionType="' and '"',
DUMMY23 filler char(200) Terminated by WHITESPACE enclosed by 'SettleType="' and '"',
DUMMY24 filler char(200) Terminated by WHITESPACE enclosed by 'RefISIN="' and '"',
DUMMY25 filler char(200) Terminated by WHITESPACE enclosed by 'RefObligation="' and '"',
DUMMY26 filler char(200) Terminated by WHITESPACE enclosed by 'Sensitivity="' and '"',
DUMMY27 filler char(200) Terminated by WHITESPACE enclosed by 'EffectiveConvexity="' and '"',
DUMMY28 filler char(200) Terminated by WHITESPACE enclosed by 'Vega="' and '"',
DUMMY29 filler char(200) Terminated by WHITESPACE enclosed by 'NextResetDate="' and '"',
DUMMY30 filler char(200) Terminated by WHITESPACE enclosed by 'LastResetDate="' and '"',
EFFECTIVEDURATION Terminated by WHITESPACE enclosed by 'EffectiveDuration="' and '"',
DUMMY31 filler char(200) Terminated by WHITESPACE enclosed by 'Instrument="' and '"',
DUMMY32 filler char(200) Terminated by WHITESPACE enclosed by 'IssuerCode="' and '"',
DUMMY33 filler char(200) Terminated by WHITESPACE enclosed by 'IssuerName="' and '"',
DUMMY34 filler char(200) Terminated by WHITESPACE enclosed by 'IssuerREDCode="' and '"',
DUMMY35 filler char(200) Terminated by WHITESPACE enclosed by 'Strategy="' and '"',
DUMMY36 filler char(200) Terminated by WHITESPACE enclosed by 'StrikePrice="' and '"',
MATURITYDATE Terminated by WHITESPACE enclosed by 'MaturityDate="' and '"',
DUMMY37 filler char(200) Terminated by WHITESPACE enclosed by 'TickerSymbol="' and '"',
DUMMY38 filler char(200) Terminated by WHITESPACE enclosed by 'MetPay="' and '"',
DUMMY39 filler char(200) Terminated by WHITESPACE enclosed by 'MetRec="' and '"',
DUMMY40 filler char(200) Terminated by WHITESPACE enclosed by 'Payrec="' and '"',
DUMMY41 filler char(200) Terminated by WHITESPACE enclosed by 'RiskSection="' and '"',
DUMMY54 filler char(200) Terminated by WHITESPACE enclosed by 'HedgedItem="' and '"',
DUMMY43 filler char(200) Terminated by WHITESPACE enclosed by 'ResetFrequency="' and '"',
DUMMY44 filler char(200) Terminated by WHITESPACE enclosed by 'ResetFrequencyNumber="' and '"',
DUMMY45 filler char(200) Terminated by WHITESPACE enclosed by 'PaymentFrequency="' and '"',
DUMMY46 filler char(200) Terminated by WHITESPACE enclosed by 'PaymentFrequencyNumber="' and '"',
DUMMY47 filler char(200) Terminated by WHITESPACE enclosed by 'CapFloorCoupon="' and '"',
DUMMY48 filler char(200) Terminated by WHITESPACE enclosed by 'RefIndexRate="' and '">',
DUMMY50 filler char(1000) enclosed by "<Classification=" and "/>",
DUMMY51 filler char(1000) enclosed by "<Classification=" and "/>",
DUMMY52 filler char(1000) enclosed by "<Classification=" and "/>",
DUMMY53 filler char(1000) enclosed by "<Classification=" and "/>"
INTO TABLE DERIVATIVE_POSITION
WHEN PORTFOLIOCODE != ' '
FIELDS TERMINATED BY '</NewDataSet>' optionally enclosed by '"'
TRAILING NULLCOLS
DUMMY1 filler char(65000) terminated by '<DerivativePosition ',
DERIVATIVESECURITYID TERMINATED BY WHITESPACE enclosed by 'DerivativeSecurityID="' and '"',
PORTFOLIOCODE TERMINATED BY WHITESPACE enclosed by 'PortfolioCode="' and '"',
LONGSHORTINDICATOR TERMINATED BY WHITESPACE ENCLOSED BY 'LongShortIndicator="' and '"',
FAS157Level filler char(100) TERMINATED BY WHITESPACE enclosed by 'FAS157Level="' and '"',
FAS157MVAdjustable filler char(100) TERMINATED BY WHITESPACE enclosed by 'FAS157MVAdjustable="' and '"',
OriginalMV filler char(100)TERMINATED BY WHITESPACE enclosed by 'OriginalMV="' and '"',
FAS157MVDelta filler char(100) TERMINATED BY WHITESPACE enclosed by 'FAS157MVDelta="' and '"',
FAS157AdjustedMV filler char(100)TERMINATED BY WHITESPACE enclosed by 'FAS157AdjustedMV="' and '"',
CURRENTNOTIONALLOCAL TERMINATED BY WHITESPACE enclosed by 'CurrentNotionalLocal="' and '"',
CURRENTNOTIONALUSD TERMINATED BY WHITESPACE enclosed by 'CurrentNotionalUSD="' and '"',
OPENQUANTITY TERMINATED BY WHITESPACE enclosed by 'OpenQuantity="' and '"',
ORIGINALNOTIONALLOCAL TERMINATED BY WHITESPACE enclosed by 'OriginalNotionalLocal="' and '"',
ORIGINALNOTIONALUSD TERMINATED BY WHITESPACE enclosed by 'OriginalNotionalUSD="' and '"',
ORIGINALQUANTITY TERMINATED BY WHITESPACE enclosed by 'OriginalQuantity="' and '"',
ACCRUEDINTERESTLOCAL TERMINATED BY WHITESPACE enclosed by 'AccruedInterestLocal="' and '"',
ACCRUEDINTERESTUSD TERMINATED BY WHITESPACE enclosed by 'AccruedInterestUSD="' and '"',
ACCRUEDINTERESTBASE TERMINATED BY WHITESPACE enclosed by 'AccruedInterestBase="' and '"',
CLEANMARKETVALUEENDOFDAYLOCAL TERMINATED BY WHITESPACE enclosed by 'CleanMarketValueEndOfDayLocal="' and '"',
CLEANMARKETVALUEENDOFDAYUSD TERMINATED BY WHITESPACE enclosed by 'CleanMarketValueEndOfDayUSD="' and '"',
CLEANMARKETVALUEENDOFDAYBASE TERMINATED BY WHITESPACE enclosed by 'CleanMarketValueEndOfDayBase="' and '"',
DIRTYMARKETVALUEENDOFDAYLOCAL TERMINATED BY WHITESPACE enclosed by 'DirtyMarketValueEndOfDayLocal="' and '"',
DIRTYMARKETVALUEENDOFDAYUSD TERMINATED BY WHITESPACE enclosed by 'DirtyMarketValueEndOfDayUSD="' and '"',
PREMIUMLOCAL TERMINATED BY WHITESPACE enclosed by 'PremiumLocal="' and '"',
PREMIUMUSD TERMINATED BY WHITESPACE enclosed by 'PremiumUSD="' and '"',
PREMIUMBASE TERMINATED BY WHITESPACE enclosed by 'PremiumBase="' and '"',
BIDDIES TERMINATED BY WHITESPACE enclosed by 'Biddies="' and '"',
ADDONEXPOSUREUSD TERMINATED BY WHITESPACE enclosed by 'AddOnExposureUSD="' and '"',
RegulatoryExposureUSD filler char(100) TERMINATED BY WHITESPACE enclosed by 'RegulatoryExposureUSD="' and '"',
PARCR01 filler char(100) TERMINATED BY WHITESPACE enclosed by 'PARCR01="' and '"',
FAS133DESIGNATIONGAAP TERMINATED BY WHITESPACE enclosed by 'FAS133DesignationGAAP="' and '"',
FAS133DESIGNATIONSTAT TERMINATED BY WHITESPACE enclosed by 'FAS133DesignationSTAT="' and '"',
TRADEDATE TERMINATED BY WHITESPACE enclosed by 'TradeDate="' and '"',
EffectiveDate filler char(100) TERMINATED BY WHITESPACE enclosed by 'EffectiveDate="' and '"',
ALLOCATION TERMINATED BY WHITESPACE enclosed by 'Allocation="' and '"' "round(:ALLOCATION,4)",
DUMMY36 filler char(100) enclosed by '/' and '>'
Log:
Table DERIVATIVE_SECURITY:
4079 Rows successfully loaded.
0 Rows not loaded due to data errors.
28074 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Table DERIVATIVE_POSITION:
0 Rows successfully loaded.
0 Rows not loaded due to data errors.
32153 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 248196 bytes(26 rows)
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 32153
Total logical records rejected: 0
Total logical records discarded: 28074When there are multiple tables in a control file, SQL Loader assumes the data for the first file in the second table immediately follows the last field in the first table. You probably want SQL Loader to start looking for the first column of the second table at the start of the second table. You can do this by using the POSITION clause
DUMMY51 filler char(1000) enclosed by "<Classification=" and "/>",
DUMMY52 filler char(1000) enclosed by "<Classification=" and "/>",
DUMMY53 filler char(1000) enclosed by "<Classification=" and "/>"
INTO TABLE DERIVATIVE_POSITION
WHEN PORTFOLIOCODE != ' '
FIELDS TERMINATED BY '</NewDataSet>' optionally enclosed by '"'
TRAILING NULLCOLS
DUMMY1 filler *position(1)* char(65000) terminated by '<DerivativePosition ',
DERIVATIVESECURITYID TERMINATED BY WHITESPACE enclosed by 'DerivativeSecurityID="' and '"',
PORTFOLIOCODE TERMINATED BY WHITESPACE enclosed by 'PortfolioCode="' and '"',
. -
How to load a XML file into a table
Hi,
I've been working on Oracle for many years but for the first time I was asked to load a XML file into a table.
As an example, I've found this on the web, but it doesn't work
Can someone tell me why? I hoped this example could help me.
the file acct.xml is this:
<?xml version="1.0"?>
<ACCOUNT_HEADER_ACK>
<HEADER>
<STATUS_CODE>100</STATUS_CODE>
<STATUS_REMARKS>check</STATUS_REMARKS>
</HEADER>
<DETAILS>
<DETAIL>
<SEGMENT_NUMBER>2</SEGMENT_NUMBER>
<REMARKS>rp polytechnic</REMARKS>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>3</SEGMENT_NUMBER>
<REMARKS>rp polytechnic administration</REMARKS>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>4</SEGMENT_NUMBER>
<REMARKS>rp polytechnic finance</REMARKS>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>5</SEGMENT_NUMBER>
<REMARKS>rp polytechnic logistics</REMARKS>
</DETAIL>
</DETAILS>
<HEADER>
<STATUS_CODE>500</STATUS_CODE>
<STATUS_REMARKS>process exception</STATUS_REMARKS>
</HEADER>
<DETAILS>
<DETAIL>
<SEGMENT_NUMBER>20</SEGMENT_NUMBER>
<REMARKS> base polytechnic</REMARKS>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>30</SEGMENT_NUMBER>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>40</SEGMENT_NUMBER>
<REMARKS> base polytechnic finance</REMARKS>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>50</SEGMENT_NUMBER>
<REMARKS> base polytechnic logistics</REMARKS>
</DETAIL>
</DETAILS>
</ACCOUNT_HEADER_ACK>
For the two tags HEADER and DETAILS I have the table:
create table xxrp_acct_details(
status_code number,
status_remarks varchar2(100),
segment_number number,
remarks varchar2(100)
before I've created a
create directory test_dir as 'c:\esterno'; -- where I have my acct.xml
and after, can you give me a script for loading data by using XMLTABLE?
I've tried this but it doesn't work:
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;
This should allow me to get something like this:
select * from xxrp_acct_details;
Statuscode status remarks segement remarks
100 check 2 rp polytechnic
100 check 3 rp polytechnic administration
100 check 4 rp polytechnic finance
100 check 5 rp polytechnic logistics
500 process exception 20 base polytechnic
500 process exception 30
500 process exception 40 base polytechnic finance
500 process exception 50 base polytechnic logistics
but I get:
Error report:
ORA-06550: line 19, column 11:
PL/SQL: ORA-00932: inconsistent datatypes: expected - got NUMBER
ORA-06550: line 4, column 2:
PL/SQL: SQL Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
and if I try to change the script without using the column HEADER_NO to keep track of the header rank inside the document:
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 status_code number path 'STATUS_CODE',
status_remarks varchar2(100) path 'STATUS_REMARKS'
) x1,
xmltable(
'/ACCOUNT_HEADER_ACK/DETAILS'
passing acct_doc
columns segment_number number path 'SEGMENT_NUMBER',
remarks varchar2(100) path 'REMARKS'
) x2
END;
I get this message:
Error report:
ORA-19114: error during parsing the XQuery expression:
ORA-06550: line 1, column 13:
PLS-00201: identifier 'SYS.DBMS_XQUERYINT' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
ORA-06512: at line 4
19114. 00000 - "error during parsing the XQuery expression: %s"
*Cause: An error occurred during the parsing of the XQuery expression.
*Action: Check the detailed error message for the possible causes.
My oracle version is 10gR2 Express Edition
I do need a script for loading xml files into a table as soon as possible, Give me please a simple example for understanding and that works on 10gR2 Express Edition
Thanks in advance!The reason your first SQL statement
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
returns the error you noticed
PL/SQL: ORA-00932: inconsistent datatypes: expected - got NUMBER
is because Oracle is expecting XML to be passed in. At the moment I forget if it requires a certain format or not, but it is simply expecting the value to be wrapped in simple XML.
Your query actually runs as is on 11.1 as Oracle changed how that functionality worked when 11.1 was released. Your query runs slowly, but it does run.
As you are dealing with groups, is there any way the input XML can be modified to be like
<ACCOUNT_HEADER_ACK>
<ACCOUNT_GROUP>
<HEADER>....</HEADER>
<DETAILS>....</DETAILS>
</ACCOUNT_GROUP>
<ACCOUNT_GROUP>
<HEADER>....</HEADER>
<DETAILS>....</DETAILS>
</ACCOUNT_GROUP>
</ACCOUNT_HEADER_ACK>
so that it is easier to associate a HEADER/DETAILS combination? If so, it would make parsing the XML much easier.
Assuming the answer is no, here is one hack to accomplish your goal
select x1.status_code,
x1.status_remarks,
x3.segment_number,
x3.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'
passing acct_doc as "d",
columns detail_no for ordinality,
detail_xml xmltype path 'DETAIL'
) x2,
xmltable(
'DETAIL'
passing x2.detail_xml
columns segment_number number path 'SEGMENT_NUMBER',
remarks varchar2(100) path 'REMARKS') x3
WHERE x1.header_no = x2.detail_no;
This follows the approach you started with. Table x1 creates a row for each HEADER node and table x2 creates a row for each DETAILS node. It assumes there is always a one and only one association between the two. I use table x3, which is joined to x2, to parse the many DETAIL nodes. The WHERE clause then joins each header row to the corresponding details row and produces the eight rows you are seeking.
There is another approach that I know of, and that would be using XQuery within the XMLTable. It should require using only one XMLTable but I would have to spend some time coming up with that solution and I can't recall whether restrictions exist in 10gR2 Express Edition compared to what can run in 10.2 Enterprise Edition for XQuery. -
Loading external (PDF)file into BLOB colum in the table. Need urgent help.
Hi All,
I've currently been working on loading many external binary files (PDF) into BLOB column. After some digging, I learn that the SQL*LOADER can be used to load data from external files into table. I also got help from another forummate mentioning to use PL/SQL procedure to do so. Since I have not done anything like this before. So, my question is what is the simple approach needed to upload PDF files into a table(there is only one table containing BLOB column in my database). In addition, the LOBs can not be query-able, I wanted to list the contents of the LOBs column to make sure that I did successfully upload data into the database. How can I do that?. I do need your help. Please direct me step by step how to do so. Your help is greatly appreciated.
Regards,
TrangOnce the PDF file is inserted in the PDM table, i am not able to read the PDF data from the below code, This code converts the binary data into the Character data i.e BLOB data into the CLOB, but still the data is not proper which is getting inserted PDF is proprietary format of Adobe. And you cant just read it from pl/sql. You need Adobe software installed in your client machine to view it.
Here is an example of how to do it.
[url http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:232814159006] Display PDF Stored in Database from ASKTOM -
Error loading local CSV file into external table
Hello,
I am trying to load a CSV file located on my C:\ drive on a WIndows XP system into an 'external table'. Everyting used to work correctly when using Oracle XE (iinstalled also locally on my WIndows system).
However, once I am trynig to load the same file into a Oracle 11g R2 database on UNIX, I get the following errr:
ORA-29913: Error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
error opening file ...\...\...nnnnn.log
Please let me know if I can achieve the same functionality I had with Oracle XP.
(Note: I cannot use SQL*Loader approach, I am invoking Oracle stored procedures from VB.Net that are attempting to load data into external tables).
Regards,
M.R.user7047382 wrote:
Hello,
I am trying to load a CSV file located on my C:\ drive on a WIndows XP system into an 'external table'. Everyting used to work correctly when using Oracle XE (iinstalled also locally on my WIndows system).
However, once I am trynig to load the same file into a Oracle 11g R2 database on UNIX, I get the following errr:
ORA-29913: Error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
error opening file ...\...\...nnnnn.log
Please let me know if I can achieve the same functionality I had with Oracle XP.
(Note: I cannot use SQL*Loader approach, I am invoking Oracle stored procedures from VB.Net that are attempting to load data into external tables).
Regards,
M.R.So your database is on a unix box, but the file is on your Windows desktop machine? So .... how is it you are making your file (on your desktop) visible to your database (on a unix box)??????? -
Loading an XML file into the table without creating a directory .
Hi,
I wanted to load an XML file into a table column . But I should not create a directory in the server and placing the XML file there and giving the path in the insert query. Can anybody help me here?
Thanks in advance.You could write a java stored procedure that retrieves the file into a clob. Wrap that in a function call and use it in your insert statement.
This solution require read privileges granted by sys and is therefore only feasible if the top-level directory/directories are known or you get read-access to everything. -
Load a flat file into BW-BPS using SAP GUI
Hi,
We are using BW BPS 3.5 version, i implemented how to guide " How to load a flat file into BW-BPS using SAP GUI" successfully without any errors.
I inlcuded three infoobjects in the text file costelemt, Posting period and amount. the same three infoobjects i inlcuded the file structure in the global data as specified in the how to document
The flat file format is like this
Costelmnt Postingperiod Amount
XXXXX #
XXXXX 1 100
XXXXX 2 800
XXXXX 3 700
XXXXX 4 500
XXXXX 5 300
XXXXX 6 200
XXXXX 7 270
XXXXX 8 120
XXXXX 9 145
XXXXX 10 340
XXXXX 11 147
XXXXX 12 900
I successfully loaded above flat file in to BPS cube and it dispalyed in the layout also.
But users are requesting to load flatfile in the below format
Costelmnt Annual(PP=#) Jan(PP=1) Feb(PP=2) ........................................Dec(PP=12)
XXXXX Blank 100 800 900
Is it possible to load a flat file like this
They wants load a single row instead of 13 rows for each costelement
How to do this. Please suggest me if anybody accorss this requirment.
In the infocube we have got only one Info object 0FISCPER3(Posting period) and one 0AMOUNT(Amount)
do we need 13 Infobjects for each posting period and amount.
Is there any possiblity we can implement any user exit which we use in BEX Quer's
Please share your ideas on this.
Thanks in advance
Best regards
SSHi,
There are 2 ways to do this.
One is to change the structure of the cube to have 12 key figures for the 12 posting periods.
Another way is to write an ABAP Function Module to fetch the values from each record based on the posting period and store it in the cube for the corresponding characteristic. This way, you dont have to change the structure of the cube.
If this particular cube is not used anywhere else, I would suggest to change the structure itself.
Hope this helps. -
How can one read a Excel File and Upload into Table using Pl/SQL Code.
How can one read a Excel File and Upload into Table using Pl/SQL Code.
1. Excel File is on My PC.
2. And I want to write a Stored Procedure or Package to do that.
3. DataBase is on Other Server. Client-Server Environment.
4. I am Using Toad or PlSql developer tool.If you would like to create a package/procedure in order to solve this problem consider using the UTL_FILE in built package, here are a few steps to get you going:
1. Get your DBA to create directory object in oracle using the following command:
create directory TEST_DIR as ‘directory_path’;
Note: This directory is on the server.
2. Grant read,write on directory directory_object_name to username;
You can find out the directory_object_name value from dba_directories view if you are using the system user account.
3. Logon as the user as mentioned above.
Sample code read plain text file code, you can modify this code to suit your need (i.e. read a csv file)
function getData(p_filename in varchar2,
p_filepath in varchar2
) RETURN VARCHAR2 is
input_file utl_file.file_type;
--declare a buffer to read text data
input_buffer varchar2(4000);
begin
--using the UTL_FILE in built package
input_file := utl_file.fopen(p_filepath, p_filename, 'R');
utl_file.get_line(input_file, input_buffer);
--debug
--dbms_output.put_line(input_buffer);
utl_file.fclose(input_file);
--return data
return input_buffer;
end;
Hope this helps. -
Getting error while loading flat file into table.
I am using ODI 11 and i am trying to load data in oracle database table using source as flat .txt file .
When i execute the interface , i am getting below errors.
ODI-1217: Session INF_FILE2TAB (31022) fails with return code 7000.
ODI-1226: Step INF_FILE2TAB fails after 1 attempt(s).
ODI-1240: Flow INF_FILE2TAB fails while performing a Loading operation. This flow loads target table PARTNER.
Caused By: org.apache.bsf.BSFException: exception from Jython:
Traceback (most recent call last):
File "<string>", line 44, in <module>
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:457)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:889)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:476)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:204)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:540)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:202)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1074)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1466)
at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:2224)
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:2168)
at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:333)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
java.sql.SQLException: java.sql.SQLException: ORA-06564: object DAT_DIR does not exist
at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:146)
at com.sunopsis.dwg.codeinterpretor.SnpScriptingInterpretor.execInBSFEngine(SnpScriptingInterpretor.java:346)
at com.sunopsis.dwg.codeinterpretor.SnpScriptingInterpretor.exec(SnpScriptingInterpretor.java:170)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java:2458)
at oracle.odi.runtime.agent.execution.cmd.ScriptingExecutor.execute(ScriptingExecutor.java:48)
at oracle.odi.runtime.agent.execution.cmd.ScriptingExecutor.execute(ScriptingExecutor.java:1)
at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:50)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2906)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2609)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:540)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:453)
at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:1740)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:338)
at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:214)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:272)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:263)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:822)
at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:123)
at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:83)
at java.lang.Thread.run(Thread.java:662)
Please let me know pointers on this.Yes,after your sugestion i have created ODI agent and tested the file system connection in topology. It was connected successfully.
but when i tried again for file to table load. Again got below error.
org.apache.bsf.BSFException: exception from Jython:
Traceback (most recent call last):
File "<string>", line 44, in <module>
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:457)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:889)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:476)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:204)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:540)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:202)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1074)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1466)
at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:2224)
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:2168)
at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:333)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
java.sql.SQLException: java.sql.SQLException: ORA-06564: object DAT_DIR does not exist
at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:146)
at com.sunopsis.dwg.codeinterpretor.SnpScriptingInterpretor.execInBSFEngine(SnpScriptingInterpretor.java:346)
at com.sunopsis.dwg.codeinterpretor.SnpScriptingInterpretor.exec(SnpScriptingInterpretor.java:170)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java:2458)
at oracle.odi.runtime.agent.execution.cmd.ScriptingExecutor.execute(ScriptingExecutor.java:48)
at oracle.odi.runtime.agent.execution.cmd.ScriptingExecutor.execute(ScriptingExecutor.java:1)
at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:50)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2906)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2609)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:540)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:453)
at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:1740)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:338)
at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:214)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:272)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:263)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:822)
at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:123)
at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:83)
at java.lang.Thread.run(Thread.java:662)
Please suggest.
Maybe you are looking for
-
Error while installing Oracle Apps server 10.1.3 with Oracle DB 11.2.0.2 residing in the same server and being used by Apps server as it's metadata. bash-3.00$ export ORACLE_HOME=/data/ora11g/app/ora11g/product/11.2.0 bash-3.00$ cd /data/OAS/install/
-
hi i want to run report based on Duplicate Payment . which table contains this information? this report should return different and/ or the same vendors with the same invoice numbers, and/or identical payment amounts with different invoices and th
-
Hy Sometimes when working on an imovie projtect, I press space bar to watch it and it comes only the sound, but the image stays as a still frame of the image that is on the screen at that moment. It doesnt show as usually the movie. Thanks for any he
-
Observer Pattern applied in Abap
Observer Pattern Observer pattern is a well known pattern especially with Java, here i continue my work in patterns. This is my humble understanding of a way how we can apply observer pattern The main components of this pattern is: Observer pattern:
-
Skip count does not increase when song is skipped on ipod
First, has anyone been able to see a skip added after syncing, since 4.2 came out? Second, is anyone familiar with what might have changed? Is there a fix I can't find? Thanks in advance