76 lines
3.3 KiB
Transact-SQL
76 lines
3.3 KiB
Transact-SQL
USE [DataPRO]
|
||
GO
|
||
/****** Object: StoredProcedure [dbo].[sp_CompareGroups] Script Date: 2/11/2019 1:08:12 PM ******/
|
||
SET ANSI_NULLS ON
|
||
GO
|
||
SET QUOTED_IDENTIFIER ON
|
||
GO
|
||
|
||
|
||
ALTER PROCEDURE [dbo].[sp_CompareGroups]
|
||
|
||
@StaticDescription NVARCHAR(255),
|
||
@StaticGroupId INT,
|
||
@EmbeddedGroupId INT,
|
||
@Result BIT output
|
||
|
||
AS
|
||
BEGIN
|
||
IF ((SELECT COUNT(*) FROM [dbo].[Groups] WHERE Id = @EmbeddedGroupId AND Description = @StaticDescription) = 0)
|
||
BEGIN
|
||
SET @Result = 0
|
||
RETURN;
|
||
END
|
||
|
||
SET NOCOUNT ON;
|
||
DECLARE @TotalCountStaticGroup INT
|
||
DECLARE @TotalCountEmbeddedGroup INT
|
||
DECLARE @IdenticalCount INT
|
||
|
||
SET @TotalCountStaticGroup = [dbo].[foo_GetTotalChannelCount](@StaticGroupId)
|
||
SET @TotalCountEmbeddedGroup = [dbo].[foo_GetTotalChannelCount](@EmbeddedGroupId)
|
||
IF (@TotalCountStaticGroup <> @TotalCountEmbeddedGroup)
|
||
BEGIN
|
||
SET @Result = 0
|
||
RETURN;
|
||
END
|
||
ELSE
|
||
BEGIN
|
||
IF (@TotalCountStaticGroup > 0) -- Both TotalCounts are the same
|
||
BEGIN
|
||
SET @IdenticalCount = [dbo].[foo_GetIdenticalChannelCount](@StaticGroupId, @EmbeddedGroupId)
|
||
IF (@IdenticalCount <> @TotalCountStaticGroup) -- Both TotalCounts are the same
|
||
BEGIN
|
||
SET @Result = 0
|
||
RETURN;
|
||
END
|
||
END
|
||
END
|
||
|
||
BEGIN TRY
|
||
EXEC [dbo].[sp_CompareGroupHardware] @StaticGroupId, @EmbeddedGroupId, @Result OUTPUT
|
||
IF (@Result = 0)
|
||
BEGIN
|
||
RETURN
|
||
END
|
||
END TRY
|
||
BEGIN CATCH
|
||
SET @Result = 0
|
||
END CATCH
|
||
|
||
BEGIN TRY
|
||
EXEC [dbo].[sp_CompareGroupChannelSettings] @StaticGroupId, @EmbeddedGroupId, @Result OUTPUT
|
||
IF (@Result = 0)
|
||
BEGIN
|
||
RETURN
|
||
END
|
||
END TRY
|
||
BEGIN CATCH
|
||
SET @Result = 0
|
||
END CATCH
|
||
|
||
SET @Result = 1
|
||
END
|
||
|
||
|