Reputation: 2652
I am getting Oracle 'ORA-01861: literal does not match format string' while loading date strings of simple (YYYY-MM-DD) format into Oracle 11g:
My table DDL is:
CREATE TABLE fp_basic_dividends (
fs_perm_sec_id VARCHAR(20) NOT NULL,
"DATE" DATE NOT NULL,
currency CHAR(3) NOT NULL,
adjdate DATE NOT NULL,
p_divs_pd FLOAT(53) NOT NULL,
p_divs_paydatec DATE NULL,
p_divs_recdatec DATE NULL,
p_divs_s_spinoff CHAR(1) NOT NULL,
p_divs_s_pd FLOAT(53) NULL,
PRIMARY KEY (fs_perm_sec_id, "DATE"));
My sqlldr ctl file is:
load data
append
into table fp_basic_dividends
fields terminated by "|" optionally enclosed by '"'
TRAILING NULLCOLS
(
FS_PERM_SEC_ID CHAR(20),
"DATE" DATE "YYYY-MM-DD",
CURRENCY CHAR(3),
ADJDATE DATE "YYYY-MM-DD",
P_DIVS_PD FLOAT,
P_DIVS_PAYDATEC DATE "YYYY-MM-DD",
P_DIVS_RECDATEC DATE "YYYY-MM-DD",
P_DIVS_S_SPINOFF,
P_DIVS_S_PD FLOAT
)
Example data is:
"XXXXRR-S-US"|1997-09-30|"UAH"|1997-09-30|.0126400003|1997-10-01|1997-09-29|"0"|
Result log file content is:
Table FP_BASIC_DIVIDENDS, loaded from every logical record.
Insert option in effect for this table: APPEND
TRAILING NULLCOLS option in effect
Column Name Position Len Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
FS_PERM_SEC_ID FIRST 20 | O(") CHARACTER
"DATE" NEXT * | O(") DATE YYYY-MM-DD
CURRENCY NEXT 3 | O(") CHARACTER
ADJDATE NEXT * | O(") DATE YYYY-MM-DD
P_DIVS_PD NEXT 4 FLOAT
P_DIVS_PAYDATEC NEXT * | O(") DATE YYYY-MM-DD
P_DIVS_RECDATEC NEXT * | O(") DATE YYYY-MM-DD
P_DIVS_S_SPINOFF NEXT * | O(") CHARACTER
P_DIVS_S_PD NEXT 4 FLOAT
Record 1: Rejected - Error on table FP_BASIC_DIVIDENDS, column P_DIVS_PAYDATEC.
ORA-01861: literal does not match format string
What am I doing wrong? Any help is greatly appreciated
Upvotes: 2
Views: 6984
Reputation: 108370
I think the problem is with PD_DIVS_PD FLOAT,
.
Looks like what you have in the datafile is really character data (VARCHAR), and not a fixed length binary representation.
To get SQL*Loader to convert from character representation, I think the datatype has to be qualified as EXTERNAL
, e.g.:
PD_DIVS_PD FLOAT EXTERNAL,
Here's what I think is happening... I think SQL*Loader is picking up exactly four bytes for the PD_DIVS_PD FLOAT
field,
'.012'
He's not seeing that as character, he's not seeing that as a value 1.2E-02
. He's viewing those four bytes as an internal binary representation of a FLOAT (bit for sign, certain number of bits for exponent, certain number of bits as mantissa).
Then, for the next field, he's starting at the next position, and picking up the '6400003'
(up to the next field delimiter), and then trying to convert that to a DATE.
Upvotes: 4