Skip to Main Content

Chinese

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-01830: date format picture ends before converting entire input string

sgdcNov 2 2012 — edited Nov 7 2012
DB version:10.2.0.2
OS version:AIX 5.3

抓到一个sql语句,如下
select distinct ci.info_id,
                ci.space_ename,
                ci.title,
                ci.publish_time_str,
                cci.category_id,
                cci.space_ename,
                ci.info_url,
                cc.full_ename
  from cms_info ci, cms_cate_info cci, cms_category cc
 where cci.category_id = cc.id
   and TO_DATE(ci.publish_time_str, 'yyyy-MM-dd hh24-mi-ss') >=
       TO_DATE(:1, 'yyyyMMdd')
   and TO_DATE(ci.publish_time_str, 'yyyy-MM-dd hh24-mi-ss') <
       TO_DATE(:2, 'yyyyMMdd')
   and ci.info_id = cci.info_id
   and ci.info_status = 9
   and cci.space_ename in
       (select ps.name from pbo_space ps where ps.full_ename like :3)
 order by ci.publish_time_str desc
我代入dbms_sqltune.extract_binds(bind_data)看到的绑定变量值,在pl/sql developer 中执行报错:ORA-01830: date format picture ends before converting entire input string

其中cms_info表中的publish_time_str字段,类型为varchar2(30),大部分值都是合适的,如:
2011-04-27 16:41:25
2011-04-06 18:34:27
2011-04-12 08:59:42
2011-04-28 06:19:29
2011-04-20 14:11:45
2011-04-06 22:14:33
2011-04-29 09:50:44
2011-04-27 11:02:26
2011-04-21 16:19:27

有少数值带有秒的精度:
2-11-30 00:00:00.0
2-11-30 00:00:00.0
1-08-16 10:32:00.0
2-11-30 00:00:00.0
1-03-17 09:20:00.0
9-01-12 12:12:47.0
9-01-12 12:12:47.0
9-01-12 12:12:47.0
9-01-12 12:12:47.0

我知道带有秒精度的字符串,使用to_date会引起ORA-01830,不过我很奇怪,用户为什么能执行那个sql的,难道需要做一些什么设置吗?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 5 2012
Added on Nov 2 2012
8 comments
895 views