SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_DirectDispancerRDSWorkOnModify]') and xtype = N'P')
DROP PROCEDURE  [dbo].[sp_DirectDispancerRDSWorkOnModify]
GO

---- =============================================
---- Author:      Vitacore (с)
---- Create date: 2017-09-21
---- Description: Хранимка рулит какую хранимку звать по действию при изменении объекта
---- =============================================

--CREATE  PROCEDURE [dbo].[sp_DirectDispancerRDSWorkOnModify]
--@GuidPackage uniqueidentifier,
--@QueueName varchar(100)
--AS

--BEGIN
--	SET NOCOUNT ON;
	 
--	if ((select [Status] from AKUZ.T_RDS_DISP_PACKAGE where RdsdispPackageID = @GuidPackage) = 'ident')
--	begin
--		exec sp_DirectDispancerRDSXML @GuidPackage, @QueueName
--	end
--	else 
--	begin
--		declare @id varchar(36);
--		declare @entName varchar(255);
--		(select @id = [Status], @entName = ent.EntName from AKUZ.T_RDS_DISP_PACKAGE pack
--		 join AKUZ.T_RDS_DISP_PROGRAM program on program.RdsDispProgramID = pack.RdsDispProgram
--		 join AKUZ.T_RDS_DISP_PROGRAM_GROUP programgroup on program.RdsDispProgramGroup = programgroup.RdsDispProgramGroupID
--		 join VCLib.T_ENTITIES ent on ent.EntityID = programgroup.Entities
--		 where pack.RdsdispPackageID = @GuidPackage)
--		if (@id is not null)
--		begin
--			if(@entName = 'DISPANSERISATION_INIT')
--			exec sp_DispanserisationInitToRDS @id, @QueueName
--			else
--			exec sp_DirectDispancerRDSXMLDir @id, @QueueName
--		end
--	end
--END