C2026-058 Check all Tables for if Acc Page Id Prefix is Used More than Once
This commit is contained in:
1 parent
ae9fb0eb67
commit
82f11fa696
10 files changed
+717
-133
No files matched your search
@@ -25035,6 +25035,162 @@ IF (@@Error = 0) PRINT 'Trigger Alteration: tr_Contents_Delete Succeeded'
|
||||
ELSE PRINT 'Trigger Alteration: tr_Contents_Delete Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: View [dbo].[vwDupAccIDs] ***********************/
|
||||
If Exists(SELECT * FROM sys.objects Where name = 'vwDupAccIDs' AND type in (N'V'))
|
||||
DROP VIEW [dbo].[vwDupAccIDs]
|
||||
GO
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Matthew Schill
|
||||
Create Date: 10/7/2026
|
||||
Description: View for Duplicate Accessory Page IDs in ROs in PROMS
|
||||
Usage: Select * FROM dbo.vwDupAccIDs Order by RofstID, AccPageID, GroupTitle
|
||||
==========================================================================================================
|
||||
*/
|
||||
CREATE View [dbo].[vwDupAccIDs]
|
||||
AS
|
||||
SELECT rochild.AccPageID, NUMAccPageIDs,
|
||||
AccPageIDPrefix = dbiAP, GroupTitle = dbiTitle,
|
||||
title, value, roid, rochild.RofstID
|
||||
FROM
|
||||
vwRofstData_RofstChildren rochild
|
||||
INNER JOIN
|
||||
(SELECT ROFstID = Max(ROFstID)
|
||||
FROM ROFsts
|
||||
Group by RODbID) latestfsts
|
||||
ON latestfsts.ROFstID = rochild.RofstID
|
||||
INNER JOIN
|
||||
(SELECT NUMAccPageIDs=COunt(*), RoFstID, AccPageID FROM
|
||||
vwRofstData_RofstChildren
|
||||
WHERE AccPageID IS NOT NULL
|
||||
Group by RoFstID, AccPageID
|
||||
Having Count(*) > 1
|
||||
) dupAcc
|
||||
ON latestfsts.ROFstID = dupAcc.RofstID
|
||||
AND dupAcc.AccPageID = rochild.AccPageID
|
||||
|
||||
go
|
||||
|
||||
IF (@@Error = 0) PRINT 'View [vwDupAccIDs] Succeeded'
|
||||
ELSE PRINT 'View [vwDupAccIDs] Error on Creation'
|
||||
go
|
||||
|
||||
/****** Object: StoredProcedure [getDupAccIDs] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getDupAccIDs]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [getDupAccIDs];
|
||||
GO
|
||||
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Matthew Schill
|
||||
Create Date: 10/7/2026
|
||||
Description: Procedure for Duplicate Accessory Page IDs in ROs in PROMS
|
||||
==========================================================================================================
|
||||
*/
|
||||
CREATE PROCEDURE [dbo].[getDupAccIDs]
|
||||
AS
|
||||
BEGIN
|
||||
Select * FROM dbo.vwDupAccIDs Order by RofstID, AccPageID, GroupTitle
|
||||
|
||||
RETURN
|
||||
END
|
||||
|
||||
GO
|
||||
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: getDupAccIDs Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: getDupAccIDs Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [getDupAccPrefixes] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getDupAccPrefixes]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [getDupAccPrefixes];
|
||||
GO
|
||||
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Matthew Schill
|
||||
Create Date: 10/7/2026
|
||||
Description: Procedure for Duplicate Accessory Page Prefixes in ROs in PROMS
|
||||
==========================================================================================================
|
||||
*/
|
||||
CREATE PROCEDURE [dbo].[getDupAccPrefixes]
|
||||
AS
|
||||
BEGIN
|
||||
SELECT AccPageIDPrefix = dbiAP, GroupTitle = dbiTitle
|
||||
FROM
|
||||
RofstDatabase
|
||||
INNER JOIN
|
||||
(SELECT ROFstID = Max(ROFstID)
|
||||
FROM ROFsts
|
||||
Group by RODbID) latestfsts
|
||||
ON latestfsts.ROFstID = RofstDatabase.RofstID
|
||||
INNER JOIN
|
||||
(SELECT RoFstID, APPrefix = dbiAP FROM
|
||||
RofstDatabase
|
||||
Group by RoFstID, dbiAP
|
||||
Having Count(*) > 1
|
||||
) dupAcc
|
||||
ON latestfsts.ROFstID = dupAcc.RofstID AND APPrefix = dbiAP
|
||||
Order by dbiAP, dbiTitle
|
||||
|
||||
RETURN
|
||||
END
|
||||
|
||||
GO
|
||||
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: getDupAccPrefixes Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: getDupAccPrefixes Error on Creation'
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [getDocsDupAccIDs] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getDocsDupAccIDs]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [getDocsDupAccIDs];
|
||||
GO
|
||||
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Matthew Schill
|
||||
Create Date: 10/7/2026
|
||||
Description: Get PROMS Documents containing Duplicate Accessory Page IDs
|
||||
==========================================================================================================
|
||||
*/
|
||||
CREATE PROCEDURE [dbo].[getDocsDupAccIDs]
|
||||
AS
|
||||
BEGIN
|
||||
Select Path = CASE WHEN VN.ParentName = VN.GrandParentName THEN ''
|
||||
ELSE VN.GrandParentName + '->' END +
|
||||
VN.ParentName + '->' + VN.FolderName + '->' + Pth.Path + '`' + Text,
|
||||
AccPageID, DupAcc.roid, Contents.ContentID
|
||||
FROM dbo.vwDupAccIDs DupAcc
|
||||
INNER JOIN DROUsages with (NoLock) ON LEFT(DROUsages.ROID,12) = LEFT(DupAcc.roid,12)
|
||||
INNER JOIN Entries with (NoLock) on DROUsages.DocID = Entries.DocID
|
||||
INNER JOIN Contents with (NoLock) on Contents.ContentID = Entries.ContentID
|
||||
INNER JOIN Items with (NoLock) on Contents.ContentID = Items.ContentID
|
||||
INNER JOIN vefn_getversionItems('') vi on Contents.contentID = vi.contentID
|
||||
INNER JOIN VEFN_GetVersionNames() VN ON vi.VersionID = VN.VersionID
|
||||
OUTER APPLY
|
||||
(Select Path = REPLACE(dbo.ve_GetPath(Items.ItemID), '\u8209?', '-')) Pth
|
||||
Order by GrandParentName, ParentName, FolderName, Path, Text, AccPageID
|
||||
RETURN
|
||||
END
|
||||
|
||||
GO
|
||||
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: getDocsDupAccIDs Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: getDocsDupAccIDs Error on Creation'
|
||||
GO
|
||||
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
| ADD New Code Before this Block |
|
||||
@@ -25068,8 +25224,8 @@ BEGIN TRY -- Try Block
|
||||
DECLARE @RevDate varchar(255)
|
||||
DECLARE @RevDescription varchar(255)
|
||||
|
||||
set @RevDate = '07/16/2026 8:30 AM'
|
||||
set @RevDescription = 'Reworked ve_GetParentItem for Performance improvement'
|
||||
set @RevDate = '10/7/2026 9:30 AM'
|
||||
set @RevDescription = 'Added Reports for Duplicate Acc Page IDs in ROs'
|
||||
|
||||
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
|
||||
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription
|
||||
|
||||
Reference in new issue
Block a user