ASP about paging methods

Source: Internet
Author: User
Paging time relationship, without a complete test, this is the approximate meaning.
CREATE PROCEDURE Getnotes

@forumID varchar (10),
@a_intPageNo int,
@a_intPageSize int,
@rootID varchar (10)
As
DECLARE @m_intRecordNumber int
DECLARE @m_intStartRecord int
DECLARE @pagecount int
DECLARE @temp int
DECLARE @end int
DECLARE @sql varchar (500)
DECLARE @bbsname varchar (25)
DECLARE @articles int
DECLARE @manager varchar (30)
DECLARE @selectrootID varchar (500)
DECLARE @temprootID varchar (10)

Select @m_intRecordNumber = @a_intPageSize * @a_intPageNo
Select @m_intStartRecord = @a_intPageSize * (@a_intPageNo-1) + 1

SET NOCOUNT ON
Select @bbsname =subjectname, @manager =manager, @articles =articles from bbs_subjects where subjectid= @forumID
If @rootID = ' 0 '
Begin
--Select @sql = ' Declare m_curtemp Scroll cursor for select Id,title,shrink,rootid,orderid,pubtime,hits,bytes,username, Email from bbs_forum_ ' + @forumID + ' WHERE rootid in (select distinct Rootid to Bbs_forum_ ' + @forumID + ') Order by Rootid de Sc,orderid ASC '
Select @sql = ' Declare m_curtemp Scroll cursor for select Rootid to Bbs_forum_ ' + @forumID + ' where Rootid=parentid order by Rootid Desc '
End
Else
Select @sql = ' Declare m_curtemp Scroll cursor for select Id,title,shrink,rootid,orderid,pubtime,hits,bytes,username, Email from bbs_forum_ ' + @forumID + ' where rootid= ' + @rootID + ' ORDER by OrderID ASC '

EXEC (@sql)
Open M_curtemp

Set @pagecount = case
When @ @cursor_rows% @a_intPageSize =0 then @ @cursor_rows/@a_intPageSize
When @ @cursor_rows% @a_intPageSize <>0 then @ @cursor_rows/@a_intPageSize +1
End
If @ @cursor_rows < @a_intPageSize and @ @cursor_rows >0
Begin
Select @pagecount =1
End


If @rootID = ' 0 '
Begin
Set @temp = 1
Set @selectrootID = ' 0 '
Fetch absolute @m_intStartRecord from m_curtemp to @temprootID
While @ @fetch_status = 0 and @temp < @a_intPageSize
Begin
Set @temp = @temp + 1
Select @selectrootID = @selectrootID + ', ' + @temprootID
FETCH NEXT from m_curtemp into @temprootID
End
Close M_curtemp
Deallocate m_curtemp
SET NOCOUNT OFF
Select ' PageCount ' = @pagecount
Select ' Bbsname ' = @bbsname
Select ' Manager ' = @manager
Select ' Articles ' = @articles
Select @sql = ' Declare curtemp Scroll cursor for select Id,title,shrink,rootid,orderid,images,pubtime,hits,bytes, Username,email from Bbs_forum_ ' + @forumID + ' where Rootid in (' + @selectrootID + ') Order by Rootid Desc,orderid ASC '
EXEC (@sql)
Open Curtemp
Fetch the Curtemp
While @ @fetch_status = 0
Begin
FETCH NEXT from Curtemp
End
Close Curtemp
Deallocate curtemp
End
Else
Begin
Set @temp = 1
SET NOCOUNT OFF
Fetch absolute @m_intStartRecord from m_curtemp
While @ @fetch_status = 0 and @temp < @a_intPageSize
Begin
Set @temp = @temp + 1
FETCH NEXT from M_curtemp
End
Close M_curtemp
Deallocate m_curtemp
End

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.