项目从oracle迁移到sqlserver后,代码中分页的相对改动
<select id="getLogList" resultparameterprepend = "and" > to_char(a.OPERTOR_TIME,'yyyy-MM-dd hh24:mi:ss') >=#dateStart# and to_char(a.OPERTOR_TIME,'yyyy-MM-dd hh24:mi:ss') <=#dateEnd# </isNotEmpty> <isNotEmpty property = "logOpertor" prepend = "and" > a.LOG_OPERTOR =#logOpertor# </isNotEmpty> order by OPERTOR_TIME desc) c) where r >= #startRow# AND rownum <= #pageSize#
?以上是oracle的下,根据rownum来分页的,startRow和pageSize分别是实体类中对应的字段,开始行和页大小。
迁移到sqlserver之后,因为startRow和pageSize已经定了,所以修改的话,也得基于这两个字段。修改代码如下:
<select id="getLogList" resultparameterprepend = "and" > CONVERT(varchar(100), a.OPERTOR_TIME, 23) >=#dateStart# and CONVERT(varchar(100), a.OPERTOR_TIME, 23) <=#dateEnd# </isNotEmpty> <isNotEmpty property = "logOpertor" prepend = "and" > a.LOG_OPERTOR =#logOpertor# </isNotEmpty> and LOG_ID>=( select max(LOG_ID) from ( select top $startRow$ LOG_ID from MONITOR_LOG order by LOG_ID ) as t) order by LOG_ID </select>
?