109 lines
3.3 KiB
Transact-SQL
109 lines
3.3 KiB
Transact-SQL
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
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|