您好,登錄后才能下訂單哦!
獲取分頁的每頁結果存儲過程
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。