0
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 :)

luna.t
  • 39
  • 2
  • 12
  • 1
    I'd think about those extra spaces. – mustaccio Dec 14 '14 at 23:01
  • possible duplicate of [SQL Error: ORA-01861: literal does not match format string 01861](http://stackoverflow.com/questions/22542882/sql-error-ora-01861-literal-does-not-match-format-string-01861) – Phil Ross Aug 30 '15 at 11:32

2 Answers2

1

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');
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
1

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'));
ms32035
  • 159
  • 4