Oracle - literal不匹配格式字符串错误 [英] Oracle - literal does not match format string error

查看:240
本文介绍了Oracle - literal不匹配格式字符串错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

简单Oracle查询:字面值与格式字符串不匹配



$ b b

我得到以下错误:

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 `

第一个栏位是 DATE 格式。

感谢。

推荐答案

值到日期列,那么您需要在 INSERT 期间使用 to_date() 函数。使用此函数时,您将提供字符串的格式。

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()函数格式:

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);

请参阅 SQL Fiddle with demo

这篇关于Oracle - literal不匹配格式字符串错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆