YAFLogo

rdoty
  • rdoty
  • 56% (Neutral)
  • YAF Forumling Topic Starter
14 years ago
I'm having trouble deleting forums. It just hangs and doesn't complete. I'm using YAF version 1.9.1.8. Any help would be appreciated. Here is the stored procedure I'm using:

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[yaf_forum_delete](
@ForumID INT)
AS
BEGIN
-- Maybe an idea to use cascading foreign keys instead? Too bad they don't work on MS SQL 7.0...
UPDATE yaf_Forum
SET LastMessageID = NULL,
LastTopicID = NULL
WHERE ForumID = @ForumID
UPDATE yaf_Topic
SET LastMessageID = NULL
WHERE ForumID = @ForumID
DELETE FROM yaf_WatchTopic
FROM yaf_Topic
WHERE yaf_Topic.ForumID = @ForumID
AND yaf_WatchTopic.TopicID = yaf_Topic.TopicID

DELETE FROM yaf_Active
FROM yaf_Topic
WHERE yaf_Topic.ForumID = @ForumID
AND yaf_Active.TopicID = yaf_Topic.TopicID

DELETE FROM yaf_NntpTopic
FROM yaf_NntpForum
WHERE yaf_NntpForum.ForumID = @ForumID
AND yaf_NntpTopic.NntpForumID = yaf_NntpForum.NntpForumID
DELETE FROM yaf_NntpForum
WHERE ForumID = @ForumID
DELETE FROM yaf_WatchForum
WHERE ForumID = @ForumID
-- BAI CHANGED 02.02.2004
-- Delete topics, messages and attachments
DECLARE @tmpTopicID INT;
DECLARE topic_cursor CURSOR FOR
SELECT TopicID
FROM yaf_topic
WHERE ForumId = @ForumID
ORDER BY TopicID DESC
OPEN topic_cursor
FETCH NEXT FROM topic_cursor
INTO @tmpTopicID
-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC yaf_topic_delete
@tmpTopicID ,
1 ,
1;
-- This is executed as long as the previous fetch succeeds.
FETCH NEXT FROM topic_cursor
INTO @tmpTopicID
END
CLOSE topic_cursor
DEALLOCATE topic_cursor
-- TopicDelete finished
-- END BAI CHANGED 02.02.2004
DELETE FROM yaf_ForumAccess
WHERE ForumID = @ForumID
--ABOT CHANGED
--Delete UserForums Too
DELETE FROM yaf_UserForum
WHERE ForumID = @ForumID
--END ABOT CHANGED 09.04.2004
DELETE FROM yaf_Forum
WHERE ForumID = @ForumID
END


Thank you.

Rick
Sponsor

Mek
  • Mek
  • 100% (Exalted)
  • YAF Developer
14 years ago
Is it a particularly large forum your deleting? i.e. threads/posts.

UserPostedImage

"It's a case of RTFM.. the only problem being we don't have a manual!"

When I post FP:Mek in a topic, I'm leaving my footprint there so I can track it once I get into coding/supporting. (Yes I stole this off Ederon 🙂 )
rdoty
  • rdoty
  • 56% (Neutral)
  • YAF Forumling Topic Starter
14 years ago
This particular one has 135 topics and 4,395 messages.

Thanks.
YAF Logo Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button