Added function vefn_CompareROIDs
Modified stored procedure getAffectedDRoUsages to utilize function
This commit is contained in:
parent
a16ea8a6ac
commit
69bbda7ed8
@ -6712,7 +6712,9 @@ IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getAffectedDRoUs
|
|||||||
GO
|
GO
|
||||||
|
|
||||||
/*
|
/*
|
||||||
getAffectedDROUsages 1, '00010000019c0000', 'KBR Test', 'Changed', 'KBR'
|
getAffectedDROUsages 1, '00010000019c0000', 'KBR Test', 'Changed', 'KBR',''
|
||||||
|
getAffectedDROUsages 1, '000300003D8E', 'KBR Test', 'Changed', 'KBR',''
|
||||||
|
|
||||||
*/
|
*/
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||||
@ -6738,13 +6740,20 @@ AS
|
|||||||
SELECT Distinct ContentID From vefn_GetVersionItems(@VersionList)
|
SELECT Distinct ContentID From vefn_GetVersionItems(@VersionList)
|
||||||
DECLARE @typeID int
|
DECLARE @typeID int
|
||||||
SELECT @typeID = TypeID from AnnotationTypes where Name = 'Verification Required'
|
SELECT @typeID = TypeID from AnnotationTypes where Name = 'Verification Required'
|
||||||
|
DECLARE @DRoUsages TABLE
|
||||||
|
(
|
||||||
|
DRoUsageID int primary key
|
||||||
|
)
|
||||||
|
Insert INTO @DRoUsages
|
||||||
|
select DRoUsageID from DRoUsages where ROID like substring(@ROID,1,12) + '%' AND dbo.vefn_CompareROIDS(ROID,@ROID) > 0
|
||||||
|
|
||||||
-- Add "Verification Required" Annotation for each ROUsage
|
-- Add "Verification Required" Annotation for each ROUsage
|
||||||
INSERT INTO [Annotations] ([ItemID],[TypeID],[SearchText],[UserID])
|
INSERT INTO [Annotations] ([ItemID],[TypeID],[SearchText],[UserID])
|
||||||
SELECT ItemID, @typeID,'Referenced Object (' + @RODesc + ') ' + @Command,@UserID
|
SELECT ItemID, @typeID,'Referenced Object (' + @RODesc + ') ' + @Command,@UserID
|
||||||
FROM Items where CONTENTID in (SELECT ContentID
|
FROM Items where CONTENTID in (SELECT ContentID
|
||||||
FROM DROUsages DR
|
FROM (select dr.* from DRoUsages dr join @DRoUsages dd on dr.DRoUsageid = dd.DRoUsageid) DR
|
||||||
JOIN Entries EE on EE.DocID = DR.DocID
|
JOIN Entries EE on EE.DocID = DR.DocID
|
||||||
where RODbID = @RODbID AND ROID = @ROID AND ContentID in (select ContentID from @JustThisVersion))
|
where RODbID = @RODbID AND ContentID in (select ContentID from @JustThisVersion))
|
||||||
SELECT
|
SELECT
|
||||||
[DROUsages].[DROUsageID],
|
[DROUsages].[DROUsageID],
|
||||||
[DROUsages].[DocID],
|
[DROUsages].[DocID],
|
||||||
@ -6765,7 +6774,7 @@ AS
|
|||||||
JOIN [Documents] ON
|
JOIN [Documents] ON
|
||||||
[Documents].[DocID]=[DROUsages].[DocID]
|
[Documents].[DocID]=[DROUsages].[DocID]
|
||||||
WHERE
|
WHERE
|
||||||
[DRoUsages].[RODbID]=@RODbID AND [DRoUsages].[ROID]=@ROID
|
[DRoUsages].[DRoUsageID] in (select DRoUsageid from @DRoUsages)
|
||||||
AND [Documents].[DocID] in (select EE.DocID from Entries EE where ContentID in (select ContentID from @JustThisVersion))
|
AND [Documents].[DocID] in (select EE.DocID from Entries EE where ContentID in (select ContentID from @JustThisVersion))
|
||||||
RETURN
|
RETURN
|
||||||
END
|
END
|
||||||
@ -8664,3 +8673,37 @@ IF (@@Error = 0) PRINT 'Procedure Creation: getOwnersByVersionID Succeeded'
|
|||||||
ELSE PRINT 'Procedure Creation: getOwnersByVersionID Error on Creation'
|
ELSE PRINT 'Procedure Creation: getOwnersByVersionID Error on Creation'
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_CompareROIDs]') AND OBJECTPROPERTY(id,N'IsScalarFunction') = 1)
|
||||||
|
DROP FUNCTION [vefn_CompareROIDs];
|
||||||
|
/****** Object: UserDefinedFunction [dbo].[vefn_CompareROIDs] Script Date: 07/21/2014 17:50:44 ******/
|
||||||
|
SET ANSI_NULLS ON
|
||||||
|
GO
|
||||||
|
SET QUOTED_IDENTIFIER ON
|
||||||
|
GO
|
||||||
|
|
||||||
|
create function vefn_CompareROIDs (@roid1 varchar(16), @roid2 varchar(16))
|
||||||
|
returns int
|
||||||
|
as begin
|
||||||
|
declare @len1 int
|
||||||
|
declare @len2 int
|
||||||
|
if @roid1 = @roid2
|
||||||
|
return 1
|
||||||
|
set @len1 = len(@roid1)
|
||||||
|
set @len2 = len(@roid2)
|
||||||
|
if @len1 = @len2
|
||||||
|
begin
|
||||||
|
if @len1 = 16 and substring(@roid1,13,4) = '0000' and substring(@roid2,13,4) = '0041'
|
||||||
|
return 2
|
||||||
|
if @len1 = 16 and substring(@roid2,13,4) = '0000' and substring(@roid1,13,4) = '0041'
|
||||||
|
return 3
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
if substring(@roid1,1,12) = substring(@roid2,1,12)
|
||||||
|
return 4
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
GO
|
||||||
|
-- Display the status of ScalarFunction creation
|
||||||
|
IF (@@Error = 0) PRINT 'Function: vefn_CompareROIDs Succeeded'
|
||||||
|
ELSE PRINT 'Function: vefn_CompareROIDs Error on Creation'
|
||||||
|
GO
|
||||||
|
Loading…
x
Reference in New Issue
Block a user