pb11.5或pb12.5中sql语句的奇怪问题?
lqhly 2014-11-04 03:16:03 我的系统:xp-sp3、sqlserver2008、pb11.5 或pb12.5,通过odbc连接数据库。
我在做一个单据的自动增加时遇到了一个郁闷、奇怪的现象,不知道是什么原因,请求各位大侠救助。
order_no 单据号格式为年+月+日+2位流水号,比如14年11月04日 + 01即:14110401
我把'14110401%'存到一个字符串变量order_no_t中
保存成功后,在添加第二张单据时,单据号不能自动增加。经过调试跟踪发现是:
select max(order_no) into :order_no_max from t_order where order_no like :order_no_t;
这个语句执行后order_no_max = null而不是想要的'14110401’
而我直接用'14110401%'代替变量order_no_t 时结果却是正确的'14110401‘即
select max(order_no) into :order_no_max from t_order where order_no like ‘14110411%’
我还以为是pb115的版本出来问题,然后我升级到pb12,5问题还是一样的。请问高手们到底是什么原因造成的这样奇怪的结果?