我要投稿

关于bigeagle的树状结构存储过程的一点看法

时间:2010-08-13 09:34 作者:cccbbs 阅读:1245

扫描二维码关注公众号,可以查询淘宝、京东商品优惠券

            
                                  

[/td]
            
大鹰,关于你在精华区的树状结构存储过程的贴子的内容好像不对呀,我做了实验,只能取根帖,我改了一下,在query analyzer中可以,但在页面上只能显示出一部分,你帮忙看一下好吗?????????????

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



????

????????????????/*求符合条件记录数*/

????????????????select "RecordCount" = count(*)?????????????????????????

???????????????????????from BBS where Layer=1 and ForumID = @a_ForumID



???????????????/*输出纪录*/

???????????????/*首先定义可滚动光标*/

???????????????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 into @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) ,

????????????????????????????????????'TotalChilds' = (select sum(TotalChilds)

????????????????????????????????????????????????????????from BBS as b

????????????????????????????????????????????????????????where a.RootID = b.RootID) ,

????????????????????????????????'LastReplyTime' = a.PostTime

?????????????????????????????????????

????????????????????????????????from BBS as a

?????????????????????????????????????join BBSUser as d on a.UserID = d.[ID]

????????????????????????????????where a.Layer>=1 and a.ForumID = @a_ForumID and a.rootID=@m_intRootID

????????????????????????????????order by RootID desc , Layer , PostTime desc

????????fetch next from m_curTemp into @m_intRootID

????????end

???????????????set rowcount 0

???????????????/*清场*/???????

???????????????CLOSE m_curTemp

???????????????DEALLOCATE m_curTemp

GO

最新评论

我要投稿 我要评论
插入url链接 添加表情
限 100000 字节
响应相关主管单位规定,关闭回帖发帖功能
[VB毕业设计] [ASP毕业设计] [JAVA毕业设计] [JSP毕业设计] [PHP毕业设计] [asp.net毕业设计] [.net毕业设计] [网络毕业设计] [Delphi毕业设计] [VC毕业设计] [VF毕业设计] [机械毕业设计] [工艺毕业设计] [模具毕业设计] [其他毕业设计]
站长联系 cccbbsnet#163.com 本站系公益性质网站,站内广告维系本站运作。欢迎赞助本站。
大学生计算机相关方向|软件编程|网络工程|web开发|数据库技术|学习资料等
本社区仅供学习计算机相关技术所使用,访客发言不得违反国家法律法规
Time now is:07-21 18:04, Gzip enabled 蜀ICP备07004838号Powered by cccbbs.net v7.5 SP3 Code © 2003-06 cccbbs
计算机毕业设计