注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Oracle、MySQL资料及经验

.

 
 
 

日志

 
 

ORA-00932和ORA-01840  

2014-12-22 14:13:36|  分类: ORA等错误处理 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

SQL> select OBJECT_NAME ,to_char(CREATED,'yyyy-mm-dd hh24:mi:ss') from t where created > &date1;                  
输入 date1 的值:  2011-09-17

原值    1: select OBJECT_NAME ,to_char(CREATED,'yyyy-mm-dd hh24:mi:ss') from t where created > &date1
新值    1: select OBJECT_NAME ,to_char(CREATED,'yyyy-mm-dd hh24:mi:ss') from t where created > 2011-09-17

select OBJECT_NAME ,to_char(CREATED,'yyyy-mm-dd hh24:mi:ss') from t where created > 2011-09-17
                                                                                  *
第 1 行出现错误:
ORA-00932: 数据类型不一致: 应为 DATE, 但却获得 NUMBER


SQL> select OBJECT_NAME ,to_char(CREATED,'yyyy-mm-dd hh24:mi:ss') from t where created > to_date(&date1,'yyyy-mm-dd'); 
输入 date1 的值:  2011-09-17

原值    1: select OBJECT_NAME ,to_char(CREATED,'yyyy-mm-dd hh24:mi:ss') from t where created > to_date(&date1,'yyyy-mm-dd')
新值    1: select OBJECT_NAME ,to_char(CREATED,'yyyy-mm-dd hh24:mi:ss') from t where created > to_date(2011-09-17,'yyyy-mm-dd')

select OBJECT_NAME ,to_char(CREATED,'yyyy-mm-dd hh24:mi:ss') from t where created > to_date(2011-09-17,'yyyy-mm-dd')
                                                                                                   *
第 1 行出现错误:
ORA-01840: 输入值对于日期格式不够长

 

SQL> select OBJECT_NAME ,to_char(CREATED,'yyyy-mm-dd hh24:mi:ss') from t where created > to_date('&date1','yyyy-mm-dd');
输入 date1 的值:  2011-09-17
原值    1: select OBJECT_NAME ,to_char(CREATED,'yyyy-mm-dd hh24:mi:ss') from t where created > to_date('&date1','yyyy-mm-dd')
新值    1: select OBJECT_NAME ,to_char(CREATED,'yyyy-mm-dd hh24:mi:ss') from t where created > to_date('2011-09-17','yyyy-mm-dd')

OBJECT_NAME                    TO_CHAR(CREATED,'YY
------------------------------ -------------------
BONUS                          2011-09-17 10:21:59
SALGRADE                       2011-09-17 10:21:59
T_ZWZ                          2014-12-03 09:28:05
P_TEST                         2014-12-05 16:42:38
DEPT                           2014-10-24 17:57:06
EMP                            2014-10-24 17:57:06
T1                             2014-10-24 17:57:06
T2                             2014-10-24 17:57:06
PK_DEPT                        2014-10-24 17:57:07
PK_EMP                         2014-10-24 17:57:07
IDX_T1                         2014-10-24 17:57:07

OBJECT_NAME                    TO_CHAR(CREATED,'YY
------------------------------ -------------------
IDX_T2                         2014-10-24 17:57:07
PKG_EXP_PART                   2014-11-26 16:41:49
PKG_EXP_PART                   2014-11-26 16:41:51
EMP_PACKAGE                    2014-11-26 16:31:03
EMP_PACKAGE                    2014-11-26 16:31:18
F_EXP_PART                     2014-11-26 16:41:10
P_DEL_PART                     2014-11-26 17:48:40
T                              2014-12-22 11:31:26
V_T                            2014-10-08 15:18:42
V_T1                           2014-10-08 15:19:14
V_T2                           2014-10-08 15:20:25


sqlplus 对于调错有时还是很有好处的。

  评论这张
 
阅读(328)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018