【发布时间】:2016-04-24 06:05:46
【问题描述】:
我正在尝试更新输入日期为字符串类型的表
SELECT FromDate FROM MyTbl where NUM=3;
*output:*
FromDate
-------------------------
24-APR-16
UPDATE MyTbl SET FLAG='Y' WHERE FromDate=to_date(2016-04-24 00:00:00.0)
String FromDate= 2016-04-24 00:00:00.0
SQL Error: ORA-01861: literal does not match format string
01861. 00000 - "literal does not match format string"
*Cause: Literals in the input must be the same length as literals in
the format string (with the exception of leading whitespace). If the
"FX" modifier has been toggled on, the literal must match exactly,
with no extra whitespace.
*Action: Correct the format string to match the literal.
【问题讨论】:
-
看起来您正在使用 Java,但发布您正在使用的代码会有所帮助。您发布的
update语句缺少字符串值周围的引号。我不确定这是因为您在 Java 中动态组装 SQL 语句而忽略了添加单引号,还是因为您在 Java 中使用了绑定变量,而您只是在转录语句的样子时出错文字。此外,您的to_date调用需要格式掩码,除非字符串恰好与您会话的nls_date_format匹配。