Question

I have a question. I have this control files that works fine when I run it from a windows client. However when I run it directly in Linux, it shows load complete but when I look at my oracle data, there is NO DATA and there are even bad records. Below is my control file that works well in windows but fails in Linux. NOTE: The control file works if I remove the string or date converted fields

Control file

load data   
infile 'HOME/INPUT/FILEA.dat'  
badfile 'HOME/BAD/FILEA.bad'  
discardfile 'HOME/DIS/FILEA.dsc'  
truncate    
into table TEST  
fields terminated by '|'   
trailing nullcols  
( ABCcode  CHAR(11),    
ABCID  CHAR(6),    
ABC_SEQNO  "to_number(:ABC_SEQNO,'999999')",    
PSNO  "to_number(:PSNO,'99999999999.999')",    
ABDF  CHAR(1),    
ABCFI  CHAR(1),    
ABC_DATE NULLIF ABC_DATE="00000000" "to_date(:ABC_DATE, 'YYYYMMDD')",    
XZY_date NULLIF XZY_date="00000000" "to_date(:XZY_date, 'YYYYMMDD')",    
DESC  CHAR(1))   

Any help or ideas to get this code to run in Linux will be appreciated

Notes about the logfile: The logfile had the following
ORA-00604: error occurred at recursive SQL level 1
ORA-12899: value too large for column "ABCschema"."TEST"."ABC_DATE" (actual: 9, maximum: 8)
Also, the date conversion had the following
NULL if ABC_DATE = 0X3030303030303030(character '00000000') SQL string for column : "to_date(:ABC_DATE, 'YYYYMMDD')"

Was it helpful?

Solution

Your TEST table has the ABC_DATE column defined as VARCHAR2(8), not as a DATE.

If I create a table as:

create table test (
  ABCcode VARCHAR2(11),
  ABCID VARCHAR2(6),
  ABC_SEQNO NUMBER,
  PSNO NUMBER,
  ABDF VARCHAR2(1),
  ABCFI VARCHAR2(1),
  ABC_DATE DATE,
  XZY_date DATE,
  "DESC" VARCHAR2(1)
);

and have a data file with:

A|B|1|2.3|C|D|20140217|20140218|E

then it loads fine. If I recreate the table as:

create table test (
  ABCcode VARCHAR2(11),
  ABCID VARCHAR2(6),
  ABC_SEQNO NUMBER,
  PSNO NUMBER,
  ABDF VARCHAR2(1),
  ABCFI VARCHAR2(1),
  ABC_DATE VARCHAR2(8),
  XZY_date DATE,
  "DESC" VARCHAR2(1)
);

... then the same control file and data file now give me:

Record 1: Rejected - Error on table TEST, column ABC_DATE.
ORA-12899: value too large for column "<schema>"."TEST"."ABC_DATE" (actual: 9, maximum: 8)

You are converting the string value to a date, but then you're doing an implicit conversion back to a string when it actually inserts the data into the VARCHAR2 column. When it does that it's using your NLS_DATE_FORMAT settings, and the error I got was from having that set to DD-MON-RR.

You have three options really. Either modify your table to have actual DATE columns; or change the control file so it just inserts the plain text value and doesn't do the date conversion at all; or massage your environment so the conversion back to a string gets the format you want the string to be.

Only the first one is really sensible - if it's a date value, always store it as a DATE, never as a string.

The 0X30... thing isn't a problem, that's just showing the internal representation it's using.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top