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
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