C2021-031 added vesp_RemoveUnUsedFormat stored procedure which will remove the given format and point any uses of that format (including history records) to the PROMS Base format.
This commit is contained in:
parent
a3f89c5fa0
commit
4a70a927be
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user