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

109 lines
3.3 KiB
Transact-SQL
Raw Permalink 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_GroupsUpdateInsert] Script Date: 3/22/2019 4:33:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_GroupsUpdateInsert]
@SerialNumber nvarchar(255) = null
,@Picture NVARCHAR(255) = null
,@DisplayName nvarchar(255)
,@Description nvarchar(255)
,@Embedded bit
,@LastModified datetime
,@LastModifiedBy nvarchar(50)
,@StaticGroupId int = NULL
,@new_id int output
,@errorNumber int output
,@errorMessage nvarchar(250) output
AS
BEGIN
set @errorNumber = 0; set @errorMessage = space(0);
declare @GroupId int
set @GroupId = dbo.foo_IdGetGroup(@SerialNumber)
--declare @TemplateId int
--set @TemplateId = dbo.foo_IdGetTemplate(@Template)
if(exists(select Id from [dbo].[Groups] where Id = @GroupId))
begin
set @new_id = @GroupId;
exec dbo.sp_GroupsUpdate @GroupId
,@SerialNumber
,@Picture
,@DisplayName
,@Description
,@Embedded
,@LastModified
,@LastModifiedBy
,@StaticGroupId
,@errorNumber output, @errorMessage output
end
else
begin
exec dbo.sp_GroupsInsert @SerialNumber
,@Picture
,@DisplayName
,@Embedded
,@Description
,@LastModified
,@LastModifiedBy
,@StaticGroupId
,@errorNumber output, @errorMessage output, @new_id output
end
END