今天调试oracle写的SQL语句的时候,总是以为是参数转换出错了,然后一直纠结在参数格式不匹配这个地方,却没有考虑原来是其它地方报错。
出错SQL是这样的:
private string SQL_GET_ALLCARD = "select count(*) from card_memc where card_rcre_user_date between to_date(:beginDate,'yyyy-mm-dd hh24mi') and to_date(:endDate,'yyyy-mm-dd hh24mi')+1;";
正确的SQL语句是这样的:
private string SQL_GET_ALLCARD = "select count(*) from card_memc where card_rcre_user_date between to_date(:beginDate,'yyyy-mm-dd hh24mi') and to_date(:endDate,'yyyy-mm-dd hh24mi')+1";
我一直纠结着以为是beginDate、endDate传进来的是字符串,而在oracle中是这样格式的'2014-03-28 0600',多了个单引号。因为在oracle中,传入”2014-03-28 0600“是会报错的,所以我一直以为是错误出现在这里。其实真正的错误是在最后面那里多了个分号。傻眼了吧~