luna.t
luna.t

Reputation: 39

ORA-01861: literal does not match format string : SQL

INSERT INTO RENT_CONTRACT VALUES ('123456789','201213','20123444',100,1,' 2014-01-07 ');

I'm trying to insert this tuple in my rent_contract table , but this error:

ORA-01861: literal does not match format string )

is showing up. Although the type of the last value is DATE. Any suggestions for a solution?

Thank you in advance :)

Upvotes: 0

Views: 1848

Answers (2)

ms32035
ms32035

Reputation: 159

It depends on your session NLS settings. What you are looking for is

INSERT INTO RENT_CONTRACT VALUES  ('123456789','201213','20123444',100,1,to_date('2014-01-07','yyyy-mm-dd'));

Upvotes: 1

Gordon Linoff
Gordon Linoff

Reputation: 1269783

Oracle (by default) uses the format DD-MMM-YYYY. So try this:

INSERT INTO RENT_CONTRACT
    VALUES ('123456789', '201213', '20123444', 100,1 , '07-JAN-2014');

Also, don't put spaces in string constants.

Or, use the DATE keyword:

INSERT INTO RENT_CONTRACT
    VALUES ('123456789', '201213', '20123444', 100,1 , DATE '2014-01-07');

Upvotes: 1

Related Questions