Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the Date Format in the SQL*Loader Control File

I have csv file that has "17 September, 2009 11:06:06 AM" as COMPLETED_ON variable

I am using sql loader to load data to oracle with folowing:

LOAD DATA
INFILE 'c:/load/file_name.csv'
APPEND
INTO TABLE tbl_name
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
(
COMPLETED_ON DATE "not sure what to put here",
) 

in oracle I have this column created as follows:

"COMPLETED_ON" TIMESTAMP (0) WITH LOCAL TIME ZONE

How do I change COMPLETED_ON date in control file?

like image 377
Angelina Avatar asked May 16 '13 19:05

Angelina


1 Answers

I'm not 100% with the LOAD DATA INFILE syntax, but I know the format string 'DD Month, YYYY HH:MI:SS AM' matches your date format. I was able to use it in a TO_DATE to convert your sample date. Try this:

LOAD DATA
INFILE 'c:/load/CW_COMPLIANCE.csv'
APPEND
INTO TABLE tbl_name
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
(
COMPLETED_ON DATE 'DD Month, YYYY HH:MI:SS AM',
)
like image 95
Ed Gibbs Avatar answered Dec 30 '22 14:12

Ed Gibbs