Gets the per-page result stored procedure for pagination
CREATE PROCEDURE [DBO]. [mst_sp_pageshowex4] --input parameters @qCols varchar (8000), -- @qTables varchar (8000), -- @ Qwhere varchar (8000), -- @oKey varchar (, ) -- @pageSize int, -- @ pagenumber int --, 0as--does not generate set nocount on begin--declaration variables that affect the number of rows D eclare @sqlstr as varchar (max) DECLARE @sqlTable AS varchar (8000) set @sqltable = ' Select row_number () over (order by ' + @ okey + ' ) as rowid, ' + @qCols + ' FROM ' [email protected] + ' where + @qWhere ;set @sqlstr = ' select * from ( ' [email protected]+ ' ) as d where rowid between ' + str (@pageNumber * @pagesize +1) + ' AND ' + Str ((@pageNumber +1) * @pagesize) ;exec (@sqlstr); END
Get the total number of paging records stored procedures
Create PROCEDURE [dbo]. [Sp_pagecount] @qfromTables varchar (8000),--from which tables @qwhere varchar (8000) as BEGIN DECLARE @sqlstr as varchar (8000) Set @sqlstr = ' SELECT COUNT (*) from ' + @qfromTables + ' where ' [email protected];p rint @sqlstr; exec (@sqlstr) ; END
SQL mapping File Article.xml configuration
<?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.dt D "><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 $ ' & Lt;/select></sqlmap>
This article is from the "bit accumulation" blog, please be sure to keep this source http://tianxingzhe.blog.51cto.com/3390077/1720357
Ibatis calling SQL Server stored procedures