USP_RECORDOPERATION_GROUPMEMBERSETPRIMARY
Executes the "Group Member: Set Primary" record operation.
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | Input parameter indicating the ID of the record being updated. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the update. |
Definition
Copy
create procedure dbo.USP_RECORDOPERATION_GROUPMEMBERSETPRIMARY
(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null
)
as
set nocount on;
declare @GROUPID uniqueidentifier;
select @GROUPID = GROUPID from GROUPMEMBER where ID = @ID;
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
update
dbo.GROUPMEMBER
set
ISPRIMARY = 0,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = getdate()
where
GROUPID = @GROUPID
and ISPRIMARY = 1
and ID <> @ID;
update
dbo.GROUPMEMBER
set
ISPRIMARY = 1,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = getdate()
where
ISPRIMARY = 0
and ID = @ID;
return 0;