Files
DP44/DataPRO_sql/dbo.sp_CompareGroups.StoredProcedure.sql
2026-04-17 14:55:32 -04:00

76 lines
3.3 KiB
Transact-SQL
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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