External Tables (Oracle Loader)
Hi While creating the external Table, i am getting error.
ORA-12899: value too large for column PRC_REC_TYPE (actual: 2, maximum: 1)
But while checking the CSV file, i found that prc_rec_type is having one 1 length value.
-- Create table
create table ET_PGIT_POL_RISK_COVER
prc_pol_no VARCHAR2(60),
prc_end_no_idx VARCHAR2(22),
prc_sec_code VARCHAR2(12),
prc_risk_id VARCHAR2(12),
prc_smi_code VARCHAR2(12),
prc_code VARCHAR2(12),
prc_desc VARCHAR2(2000),
prc_rate VARCHAR2(22),
prc_rate_per VARCHAR2(22),
prc_cvr_type VARCHAR2(1),
prc_add_si_yn VARCHAR2(1),
prc_si_curr_code VARCHAR2(12),
prc_prem_curr_code VARCHAR2(12),
prc_si_fc VARCHAR2(22),
prc_si_lc_1 VARCHAR2(22),
prc_si_lc_2 VARCHAR2(22),
prc_si_lc_3 VARCHAR2(22),
prc_prem_fc VARCHAR2(22),
prc_prem_lc_1 VARCHAR2(22),
prc_prem_lc_2 VARCHAR2(22),
prc_prem_lc_3 VARCHAR2(22),
prc_eff_fm_dt VARCHAR2(30),
prc_eff_to_dt VARCHAR2(30),
prc_brok_comm_appl_yn VARCHAR2(1),
prc_no_clm_bonus_appl_yn VARCHAR2(1),
prc_prof_comm_appl_yn VARCHAR2(1),
prc_cr_uid VARCHAR2(12),
prc_rate_eft VARCHAR2(12),
prc_terrorism_yn VARCHAR2(1),
prc_lvl VARCHAR2(12),
prc_tot_si_fc VARCHAR2(22),
prc_first_loss_perc VARCHAR2(22),
prc_flxi_risk_cover_desc VARCHAR2(2000),
prc_rec_type VARCHAR2(1)
organization external
type ORACLE_LOADER
default directory MMI_DATA_MIG
access parameters
RECORDS DELIMITED BY NEWLINE BADFILE 'ET_PGIT_POL_RISK_COVER.Bad' LOGFILE 'ET_PGIT_POL_RISK_COVER.Log' FIELDS TERMINATED BY ',' MISSING FIELD VALUES ARE NULL REJECT ROWS WITH ALL NULL FIELDS
location (MMI_DATA_MIG:'COVER_1.csv')
reject limit UNLIMITED;
Not able to upload the file here.
CHANDAN,0,1001,1,,1004,TPPropertyDamage,2.00000,100.00000,C,0,001,001,10000.000,10000.000,10000.000,10000.000,200.000,200.000,200.000,200.000,14-Feb-13 11:10:39,13-Feb-14 23:59:00,1,0,0,MMI,,0,F,0.000,,,N
CHANDAN,0,1001,1,,1005,RoadSideAssistance,1.50000,100.00000,C,0,001,001,15000.000,15000.000,15000.000,15000.000,225.000,225.000,225.000,225.000,14-Feb-13 11:10:39,13-Feb-14 23:59:00,1,0,0,MMI,,0,F,0.000,,,N
There are Actually three rows in csv.Above 2 rows are not inserted into et table whereas last row is getting inserted into et table(Below one)
CHANDAN,0,1001,1,,1099,SASRIA,0.25000,1.00000,C,0,001,001,12500.000,12500.000,12500.000,12500.000,0.250,0.250,0.250,0.250,14-Feb-13 11:10:39,13-Feb-14 23:59:00,0,0,0,MMI,,0,F,0.000,,,N
Similar Messages
-
Hi,
I am trying to insert a csv file as a single record as a CLOB (one row for entire csv file) and trying to do that via external table. But unalbe to do so. Following is the syntax I tried with:
create table testext_tab2
( file_data clob
organization external
TYPE ORACLE_LOADER
DEFAULT DIRECTORY dir_n1
access parameters
RECORDS DELIMITED BY NEWLINE
BADFILE DIR_N1:'lob_tab_%a_%p.bad'
LOGFILE DIR_N1:'lob_tab_%a_%p.log'
FIELDS TERMINATED BY ','
MISSING FIELD VALUES ARE NULL
clob_filename CHAR(100)
COLUMN TRANSFORMS (file_data FROM LOBFILE (clob_filename) FROM (DIR_N1) CLOB)
LOCATION ('emp.txt')
REJECT LIMIT UNLIMITED
--it gives the output that the table is created but the table does not have any rows (select count(*) from testext_tab2 gives 0 rows)
-- and the logfile has entries like follows:
Fields in Data Source:
CLOB_FILENAME CHAR (100)
Terminated by ","
Trim whitespace same as SQL Loader
Column Transformations
FILE_DATA
is set from a LOBFILE
directory is from constant DIR_N1
directory object list is ignored
file is from field CLOB_FILENAME
file contains character data
in character set WE8ISO8859P1
KUP-04001: error opening file /oracle/dba/dir_n1/7369
KUP-04017: OS message: No such file or directory
KUP-04065: error processing LOBFILE for field FILE_DATA
KUP-04101: record 1 rejected in file /oracle/dba/dir_n1/emp.txt
KUP-04001: error opening file /oracle/dba/dir_n1/7499
KUP-04017: OS message: No such file or directory
KUP-04065: error processing LOBFILE for field FILE_DATA
KUP-04101: record 2 rejected in file /oracle/dba/dir_n1/emp.txt
KUP-04001: error opening file /oracle/dba/dir_n1/7521
KUP-04017: OS message: No such file or directory
KUP-04065: error processing LOBFILE for field FILE_DATA
KUP-04101: record 3 rejected in file /oracle/dba/dir_n1/emp.txt
and also the file to be loaded (emp.txt) has data like this:
7369,SMITH,CLERK,7902,12/17/1980,800,null,20
7499,ALLEN,SALESMAN,7698,2/20/1981,1600,300,30
7521,WARD,SALESMAN,7698,2/22/1981,1250,500,30
7566,JONES,MANAGER,7839,4/2/1981,2975,null,20
7654,MARTIN,SALESMAN,7698,9/28/1981,1250,1400,30
7698,BLAKE,MANAGER,7839,5/1/1981,2850,null,30
7782,CLARK,MANAGER,7839,6/9/1981,2450,null,10
7788,SCOTT,ANALYST,7566,12/9/1982,3000,null,20
7839,KING,PRESIDENT,null,11/17/1981,5000,null,10
7844,TURNER,SALESMAN,7698,9/8/1981,1500,0,30
7876,ADAMS,CLERK,7788,1/12/1983,1100,null,20
7900,JAMES,CLERK,7698,12/3/1981,950,null,30
7902,FORD,ANALYST,7566,12/3/1981,3000,null,20
7934,MILLER,CLERK,7782,1/23/1982,1300,null,10I will be thankful for help on this. Also I read on asktom site (http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1669379500346411993)
that LOB are not supported for external tables but there are other sites with examples of CLOB being loaded by external tables.
With regards,
OrausernCMcM wrote:
Hi all
We have an application that runs fine on 10.2.0.4 on most platforms, but a customer has reported an error when running 10.2.0.3 on HP. We have since reproduced the error on 10.2.0.3 on XP but have failed to reproduce it on Solaris or Linux.
The exact error is within a set of procedures, but the simplest reproducible form of the error is pasted in below.Except that you haven't pasted output to show us what the actual error is. Are we supposed to guess?
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> ed
Wrote file afiedt.buf
1 declare
2 vstrg clob:= 'A';
3 Thisstrg varchar2(32000);
4 begin
5 for i in 1..31999 loop
6 vstrg := vstrg||'A';
7 end loop;
8 ThisStrg := vStrg;
9* end;
SQL> /
PL/SQL procedure successfully completed.
SQL>Works ok for me on 10.2.0.1 (Windows 2003 server) -
Problem in external table & sql*loader
hi all
i want to transter data between flat file to oracle database through external table option and sql*loader Utility.
1. how u make .dat file in external table.
2. how u make .ctl file in sql*loader utility.
if u know any good site plz. tell me.
thanx
Mohammadi52Hi,
Use this link to search any Oracle documentation:
http://tahiti.oracle.com/
Also please have a look on the below link:
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14220/utility.htm
Regards -
SQL*Loader or external table for load a MSG (email) file
Hi there!
I'm looking for a way to load an email in a Oracle DB.
I mean, not all the email's body in a column, but to "parse" it in a multi column/table fashion.
Is it possible to do with a sql*loader script or an external table?
I think it is not possible, and that I must switch to XML DB.
Any idea?
Thanks,
AntonioHello,
Why don't you just load the entire MSG (email) as clob into one email_body column or whatever column name you want to use.
To load data upto 32k, you can use varchar2(32656) but its not a good idea to load clob in that manner because it's very inconsistent as length can
vary resulting in string literal too long. So you have 2 choices now, first you have to use either procedure or anonymous block to load clob data.
First Method -- I loaded alert.log successfully and you can imagine how big this file can be (5MB in my test case)
CREATE OR REPLACE DIRECTORY DIR AS '/mydirectory/logs';
DECLARE
clob_data CLOB;
clob_file BFILE;
BEGIN
INSERT INTO t1clob
VALUES (EMPTY_CLOB ())
RETURNING clob_text INTO clob_data;
clob_file := BFILENAME ('DIR', 'wwalert_dss.log');
DBMS_LOB.fileopen (clob_file);
DBMS_LOB.loadfromfile (clob_data,
clob_file,
DBMS_LOB.getlength (clob_file)
DBMS_LOB.fileclose (clob_file);
COMMIT;
END;Second Method: Use of Sqlldr
Example of controlfile
LOAD DATA
INFILE alert.log "STR '|\n'"
REPLACE INTO table t1clob
clob_text char(30000000)
)Hope this helps -
Use of External tables to load XML data.
Hi,
I have used external table definitions to load various XML files to the database, usually splitting the XML into seperate records - 1 per major element tag, and using PL/SQL to parse out a primary key to store in a relational table with all of the XML relevant to that primary key value stored as an XMLTYPE coumn in a row of the table. This has worked fine for XML with a single major entity (element tag) .
However, I now have an XML file that contains two "major" elements (both children of the root) that I would like to split out and store in seperate tables.
The XML file is of the following basic format:-
<drugs>
<drug>drug 1...</drug>
<drug>drug 2...</drug>
<partners>
<partner>partner 1</partner>
<partner>partner 2</partner>
</partners>
</drugs>
The problem is there are around 18000 elements of the first type, followed by several thousand of the 2nd type. I can create two seperate external tables - one for each element type, but how do I get the external table for the 2nd to ignore all the elements of the first type? My external table definition is :-
CREATE TABLE DRUGBANK_OWNER.DRUGBANK_PARTNERS_XML_EXTERNAL
DRUGBANK_XML CLOB
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY DRUGBANK_DIR
ACCESS PARAMETERS
( records delimited by "</partner>" SKIP 100000
characterset al32utf8
badfile extlogs:'drugbank_partners_xml.bad'
logfile extlogs:'drugbank_partners_xml.log'
discardfile extlogs:'drugbank_partners_xml.dis'
READSIZE 52428800
fields
drugbank_xml CHAR(50000000) terminated by '</partners>'
LOCATION (DRUGBANK_DIR:'drugbank.xml')
REJECT LIMIT UNLIMITED
PARALLEL ( DEGREE 8 INSTANCES 1 )
NOMONITORING;
The problem is that before the first <partners> element the 1800 or so <drugs> elements cause a data cartrdige error:-
ORA-29913: error in executing ODCIEXTTABLEFETCH callout
ORA-29400: data cartridge error
KUP-04020: found record longer than buffer size supported, 52428800
This happens regardless of the value of the SKIP or the size of the drugbank_xml field.
I have tried using an OR on the "records delimited by" access parameter, to 'delimit by "</partner>" OR "</drug>"', with the intention of filtering out the <drug> elements but this leads to a syntax error.
Anyone ever tried anything similar and got it to work?
Any other suggestions?
Thanks,
Sid.No, the content inside quotes is spanned across multiple lines....there are line breaks after every html tag.
"What's the error message you are getting?"
Iam not getting any error while selecting from external table , but I am getting tose rows in BAD file and log file has the following entries
KUP-04021: field formatting error for field TKBS_DSCN
KUP-04036: second enclosing delimiter not found
Message was edited by:
user627610 -
External table & SQL*loader
Hi everybody!
following is the script for control file and i want to create a similar script in External table ...
LOAD DATA
INFILE ''
INTO TABLE PAY_STG_OWN.STG_INTRA_ACTG_ENT
APPEND
FIELDS TERMINATED BY '~'
TRAILING NULLCOLS
ACTV_HIST_IND CHAR(1) "TRIM(:ACTV_HIST_IND)"
,AUTH_STATUS CHAR(1) "TRIM(:AUTH_STATUS)"
,SUBSYS_PROD_COD CHAR(10) "TRIM(:SUBSYS_PROD_COD)"
,TRAN_AMT INTEGER EXTERNAL(22) "DECODE(TRIM(:TRAN_AMT),NULL,NULL,Fn_Deci_Ccy(:BR_COD,TO_NUMBER(fn_neg_pos(NVL(TRIM(:TRAN_AMT),'0'))),TRIM(:TRAN_CCY_COD),'SWIFT'))"
,LEGVEH CHAR(4) "TRIM(:LEGVEH)"
the last but one column calls the DECODE function followed by a user defined function Fn_Deci_Ccy() .
My question is ..
is it possible to call a user defined function while creating a external table.
An early reply is highly appreciable.
Thanks in advance
regards
MoloyYou cannot put a function directly in the statement that creates the external table. However, you can use the function in a statement that selects from the external table.
-
External table.How to load numbers (decimal and scientific notation format)
Hi all, I need to load inside an external table records that contain 7 fields. The last field is called AMOUNT and it's represented in some records with the decimal format, in others records with the scientific notation format as, for example, below:
CY001_STATU;2009;Jan;11220020GR;'03900;CYZ900;-9,99999999839929e-03
CY001_STATU;2009;Jan;11200100;'60800;CYZ900;41380,77
The External table's script is the following:
CREATE TABLE HYP_DATA
COUNTRY VARCHAR2(50 BYTE),
YEAR VARCHAR2(20 BYTE),
PERIOD VARCHAR2(20 BYTE),
ACCOUNT VARCHAR2(50 BYTE),
DEPT VARCHAR2(20 BYTE),
ACTIVITY_LOC VARCHAR2(20 BYTE),
AMOUNT VARCHAR2(50 BYTE)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY HYP_DATA_DIR
ACCESS PARAMETERS
( RECORDS DELIMITED BY NEWLINE
BADFILE 'HYP_BAD_DIR':'HYP_LOAD.bad'
DISCARDFILE 'HYP_DISCARD_DIR':'HYP_LOAD.dsc'
LOGFILE 'HYP_LOG_DIR':'HYP_LOAD.log'
SKIP 0
FIELDS TERMINATED BY ";"
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS
"COUNTRY" Char,
"YEAR" Char,
"PERIOD" Char,
"ACCOUNT" Char,
"DEPT" Char,
"ACTIVITY_LOC" Char,
"AMOUNT" Char
LOCATION (HYP_DATA_DIR:'Total.txt')
REJECT LIMIT UNLIMITED
NOPARALLEL
NOMONITORING;
If, for the field AMOUNT I use the datatype VARCHAR (as above), the table is loaded but I have some records rejected, and all these records contain the last field AMOUNT with the scientific notation as:
CY001_STATU;2009;Jan;11220020GR;'03900;CYZ900;-9,99999999839929e-03
CY001_STATU;2009;Feb;11220020GR;'03900;CYZ900;-9,99999999839929e-03
CY001_STATU;2009;Mar;11220020GR;'03900;CYZ900;-9,99999999839929e-03
CY001_STATU;2009;Dec;11220020GR;'03900;CYZ900;-9,99999999839929e-03
All the others records with a decimal AMOUNT are loaded correctly.
So, my problem is that I NEED to load all the records (with the decimal and the scientific notation format) together (without records rejected), but I don't know which datatype I have to use for the AMOUNT field....
Anybody has any idea ???
Any help would be appreciated
Thanks in advance
Alex@OP,
What version of Oracle are you using?
Just cut'n'paste of you script and example woked FINE for me.
however my quation is... An external table will LOAD all data or none at all. How are you validating/concluding that...
I have some records rejected, and all these records contain the last field AMOUNT with the scientific notation
select * from v$version where rownum <2;
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
select * from mydata;
CY001_STATU 2009 Jan 11220020GR '03900 CYZ900 -9,99999999839929e-03
CY001_STATU 2009 Feb 11220020GR '03900 CYZ900 -9,99999999839929e-03
CY001_STATU 2009 Jan 11220020GR '03900 CYZ900 -9,99999999839929e-03
CY001_STATU 2009 Jan 11200100 '60800 CYZ900 41380,77
CY001_STATU 2009 Mar 11220020GR '03900 CYZ900 -9,99999999839929e-03
CY001_STATU 2009 Dec 11220020GR '03900 CYZ900 -9,99999999839929e-03
CY001_STATU 2009 Jan 11220020GR '03900 CYZ900 -9,99999999839929e-03
CY001_STATU 2009 Jan 11200100 '60800 CYZ900 41380,77MYDATA table script is...
drop table mydata;
CREATE TABLE mydata
COUNTRY VARCHAR2(50 BYTE),
YEAR VARCHAR2(20 BYTE),
PERIOD VARCHAR2(20 BYTE),
ACCOUNT VARCHAR2(50 BYTE),
DEPT VARCHAR2(20 BYTE),
ACTIVITY_LOC VARCHAR2(20 BYTE),
AMOUNT VARCHAR2(50 BYTE)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY IN_DIR
ACCESS PARAMETERS
( RECORDS DELIMITED BY NEWLINE
BADFILE 'IN_DIR':'HYP_LOAD.bad'
DISCARDFILE 'IN_DIR':'HYP_LOAD.dsc'
LOGFILE 'IN_DIR':'HYP_LOAD.log'
SKIP 0
FIELDS TERMINATED BY ";"
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS
"COUNTRY" Char,
"YEAR" Char,
"PERIOD" Char,
"ACCOUNT" Char,
"DEPT" Char,
"ACTIVITY_LOC" Char,
"AMOUNT" Char
LOCATION (IN_DIR:'total.txt')
REJECT LIMIT UNLIMITED
NOPARALLEL
NOMONITORING;vr,
Sudhakar B. -
Hi,
I am working in Oracle 8i. I need to use Oracle 8i External Table to load data in the database. But I am getting the following error
ORA-00922: Missing or Invalid Option
The snippet which I used is as follows:
create table ext_table_csv (
a NUMBER,
n NUMBER,
m NUMBER
organization external
type oracle_loader
default directory swami
access parameters (
records delimited by newline
fields terminated by ';'
missing field values are null
location ('sample.txt')
PARALLEL
reject limit 0
The input file data is
018307;20080421;123457
018307;20080421;123457
Please let me know how this can be done in Oracle 8i and I have to use Oracle Loader only.Its a new feature introduced in Oracle 9i.
http://download.oracle.com/docs/cd/A91202_01/901_doc/server.901/a90120/ch2_feat.htm#58871
For 8i, SQL*Loader is the only option. -
Oracle 11g - External Table/SQL Developer Issue?
Oracle 11g - External Table/SQL Developer Issue?
==============================
I hope this is the right forum for this issue, if not let me, where to go.
We are using Oracle 11g (11.2.0.1.0) on (Platform : solaris[tm] oe (64-bit)), Sql Developer 3.0.04
We are trying to use oracle external table to load text files in .csv format. Here is our data look like.
======================
Date1,date2,Political party,Name, ROLE
20-Jan-66,22-Nov-69,Democratic,"John ", MMM
22-Nov-70,20-Jan-71,Democratic,"John Jr.",MMM
20-Jan-68,9-Aug-70,Republican,"Rick Ford Sr.", MMM
9-Aug-72,20-Jan-75,Republican,Henry,MMM
------ ALL NULL -- record
20-Jan-80,20-Jan-89,Democratic,"Donald Smith",MMM
======================
Our Expernal table structures is as follows
CREATE TABLE P_LOAD
DATE1 VARCHAR2(10),
DATE2 VARCHAR2(10),
POL_PRTY VARCHAR2(30),
P_NAME VARCHAR2(30),
P_ROLE VARCHAR2(5)
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY P_EXT_TAB_D
ACCESS PARAMETERS (
RECORDS DELIMITED by NEWLINE
SKIP 1
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LDRTRIM
REJECT ROWS WITH ALL NULL FIELDS
MISSING FIELD VALUES ARE NULL
DATE1 CHAR (10) Terminated by "," ,
DATE2 CHAR (10) Terminated by "," ,
POL_PRTY CHAR (30) Terminated by "," ,
P_NAME CHAR (30) Terminated by "," OPTIONALLY ENCLOSED BY '"' ,
P_ROLE CHAR (5) Terminated by ","
LOCATION ('Input.dat')
REJECT LIMIT UNLIMITED;
It created successfully using SQL Developer
Here is the issue.
It is not loading the records, where fields are enclosed in '"' (Rec # 2,3,4,7)
It is loading all NULL value record (Rec # 6)
*** If we remove the '"' from input data, it loads all records including all NULL records
Log file has
KUP-04021: field formatting error for field P_NAME
KUP-04036: second enclosing delimiter not found
KUP-04101: record 2 rejected in file ....
Our questions
Why did "REJECT ROWS WITH ALL NULL FIELDS" not working?
Why did Terminated by "," OPTIONALLY ENCLOSED BY '"' not working?
Any idea?
Thanks in helping.I don't think this is a SQLDeveloper issue. You will get better answers in the Database - General or perhaps SQL and PL/SQL forums.
-
Oracle 11g - External Table/Remote File Issue?
Oracle 11g - External Table/Remote File Issue?
=============================
I hope this is the right forum for this issue, if not let me, where to go.
We are using Oracle 11g (11.2.0.1.0) on (Platform : solaris[tm] oe (64-bit)), Sql Developer 3.0.04
We are not allowed to put files on the CSV file system (Server A), where DB instance is running. We are able place CSV files on another server(Server B), where DB instance is not running.
We are trying to use oracle external table to load text files in .CSV format.
How do we create a Directory (Create Directory) on Server A DB to point to File system of Server B?
Is it feasible?
Any idea?
Thanks in helping.The Solaris DBA should be able to mount the filesystem for you. Either that or you have to get creative transferring the file like this;
http://www.linkedin.com/groups/Getting-creative-external-table-preprocessor-140609.S.50474382?qid=ba673ce4-c4bb-40c5-8367-52bd2a2dfc80&trk=group_search_item_list-0-b-ttl&goback=%2Egmp_140609
Cheers
David -
Oracle 11g - External Table Issue SQL - PL/SQL?
Oracle 11g - External Table Issue?
=====================
I hope this is the right forum for this issue, if not let me, where to go.
We are using Oracle 11g (11.2.0.1.0) on (Platform : solaris[tm] oe (64-bit)), Sql Developer 3.0.04
We are trying to use oracle external table to load text files in .csv format. Here is our data look like.
======================
Date1,date2,Political party,Name, ROLE
20-Jan-66,22-Nov-69,Democratic,"John ", MMM
22-Nov-70,20-Jan-71,Democratic,"John Jr.",MMM
20-Jan-68,9-Aug-70,Republican,"Rick Ford Sr.", MMM
9-Aug-72,20-Jan-75,Republican,Henry,MMM
ALL NULL -- record
20-Jan-80,20-Jan-89,Democratic,"Donald Smith",MMM
======================
Our Expernal table structures is as follows
CREATE TABLE P_LOAD
DATE1 VARCHAR2(10),
DATE2 VARCHAR2(10),
POL_PRTY VARCHAR2(30),
P_NAME VARCHAR2(30),
P_ROLE VARCHAR2(5)
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY P_EXT_TAB_D
ACCESS PARAMETERS (
RECORDS DELIMITED by NEWLINE
SKIP 1
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LDRTRIM
REJECT ROWS WITH ALL NULL FIELDS
MISSING FIELD VALUES ARE NULL
DATE1 CHAR (10) Terminated by "," ,
DATE2 CHAR (10) Terminated by "," ,
POL_PRTY CHAR (30) Terminated by "," ,
P_NAME CHAR (30) Terminated by "," OPTIONALLY ENCLOSED BY '"' ,
P_ROLE CHAR (5) Terminated by ","
LOCATION ('Input.dat')
REJECT LIMIT UNLIMITED;
It created successfully using SQL Developer
Here is the issue.
It is not loading the records, where fields are enclosed in '"' (Rec # 2,3,4,7)
It is loading all NULL value record (Rec # 6)
*** If we remove the '"' from input data, it loads all records including all NULL records
Log file has
KUP-04021: field formatting error for field P_NAME
KUP-04036: second enclosing delimiter not found
KUP-04101: record 2 rejected in file ....
Our questions
Why did "REJECT ROWS WITH ALL NULL FIELDS" not working?
Why did Terminated by "," OPTIONALLY ENCLOSED BY '"' not working?
Any idea?
Thanks in helping.
Edited by: qwe16235 on Jun 11, 2011 11:31 AMI'm not sure, but maybe you should get rid of the redundancy that you have in your CREATE TABLE statement.
This line covers all fields:
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
{code}
So I would change the field list to:
{code}
DATE1 CHAR (10),
DATE2 CHAR (10),
POL_PRTY CHAR (30),
P_NAME CHAR (30),
P_ROLE CHAR (5)
{code}
It worked on my installation. -
Oracle 11g - External Table Issue?
Oracle 11g - External Table Issue?
=====================
I hope this is the right forum for this issue, if not let me, where to go.
We are using Oracle 11g (11.2.0.1.0) on (Platform : solaris[tm] oe (64-bit)), Sql Developer 3.0.04
We are trying to use oracle external table to load text files in .csv format. Here is our data look like.
======================
Date1,date2,Political party,Name, ROLE
20-Jan-66,22-Nov-69,Democratic,"John ", MMM
22-Nov-70,20-Jan-71,Democratic,"John Jr.",MMM
20-Jan-68,9-Aug-70,Republican,"Rick Ford Sr.", MMM
9-Aug-72,20-Jan-75,Republican,Henry,MMM
------ ALL NULL -- record
20-Jan-80,20-Jan-89,Democratic,"Donald Smith",MMM
======================
Our Expernal table structures is as follows
CREATE TABLE P_LOAD
DATE1 VARCHAR2(10),
DATE2 VARCHAR2(10),
POL_PRTY VARCHAR2(30),
P_NAME VARCHAR2(30),
P_ROLE VARCHAR2(5)
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY P_EXT_TAB_D
ACCESS PARAMETERS (
RECORDS DELIMITED by NEWLINE
SKIP 1
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LDRTRIM
REJECT ROWS WITH ALL NULL FIELDS
MISSING FIELD VALUES ARE NULL
DATE1 CHAR (10) Terminated by "," ,
DATE2 CHAR (10) Terminated by "," ,
POL_PRTY CHAR (30) Terminated by "," ,
P_NAME CHAR (30) Terminated by "," OPTIONALLY ENCLOSED BY '"' ,
P_ROLE CHAR (5) Terminated by ","
LOCATION ('Input.dat')
REJECT LIMIT UNLIMITED;
It created successfully using SQL Developer
Here is the issue.
It is not loading the records, where fields are enclosed in '"' (Rec # 2,3,4,7)
It is loading all NULL value record (Rec # 6)
*** If we remove the '"' from input data, it loads all records including all NULL records
Log file has
KUP-04021: field formatting error for field P_NAME
KUP-04036: second enclosing delimiter not found
KUP-04101: record 2 rejected in file ....
Our questions
Why did "REJECT ROWS WITH ALL NULL FIELDS" not working?
Why did Terminated by "," OPTIONALLY ENCLOSED BY '"' not working?
Any idea?
Thanks in helping.
Edited by: qwe16235 on Jun 10, 2011 2:16 PMThe following worked for me:
drop table p_load;
CREATE TABLE P_LOAD
DATE1 VARCHAR2(10),
DATE2 VARCHAR2(10),
POL_PRTY VARCHAR2(30),
P_NAME VARCHAR2(30),
P_ROLE VARCHAR2(5)
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY scott_def_dir1
ACCESS PARAMETERS (
RECORDS DELIMITED by NEWLINE
badfile scott_def_dir2:'p_load_%a_%p.bad'
logfile scott_def_dir2:'p_load_%a_%p.log'
SKIP 1
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LDRTRIM
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS
DATE1 CHAR (10) Terminated by "," ,
DATE2 CHAR (10) Terminated by "," ,
POL_PRTY CHAR (30) Terminated by "," ,
P_NAME CHAR (30) Terminated by "," OPTIONALLY ENCLOSED BY '"' ,
P_ROLE CHAR (5) Terminated by ","
LOCATION ('Input.dat')
REJECT LIMIT UNLIMITED;
Note that I had to interchange the two lines:
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS
Just to get the access parameters to parse correctly.
I added two empty lines, one in the middle and one at the end - both were rejected.
In the log file, you will see the rejectiions:
$ cat p_load_000_9219.log
LOG file opened at 07/08/11 19:47:23
Field Definitions for table P_LOAD
Record format DELIMITED BY NEWLINE
Data in file has same endianness as the platform
Reject rows with all null fields
Fields in Data Source:
DATE1 CHAR (10)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
DATE2 CHAR (10)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
POL_PRTY CHAR (30)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
P_NAME CHAR (30)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
P_ROLE CHAR (5)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL Loader
KUP-04073: record ignored because all referenced fields are null for a record
KUP-04073: record ignored because all referenced fields are null for a record
Input Data:
Date1,date2,Political party,Name, ROLE
20-Jan-66,22-Nov-69,Democratic,"John ", MMM
22-Nov-70,20-Jan-71,Democratic,"John Jr.",MMM
20-Jan-68,9-Aug-70,Republican,"Rick Ford Sr.", MMM
9-Aug-72,20-Jan-75,Republican,Henry,MMM
4-Aug-70,20-Jan-75,Independent
Result:
SQL> select * from p_load;
DATE1 DATE2 POL_PRTY P_NAME P_ROL
20-Jan-66 22-Nov-69 Democratic John MMM
22-Nov-70 20-Jan-71 Democratic John Jr. MMM
20-Jan-68 9-Aug-70 Republican Rick Ford Sr. MMM
9-Aug-72 20-Jan-75 Republican Henry MMM
Regards,
- Allen -
File loaded successfully by SQLldr but external table failed
Hi ,
When i tried to create an external table to load data from file it failed with the below error
"KUP-04018: partial record at end of file",
When i query on the external table for rows with rownum<2500 i can see the records being properly loaded but when i tried to fetch all records it throws the above error.
But the same file when i loaded with sqlldr it loaded all the records successfully.
Can you please let me know the reason for this?
RegardsCan you post us your SQLLDR control file, your external table definition, a sample of your data (preferably including the last lines of data which you believe are erroring) and also let us know your database version.
-
Hi ,
How to load data from external table to transaction table using SQLLDR ?You use an external table to load the data it is described in the link to the manual I provided.
Here is an example.
Re: Using DML order to import a .xls file
You would not be using SQLLDR though as external tables replace that functionality. -
I have an external table in Oracle 10.2.0.3. Can I update, insert or delete records through sqlplus?
Thanks a lot!That documentation is actually slightly misleading on that point...
Prior to 10g, the statement "External tables are read only; therefore, no DML operations are possible" was unambiguously true.
Starting in 10g, however, Oracle introduced ORACLE_DATAPUMP external tables (which are different than ORACLE_LOADER external tables that load human readable flat files). You are allowed to insert data into an ORACLE_DATAPUMP external table as the documentation goes on to discuss "Oracle also provides the ORACLE_DATAPUMP type, which lets you unload data (that is, read data from a table in the database and insert it into an external table) and then reload it into an Oracle database."
Justin
Maybe you are looking for
-
I pod not recognized by Windows XP
I have an IPOD Touch 2nd generation. I'm trying to connect it via USB to a WinXP box. The USB port is enhanced, is operation, but does not detect the IPOD. Any suggestions?
-
Photoshop CC 2014 skew layer action issue
Hello, I have a set of actions from previous version of PSD (CS6 > CC) which includes skewing a layer and placing it in an exact position. Worked like a charm. Now, I have upgraded to CC 2014 and these actions are useless... E.g. - what one action di
-
Is it really necessary to upgrade to maverick on a new macbook pro that has mountain lion?
Is it necessary to upgrade to Maverick on a brand new mac book pro? This download is taking FOREVER..I have never had any problems with any of my other computers taking so long to download anything. Can I cancel the download once it has started and
-
Hi everyone! For BDC programming, I use this statement (example only): CALL TRANSACTION 'F-02' USING bdc_tab MODE 'N' UPDATE 'S'. Is it possible to call the program ID and screen no. instead of th
-
Intune Company Portal iOS app - Connection Issue: Unexpected connection issue occured
Greetings, I am in the process of enrolling an iOS device and I have installed the Intune Company Portal App. When I attempt to sign in, it starts to redirect me "We are taking you to your company sin-in page" then the app says "Connection Issue, an