The service side of the page on a SQL statement can be done, paste the code after you slowly appreciate:
CREATE Procedure Appgetemplist @EID int, @LGID int, @pagesize int, @pageindex int As Begin Select COUNT (*) Count from Appemployee Select a.id,a.eid,case when @LGID =2052 then Name Else ename End name,deptitle,jobtitle , case when B.xeid was null then 0 Else 1 End Fav , Case if Isnull (a.reportto,0) [email protected] then 1 Else 0 End issub From (select Row_number () over (order by left (a.ename,1)) ID, a.* From Appemployee A Where [email protected] and Isnull (a.status,0) <>4) a Left Join Appempfavorites B on A.eid=b.eid and [email protected] where a.id between (@pageindex-1) * @pagesize +1 and @pageindex * @pagesize End |
Analysis 1:
Select Row_number () over (order by left (a.ename,1)) ID, a.* From Appemployee A Where [email protected] and Isnull (a.status,0) <>4) |
This section of the statement is the main Table Appemployee assignment of an ID, convenient for paging processing, but also by the name of the English name to sort!
Analysis 2:
Select a.id,a.eid,case when @LGID =2052 then Name Else ename End name,deptitle,jobtitle , case when B.xeid was null then 0 Else 1 End Fav , Case if Isnull (a.reportto,0) [email protected] then 1 Else 0 End issub From (select Row_number () over (order by left (a.ename,1)) ID, a.* From Appemployee A Where [email protected] and Isnull (a.status,0) <>4) a Left Join Appempfavorites B on A.eid=b.eid and [email protected] |
This statement is based on statement 1 through the Eid filter out the values we do not need
Analysis 3:
where a.id between (@pageindex-1) * @pagesize +1 and @pageindex * @pagesize |
The statement is evaluated by passing parameters and the specified value is fetched back to the client.
In summary, the service side only need to use this idea can realize the paging query function, however, the Android client in the ListView using Paging Request method (client paging follow-up discussion), can be connected to the server.
This article is from the "Suck on self-renewal" blog, please be sure to keep this source http://wyong.blog.51cto.com/1115465/1618762
Implementation of service-side paging in project combat--sql