Ibatis calling SQL Server stored procedures

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.