diff --git a/PROMS/DataLoader/PROMSFixes.Sql b/PROMS/DataLoader/PROMSFixes.Sql index 96bbc68e..5693daee 100644 --- a/PROMS/DataLoader/PROMSFixes.Sql +++ b/PROMS/DataLoader/PROMSFixes.Sql @@ -9154,7 +9154,60 @@ go IF (@@Error = 0) PRINT 'Procedure Creation: CopyItemAndChildren Succeeded' ELSE PRINT 'Procedure Creation: CopyItemAndChildren Error on Creation' GO -Delete From Formats where name like 'WPS%' or name like 'WEP%' or name like 'WPB%' or name like 'VCBEPP%' or name like 'BNPPdev%' + +IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_removeUnUsedFormat]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP PROCEDURE [vesp_removeUnUsedFormat]; +GO +/***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2021 - Volian Enterprises, Inc. All rights reserved. +*****************************************************************************/ +CREATE PROCEDURE [dbo].[vesp_removeUnUsedFormat] +( + @Name nvarchar(100) +) +WITH EXECUTE AS OWNER +AS +BEGIN TRY -- Try Block + BEGIN TRANSACTION + declare @tbl Table( + removeid int) + declare @baseid int + insert into @tbl select formatid from formats where name like @name + + -- get the format id of the base format + select @baseid = formatid from formats where name = 'base' + + -- assign deleted format with the base format + update folders set FormatID = @baseid where FormatID in (select removeid from @tbl) + update DocVersions set FormatID = @baseid where FormatID in (select removeid from @tbl) + update tblContents set FormatID = @baseid where FormatID in (select removeid from @tbl) + -- delete the contentAudits records that use the deleted format + delete ContentAudits where FormatID in (select removeid from @tbl) + -- delete the record out of formats + delete Formats where FormatID in (select removeid from @tbl) + + 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 +-- Display the status of remove format +IF (@@Error = 0) PRINT 'StoredProcedure [vesp_removeUnUsedFormat] Succeeded' +ELSE PRINT 'StoredProcedure [vesp_removeUnUsedFormat] Error on Creation' +go + + +-- remove un-used formats +exec vesp_removeUnUsedFormat 'WPS%' +exec vesp_removeUnUsedFormat 'WPB%' +exec vesp_removeUnUsedFormat 'VCBEPP%' +exec vesp_removeUnUsedFormat 'BNPPdev%' + PRINT 'Kewaunee, Point Beach, un-used Summer, Barakah Deviation formats removed' GO @@ -16642,8 +16695,8 @@ BEGIN TRY -- Try Block set nocount on DECLARE @RevDate varchar(255) DECLARE @RevDescription varchar(255) - set @RevDate = '06/25/2021 09:15 AM' - set @RevDescription = 'Remove Barakah Deviation Format' + set @RevDate = '07/06/2021 12:16 PM' + set @RevDescription = 'Added vesp_RemoveUnUsedFormat' Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription IF( @@TRANCOUNT > 0 ) COMMIT diff --git a/PROMS/VEPROMS User Interface/PROMSFixes.Sql b/PROMS/VEPROMS User Interface/PROMSFixes.Sql index 96bbc68e..5693daee 100644 --- a/PROMS/VEPROMS User Interface/PROMSFixes.Sql +++ b/PROMS/VEPROMS User Interface/PROMSFixes.Sql @@ -9154,7 +9154,60 @@ go IF (@@Error = 0) PRINT 'Procedure Creation: CopyItemAndChildren Succeeded' ELSE PRINT 'Procedure Creation: CopyItemAndChildren Error on Creation' GO -Delete From Formats where name like 'WPS%' or name like 'WEP%' or name like 'WPB%' or name like 'VCBEPP%' or name like 'BNPPdev%' + +IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_removeUnUsedFormat]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP PROCEDURE [vesp_removeUnUsedFormat]; +GO +/***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2021 - Volian Enterprises, Inc. All rights reserved. +*****************************************************************************/ +CREATE PROCEDURE [dbo].[vesp_removeUnUsedFormat] +( + @Name nvarchar(100) +) +WITH EXECUTE AS OWNER +AS +BEGIN TRY -- Try Block + BEGIN TRANSACTION + declare @tbl Table( + removeid int) + declare @baseid int + insert into @tbl select formatid from formats where name like @name + + -- get the format id of the base format + select @baseid = formatid from formats where name = 'base' + + -- assign deleted format with the base format + update folders set FormatID = @baseid where FormatID in (select removeid from @tbl) + update DocVersions set FormatID = @baseid where FormatID in (select removeid from @tbl) + update tblContents set FormatID = @baseid where FormatID in (select removeid from @tbl) + -- delete the contentAudits records that use the deleted format + delete ContentAudits where FormatID in (select removeid from @tbl) + -- delete the record out of formats + delete Formats where FormatID in (select removeid from @tbl) + + 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 +-- Display the status of remove format +IF (@@Error = 0) PRINT 'StoredProcedure [vesp_removeUnUsedFormat] Succeeded' +ELSE PRINT 'StoredProcedure [vesp_removeUnUsedFormat] Error on Creation' +go + + +-- remove un-used formats +exec vesp_removeUnUsedFormat 'WPS%' +exec vesp_removeUnUsedFormat 'WPB%' +exec vesp_removeUnUsedFormat 'VCBEPP%' +exec vesp_removeUnUsedFormat 'BNPPdev%' + PRINT 'Kewaunee, Point Beach, un-used Summer, Barakah Deviation formats removed' GO @@ -16642,8 +16695,8 @@ BEGIN TRY -- Try Block set nocount on DECLARE @RevDate varchar(255) DECLARE @RevDescription varchar(255) - set @RevDate = '06/25/2021 09:15 AM' - set @RevDescription = 'Remove Barakah Deviation Format' + set @RevDate = '07/06/2021 12:16 PM' + set @RevDescription = 'Added vesp_RemoveUnUsedFormat' Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription IF( @@TRANCOUNT > 0 ) COMMIT