ALL IN ONE:利用存储过程实现BBS树形结构的存储及有回复email通

80酷酷网    80kuku.com

  存储过程下面读取纪录的存储过程:



if exists(select * from sysobjects where ID = object_id("up_GetTopic"))

   drop proc up_GetTopic

go



create proc up_GetTopic a_intID int

   as

      declare m_intNextID int , m_intProvID int , m_intRootID int

      declare m_intLayer int , m_intForumID int

      select m_intRootID = RootID , m_intLayer = Layer , m_intForumID = ForumID

             From BBS where ID = a_intID   --求指定记录RootID



      if rowcount = 0        --如果没有选定纪录,则退出

         return 0

    

      select a.ID  , a.Layer , a.ForumID , b.UserName , b.Email , b.ICQ , b.HomePage  ,

             a.Title , a.Content , a.PostTime , a.FaceID , a.Hits

             from BBS as a

                  join BBSUser as b

                       on a.UserID = b.ID

             where RootID = m_intRootID and Layer >= m_intLayer

             order by RootID , OrderNum

     

     /*更新点击数*/

     update BBS Set Hits = Hits + 1 where ID = a_intID

go

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: