/****** Object:  StoredProcedure [dbo].[ApiAfterProdActionActiv]    Script Date: 07.09.2021 13:57:09 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



CREATE PROCEDURE [dbo].[ApiAfterProdActionActiv]

	@OrgId AS INT
	, @NewId AS INT	
	, @Type as INT
	, @NumerPelny as varchar(30)
AS 
BEGIN

IF (@Type = 501) BEGIN
	update dbo.ApiProdActivities set ErpId = @NewId where ActionId=0 and Id = @OrgId;
END
ELSE
BEGIN
update dbo.ApiProdActions  set Modified= @NewId where Id = @OrgId;
update dbo.ApiProdActivities set ErpId= -@NewId where  ActionId  = @OrgId;
END


END




GO


