select a.*,nvl(b.report_value,0) report_value from ss_report_item_t a ,(
select REPORT_ITEM,sum(REPORT_VALUE) report_value from ss_month_report_t
where to_char(REPORT_DATE,'yyyy-mm') = to_char(to_date(#beginDate#,'yyyy-mm'),'yyyy-mm')

group by  REPORT_ITEM
)  b
where a.report_item = b.report_item(+)
and REPORT_TYPE = 2 and if_valid in (1,2)
出错:date format picture ends before converting entire input string   其中REPORT_DATE是Oracle的date字段 beginDate是abitas中的传来的字符串!

解决方案 »

  1.   

    to_char(REPORT_DATE,'yyyy-mm') = to_char(to_date(#beginDate#,'yyyy-mm'),'yyyy-mm')
    为什么不使用
    REPORT_DATE>=to_date(#beginDate#,'yyyy-mm') 
    and REPORT_DATE<= last_day(to_date(#beginDate#,'yyyy-mm') );
      

  2.   

    很明显是date 的问题,不是 REPORT_DATE 就是 beginDate。
    楼主已经知道问题在哪了,还想问什么呢?
      

  3.   

    beginDate 传过来的参数可能不是按照 'YYYY-MM' 这样的格式,导致 to_date 报错
    楼主修改一下 where 条件where to_char(REPORT_DATE,'yyyy-mm') = #beginDate#这样,就算传过来的字符串不符合日期格式,最多也就是查不出数据,不会报错
      

  4.   

    where to_char(REPORT_DATE,'yyyy-mm') = #beginDate#
      

  5.   

    查看一下REPORT_DATE,#beginDate#这两个字段的数据是否齐整,是否存在空值之类的值
      

  6.   

    to_char(REPORT_DATE,'yyyy-mm') = to_char(to_date(#beginDate#,'yyyy-mm'),'yyyy-mm')可以简化些吧。除非是用了 to_char(REPORT_DATE,'yyyy-mm')做索引。不然完全可以用2楼的写法。