A view on the tree-like structure stored procedure of Bigeagle

Source: Internet
Author: User
Stored procedure great eagle, about you in the essence of the tree structure stored procedures of the content of the posts seems wrong ah, I did the experiment, can only take root posts, I changed, in Query Analyzer can, but on the page only show a part, you help to look at it?
CREATE proc Up_topiclist
@a_ForumID int, @a_intPageNo int, @a_intPageSize tinyint
As
DECLARE @m_intRecordNumber int
DECLARE @m_intStartRecord int
DECLARE @m_intRootID int
Select @m_intRecordNumber = @a_intPageSize * @a_intPageNo
Select @m_intStartRecord = @a_intPageSize * (@a_intPageNo-1) + 1


* * To meet the conditions of the number of records * *
Select "RecordCount" = count (*)
From BBS where layer=1 and ForumID = @a_ForumID

/* Output Record * *
/* First define scrollable cursor * *
SET ROWCOUNT @m_intRecordNumber
DECLARE m_curtemp Scroll cursor
For
Select ' Rootid ' =a.rootid
From BBS as a
Join Bbsuser as D on a.userid = D.[id]
where a.layer=1 and A.forumid = @a_ForumID
ORDER BY Rootid Desc, Layer, posttime desc
Open M_curtemp
Fetch absolute @m_intStartRecord from m_curtemp to @m_intRootID

while (@ @fetch_status = 0)
Begin
Select ' ID ' = A.[id],
' Title ' = A.title,
' UserName ' = D.username,
' Hits ' = a.hits,
' Face ' = A.face,
' Layer ' =a.layer,
' Contentsize ' = datalength (a.content),



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.