Data structure and stored procedure of BBS (II.)

Source: Internet
Author: User
Tags define local variables
Stored Procedures | data | structure/*************************************************************************/
/* */
* Procedure:up_getforumlist * *
/* */
/* Description: Get the layout list * *
/* */
* Parameters:none * *
/* */
* * Use Table:forum, Bbsuser * *
/* */
* Author:bigeagle@163.net * *
/* */
* DATE:2000/2/10 * *
/* */
/* History: * *
/* */
/*************************************************************************/
if exists (select * from sysobjects where id = object_id (' up_getforumlist '))
drop proc Up_getforumlist
Go

Create proc Up_getforumlist
As
Select a.ID, A.rootid, A.fatherid, A.layer, A.title, A.topiccount, A.description,
' UserID ' =b.id, B.username, B.email, B.homepage, b.signature
From forum as a join Bbsuser as B in a.masterid=b.id order by Rootid, layer
Go
Select ID, title, Rootid from forum
Up_getforumlist


/*************************************************************************/
/* */
* Procedure:up_insertforum * *
/* */
/* Description: New layout * *
/* */
/* Parameters: @a_strName: page Name * *
/* @a_strDescription: Layout Description * *
/* @a_intFatherID: Category ID, if 0 description is a large classification * *
/* */
* * Use Table:forum * *
/* */
* Author:bigeagle@163.net * *
/* */
* DATE:2000/4/23 * *
/* */
/* History: * *
/* */
/*************************************************************************/
if exists (select * from sysobjects where id = object_id (' Up_insertforum '))
drop proc Up_insertforum
Go

create proc up_insertforum @a_strName varchar (m), @a_strDescription varchar (255), @a_intFatherID tinyint
As
/* Define Local Variables * *
DECLARE @intLayer tinyint
DECLARE @intRootID tinyint

/* If it is a layout and does not specify a category, then return -1*/
if (@a_intFatherID <> 0 and NOT EXISTS (SELECT * FROM forum where id = @a_intFatherID))
Return (-1)

/* Calculates layer according to @a_intfatherid, rootid*/
if (@a_intFatherID = 0)
Begin
Select @intLayer = 0
Select @intRootID = 0
End
Else
Begin
Select @intLayer = 1
Select @intRootID = @a_intFatherID
End

Insert into Forum (Rootid, layer, Fatherid, title, description)
VALUES (@intRootID, @intLayer, @a_intFatherID, @a_strName, @a_strDescription)
if (@a_intFatherID = 0)
Begin
Select @intRootID = @ @identity
Update Forum Set Rootid = @intRootID where id = @intRootID
End
Go

/*************************************************************************/
/* */
* Procedure:up_deleteforum * *
/* */
/* Description: Delete layout * *
/* */
/* Parameters: @a_intForumID: Layout ID * *
/* */
* * Use Table:forum * *
/* */
* Author:bigeagle@163.net * *
/* */
* DATE:2000/4/23 * *
/* */
/* History: * *
/* */
/*************************************************************************/
if exists (select * from sysobjects where id = object_id (' Up_deleteforum '))
drop proc Up_deleteforum
Go

create proc up_deleteforum @a_intForumID tinyint
As
Delete from Forum where id = @a_intForumID
Delete from Forum where Rootid = @a_intForumID
Go

Select ID, title, Rootid, Fatherid from forum

/*************************************************************************/
/* */
* Procedure:up_posttopic * *
/* */
/* Description: Post Zi * *
/* */
/* Parameters: @a_intForumID: Layout ID * *
/* @a_intFatherID: Parent Sticker ID, if the new theme is 0 * *
/* @a_strSubject: Title * *
/* @a_strContent: Content * *
/* @a_intUserID: Sender ID * *
/* @a_intFaceID: Expression ID * *
/* @a_strIP: Sender IP * *
/* */
/* Use Table:bbs, forum, Bbsuser * *
/* */
* Author:bigeagle@163.net * *
/* */
* DATE:2000/2/13 * *
/* */
/* History: * *
/* */
/*************************************************************************/
if exists (select * from sysobjects where id = object_id (' up_posttopic '))
drop proc Up_posttopic
Go

Create proc Up_posttopic
@a_intForumID int,
@a_intFatherID int,
@a_strSubject varchar (255),
@a_strContent text,
@a_intUserID int,
@a_intFaceID int,
@a_strIP varchar (255)
As
/* Define Local Variables * *
DECLARE @intRootID INT--Root ID
Declare @dblOrderNum float (53)--Sort cardinality
DECLARE @intLayer INT--Layer
Declare @dblNextOrderNum float (53)--Ordernum of the next reply

/* Judge If there is no this page * *
If not EXISTS (SELECT * FROM forum where id = @a_in

Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

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.