Setting the Date Format in the SQL*Loader Control File

Angelina picture Angelina · May 16, 2013 · Viewed 63.3k times · Source

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?

Answer

Ed Gibbs picture Ed Gibbs · May 16, 2013

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',
)