Oracle - literal does not match format string error [duplicate]

那年仲夏 提交于 2019-12-18 05:55:06

问题


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.


回答1:


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




回答2:


Try this SQL:

INSERT INTO CatalogueEntry 
              VALUES(to_date('2001-12-10','yyyy-mm-dd'), 2, 14.99, 1, 0);


来源:https://stackoverflow.com/questions/13518506/oracle-literal-does-not-match-format-string-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!