B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced

This commit is contained in:
2022-08-03 15:03:40 +00:00
parent f234174a51
commit b6d69fbd4c
8 changed files with 347 additions and 22 deletions

View File

@@ -20952,6 +20952,80 @@ GO
==========================================================================================================
*/
/*
==========================================================================================================
Start: B2022-049 Unlink single procedure for enhanced (if data got corrupted)
==========================================================================================================
*/
If Exists(SELECT * FROM sys.objects Where name = 'vesp_PurgeProcLinkedItemsAndChildren' AND type in (N'P'))
DROP PROCEDURE [dbo].[vesp_PurgeProcLinkedItemsAndChildren]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2022 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
Create PROCEDURE [dbo].[vesp_PurgeProcLinkedItemsAndChildren](@EnhanceID int, @EnhType int)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
-- Only unlink for the input procedure number & its children. Do not follow the links, i.e. source or enhanced. This
-- can be used for removing link information if the links between the 2, source & enhanced, get corrupted.
declare @Enh1 TABLE
(
ID int,
xConfig xml
)
insert into @Enh1
select CC.ContentID, CC.xConfig from (select *, cast(config as xml) xConfig from Contents) CC
JOIN vefn_ChildItems(@EnhanceID) VCI ON VCI.ContentID = CC.ContentID
cross apply VEFN_GetNewEnhancedData(VCI.itemid,@EnhType) VEN
Update @Enh1 Set xConfig.modify('delete //Enhanced[@Type=sql:variable("@EnhType")]') From @Enh1
Update CC Set Config = cast(xconfig as varchar(max)) From Contents CC
Join @Enh1 EE ON EE.ID = CC.ContentID
SELECT [ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[LastChanged],
(SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=[Contents].[ContentID]) [DetailCount],
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=[Contents].[ContentID]) [EntryCount],
(SELECT COUNT(*) FROM [Grids] WHERE [Grids].[ContentID]=[Contents].[ContentID]) [GridCount],
(SELECT COUNT(*) FROM [Images] WHERE [Images].[ContentID]=[Contents].[ContentID]) [ImageCount],
(SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=[Contents].[ContentID]) [ItemCount],
(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=[Contents].[ContentID]) [PartCount],
(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=[Contents].[ContentID]) [RoUsageCount],
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=[Contents].[ContentID]) [TransitionCount],
(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=[Contents].[ContentID]) [ZContentCount]
FROM [Contents] where ContentID in (Select ID From @Enh1)
IF( @@TRANCOUNT > 0 ) COMMIT
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
EXEC vlnErrorHandler
END CATCH
GO
IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_PurgeProcLinkedItemsAndChildren] Succeeded'
ELSE PRINT 'Procedure Creation: [vesp_PurgeProcLinkedItemsAndChildren] Error on Creation'
GO
/*
==========================================================================================================
End: B2022-049 Unlink single procedure for enhanced (if data got corrupted) [Version 2.xx]
==========================================================================================================
*/
-----------------------------------------------------------------------------
/*
---------------------------------------------------------------------------
@@ -20986,8 +21060,8 @@ BEGIN TRY -- Try Block
DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255)
set @RevDate = '07/29/2022 9:00 AM'
set @RevDescription = 'B2022-082: Search not finding occurrences that use bold and underline'
set @RevDate = '08/03/2022 9:00 AM'
set @RevDescription = 'B2022-049 Unlink single procedure for enhanced (if data got corrupted) '
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription