Home
News
Articles
Forums
Links
Downloads
Login
Register
Hello: Anonymous

Statistics:
Registered users: 8
Moderators: 1
Administrators: 2
New users today: 0

Newest user:
ImaginaryDev

Totals:
Links: 5
News: 58
Maps: 0
Events: 0
Screen Shots: 0
Downloads: 2
Posts: 3
Comments: 142
Home > Articles
CSK-SQL Fix

Posted by on Sunday, March 13, 2005 (EST)

This is a fix for the moving of content pages from one section to another.

I discovered that when you move content to a different section the comment didnt follow. It turns out that the stored procedure Community_ContentPagesMoveContentPage has a slight flaw.

It sets the ContentPage_SectionID to the new section only for the parent page. This fix addresses this issue.

This simply alters the existing stored procedure.

--  Mike Munoz - 3/11/2005
--  This is a fix to address the issue of comments not moving
--  when you move contentpages to a new section
ALTER   PROCEDURE Community_ContentPagesMoveContentPage 
(
  @communityID int,
  @contentPageID int,
  @moderationStatus int,
  @sectionID int
)
AS
UPDATE Community_ContentPages SET
 ContentPage_SectionID = @sectionID,
 ContentPage_ModerationStatus = @moderationStatus
WHERE
 ContentPage_CommunityID = @communityID
-- Mike Munoz 3/11/2005 Fixes Comments not showing up when moved to a new section
 AND (ContentPage_ID = @contentPageID or contentPage_parentID = @contentPageID)

If you have used the move function previously then you have disassociated contentpages for the comments.The following is a simple script that updates the content pages to address that issue as well.

 

This script uses a temp table to hold the values that we need to update from and a transaction to make sure that all steps are successful before we make the changes final.

 


DECLARE @Succeed int
set xact_abort on
SET NOCOUNT ON
set @Succeed = 1
BEGIN TRANSACTION contentpagefix
SAVE TRAN contentpagefix
-- Create Temp table to hold the values we need to update the section ID's
CREATE TABLE [#ContentPageTemp] (
 [contentPage_id] [int] NOT NULL ,
 [contentPage_sectionID] [int] NULL
) ON [PRIMARY]
-- Check to see if any Errors were returned
IF @@error<>0 SELECT @Succeed=0
--Populate the Temp table with the Community_ContentPages Table contents
INSERT INTO #ContentPageTemp
SELECT 
 contentPage_id, 
 contentPage_sectionID
FROM Community_ContentPages
-- Check to see if any Errors were returned
IF @@error<>0 SELECT @Succeed=0
-- Update the Section ID of all rows that have ParentID's. 
-- This basically synchronizes all contentpages to have the same sectionID as their Parent page
update Community_ContentPages
set Community_ContentPages.contentPage_sectionID = a.contentPage_sectionID
from #ContentPageTemp a, Community_ContentPages b
where
 b.contentPage_parentID =a.contentPage_id
-- Check to see if any Errors were returned
IF @@error<>0 SELECT @Succeed=0
-- Check to to see if any errors occured
IF @Succeed=0  
 ROLLBACK TRANSACTION contentpagefix --Undo all changes if there were any errors
ELSE 
 COMMIT TRANSACTION -- No errors than we makes the changes final

 

AS ALWAYS BACKUP YOUR DATABASE BEFORE MAKING ANY CHANGES LIKE THIS!!!!


Add Your Comment

New Downloads

  • CSK Map Mod
    This is a VBVS Mod I made for the maps on my Gaming community site. It consists of the Map Section and the SQL scripts to create all of the Database objects

  • Get_Top_3_Recent_Fix.sql
    This is a SQL update for the Community Starter Kit. This mod requires that you have the Database Performance Fix applied.

  •