日本国产亚洲-日本国产一区-日本国产一区二区三区-日本韩国欧美一区-日本韩国欧美在线-日本韩国欧美在线观看

當前位置:雨林木風下載站 > 技術開發教程 > 詳細頁面

存儲過程分頁

存儲過程分頁

更新時間:2022-05-08 文章作者:未知 信息來源:網絡 閱讀次數:

if exists(select * from sysobjects where ID = object_id("up_TopicList"))
   drop proc up_TopicList
go

create proc up_TopicList
            @a_ForumID int , @a_intDays int , @a_intPageNo int , @a_intPageSize tinyint
   as
       declare @m_intRecordNumber int
       declare @m_intStartRecord  int
       select @m_intRecordNumber = @a_intPageSize * @a_intPageNo
       select @m_intStartRecord = @a_intPageSize * (@a_intPageNo - 1) + 1

       if @a_intDays = 0                      --如果不限定天數
          begin
                /*求符合條件記錄數*/
                select "RecordCount" = count(*)                         
                       from BBS where Layer=1 and ForumID = @a_ForumID

               /*輸出紀錄*/
               /*首先定義可滾動光標*/
               set rowcount @m_intRecordNumber
               declare m_curTemp Scroll cursor
                       for
                          select a.ID ,a.Title , d.UserName , a.FaceID ,
                                'ContentSize' = datalength(a.Content) ,
                                'TotalChilds' = (select sum(TotalChilds)
                                                        from BBS as b
                                                        where a.RootID = b.RootID) ,
                                'LastReplyTime' = (select max(PostTime)
                                                          from BBS as c
                                                          where a.RootID = c.RootID)
                                from BBS as a
                                     join BBSUser as d on a.UserID = d.ID
                                where Layer=1 and ForumID = @a_ForumID
                                order by RootID desc , Layer , PostTime
               open m_curTemp
               fetch absolute @m_intStartRecord from m_curTemp
               while  @@fetch_status = 0
                      fetch next from m_curTemp

               set rowcount 0
               /*清場*/       
               CLOSE m_curTemp
               DEALLOCATE m_curTemp
          end                      
                          
       else                                --如果限定天數          

          begin
                /*求符合條件記錄數*/
                select "RecordCount" = count(*)                         
                       from BBS where Layer=1 and ForumID = @a_ForumID
                                      and dateadd(day , @a_intDays , PostTime) > getdate()

               /*輸出紀錄*/
               /*首先定義可滾動光標*/
               set rowcount @m_intRecordNumber
               declare m_curTemp Scroll cursor
                       for
                          select a.ID ,a.Title , d.UserName , a.FaceID ,
                                'ContentSize' = datalength(a.Content) ,
                                'TotalChilds' = (select sum(TotalChilds)
                                                        from BBS as b
                                                        where a.RootID = b.RootID) ,
                                'LastReplyTime' = (select max(PostTime)
                                                          from BBS as c
                                                          where a.RootID = c.RootID)
                                from BBS as a
                                     join BBSUser as d on a.UserID = d.ID
                                where Layer=1 and ForumID = @a_ForumID
                                      and dateadd(day , @a_intDays , PostTime) > getdate()
                                order by RootID desc , Layer , PostTime
               open m_curTemp
               fetch absolute @m_intStartRecord from m_curTemp
               while  @@fetch_status = 0
                      fetch next from m_curTemp

               set rowcount 0
               /*清場*/       
               CLOSE m_curTemp
               DEALLOCATE m_curTemp
          end                                                
go


注:若在asp中調用存儲過程的command對象為cm,則set rs=cm.execute,然后用set rs=rs.nextrecordset取下一條記錄。

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

主站蜘蛛池模板: 国产精品岛国久久久久 | 性做久久久久久久久25的美女 | 色青青草原桃花久久综合 | 欧美性猛交xxxx乱大交蜜桃 | 欧美一区二区三区国产精品 | 2021久久精品国产99国产精品 | www.狠狠撸.com| 欧美一区日韩一区中文字幕页 | www久久爱| 国产成人久久精品一区二区三区 | 牛牛在线精品观看免费正 | 亚洲高清在线观看看片 | 国产视频日韩 | 天天尻逼 | 日本一级毛片视频在线看 | 性盈盈影院免费视频观看在线一区 | 一级女性全黄生活片免费 | 亚洲视屏在线观看 | 欧美成人午夜免费完成 | 亚洲精品 欧美 | 久久免费视频网 | 日本在线视频免费观看 | 国产欧美综合精品一区二区 | 午夜视频网| 国产黑丝在线 | 国产91区 | 亚洲在线视频观看 | 国产成人久久综合热 | 久久久久免费观看 | 五月天丁香婷婷综合久久 | 99中文在线| 午夜剧场在线免费观看 | 91激情在线 | 中国泡妞ssswww免费 | 亚洲日本高清影院毛片 | 精彩视频一区二区三区 | 国产又黄又爽又色视频影视网免费 | 国产亚洲精品视频中文字幕 | 国产精品久久久久久久成人午夜 | 极品专区高清在线 | 97超级碰碰碰视频在线视频观看 |