Question

I have csv file that contains shown below :

year,mon,day
2014,12,01
2013,10,30

and abc's table

create table abc (
year varchar2(4),
mon varchar2(2),
day varchar2(2),
date1 date
)

how to tell loader.ctl to merger year,mon,day become date?

like that ?

OPTIONS (SKIP=11, errors=12000) 
LOAD DATA  
APPEND INTO TABLE abc (
year "trim (:year)",
mon "trim (:mon)",
day "trim (:day)",
date1 "to_date (year||mon||day,'yyyymmdd')"
)
Was it helpful?

Solution

  1. Since your fields are comma separated, you should include fields terminated by "," in your control file.
  2. date1 is not present in the data file, but is computed. So use EXPRESSION parameter to specify that.
  3. in to_date function, use colons to reference the previous fields.

So, your control file should look like this,

OPTIONS (SKIP=11, errors=12000) 
LOAD DATA  
APPEND INTO TABLE abc
fields terminated by ","
(
year "trim (:year)",
mon "trim (:mon)",
day "trim (:day)",
date1 EXPRESSION "to_date (:year||:mon||:day,'yyyymmdd')"
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top