Possible Duplicate:
Simple Oracle query: literal does not match format string
I am getting the following error:
INSERT INTO CatalogueEntry VALUES('2001-12-10', 2, 14.99, 1, 0)
ERROR at line 1: ORA-01861: literal does not match format string `
The first field is a DATE
format.
Any ideas?
Thanks.
This error occurs when a literal is entered with a format string, but the length of such format string is not the same as the literal. This can sometimes occur in Tableau Desktop when using the DATE() function along with an Oracle database.
You should fix it as follows. SELECT TO_DATE('05/05/2021','dd/mm/yyyy') FROM dual; You need to provide the correct literal when you use TO_DATE function, TO_TIMESTAMP function, TO_CHAR function, and similar functions.
The ORA-01861 lists as resulting when “literal does not match format string”. If you're not privy to these terms then this can seem a bit unclear. However, once you're familiar with the two terms the rest falls right into place. A literal in Oracle is a fixed, specific data point.
To fix the error, specify a month value that is valid such as “January”. Some conversion is built-in, and a value of “Jan” is also valid for the Month format code.
When you are inserting a string value to a date column, then you need to convert it to a date during the INSERT
using the to_date()
function. When using this function you will provide the format of the string.
to_date()
function format:
to_date( string1, [ format_mask ], [ nls_language ] )
So your query will be like this:
insert into CatalogueEntry
values
(
to_date('2001-12-10', 'yyyy-mm-dd'),
2,
14.99,
1,
0);
See SQL Fiddle with demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With