查询条件为日期时报’无效的列类型'错误方法解决

来源:互联网 发布:北川景子 知乎 编辑:程序博客网 时间:2024/05/21 08:54

查询条件使用到日期的时候报出


实体类里字段都是正确对应的

SQL语句形式类似为:

select tv.* from account_sel_view tv   where 1=1  <if test="regstartDate!=null and regstartDate!=''">and startDate >= to_date('#{regstartDate}','yyyy-mm-dd HH24:MI:SS') </if> <if test="regendDate!=null and regendDate!=''">and startDate <= to_date('#{regendDate}','yyyy-mm-dd HH24:MI:SS')  </if> <if test="allNumLow!=null and allNumLow!=''">and dealSum >= TO_NUMBER(#{allNumLow}) </if> <if test="allNumHigh!=null and allNumHigh!=''">and dealSum <= TO_NUMBER(#{allNumHigh})  </if>

以上问题是因为:



to_date的参数不可加上' '。

正确写法为:

<if test="regstartDate!=null and regstartDate!=''">and startDate >= to_date(#{regstartDate},'yyyy-mm-dd HH24:MI:SS')</if><if test="regendDate!=null and regendDate!=''">and startDate <= to_date(#{regendDate},'yyyy-mm-dd HH24:MI:SS') </if>


0 0
原创粉丝点击