您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
获取分页的每页结果存储过程
CREATE PROCEDURE [dbo].[mst_sp_pageshowex4] --输入参数 @qCols varchar(8000), -- @qTables varchar(8000), -- @qWhere varchar(8000), -- @oKey varchar(100), -- @pageSize int, -- @pageNumber int --, 0 AS --不生成影响行数 set nocount on BEGIN --声明变量 DECLARE @sqlstr AS varchar(max) DECLARE @sqlTable AS varchar(8000) set @sqltable = 'SELECT ROW_NUMBER() OVER(ORDER BY '+ @oKey + ' ) AS RowId,' + @qCols + ' FROM '+@qTables + ' where ' + @qWhere ; set @sqlstr = 'SELECT * FROM ( '+@sqlTable+' ) AS D WHERE RowId between ' + str(@pageNumber*@pagesize +1) + ' AND ' + str((@pageNumber +1)*@pagesize) ; exec (@sqlstr); END
获取分页总记录数目存储过程
create PROCEDURE [dbo].[sp_pagecount] @qfromTables varchar(8000), -- 来自哪几张表 @qwhere varchar(8000) AS BEGIN DECLARE @sqlstr AS varchar(8000) set @sqlstr='SELECT COUNT(*) FROM ' + @qfromTables +' where ' +@qwhere; print @sqlstr; exec (@sqlstr); END
sql映射文件Article.xml配置
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd"> <sqlMap namespace="Article"> <select id="queryForPaginate2" parameterClass="article" resultClass="article"> mst_sp_pageshowex4 '$columns$ ','$table$','$where$','$orderBy$',$pageSize$,$pageNo$ </select> <select id="count2" parameterClass="article" resultClass="integer"> sp_pagecount '$table$','$where$' </select> </sqlMap>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。