USP_CLIENTROLE_MEMBER_ADD
The save procedure used by the add dataform template "Client Role Member Add".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | INOUT | The output parameter indicating the ID of the record added. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@CLIENTROLESID | int | IN | Input parameter indicating the context ID for the record being added. |
@XMLDATA | xml | IN | XML Data |
Definition
Copy
CREATE procedure dbo.USP_CLIENTROLE_MEMBER_ADD
(
@ID uniqueidentifier = null output,
@CHANGEAGENTID uniqueidentifier = null,
@CLIENTROLESID int,
@XMLDATA xml = null
)
as
set nocount on;
if @ID is null
set @ID = newid()
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()
begin try
if @XMLDATA.exist('/t/r') = 1
begin
insert into dbo.CLIENTROLECHILD ([PARENTCLIENTROLEID],[CHILDCLIENTROLEID],ADDEDBYID, CHANGEDBYID, DATEADDED, DATECHANGED)
select
@CLIENTROLESID,
CR.ID,
@CHANGEAGENTID, @CHANGEAGENTID, @CURRENTDATE, @CURRENTDATE
from @XMLDATA.nodes('/t/r') T(R)
inner join dbo.CLIENTROLES CR on CR.GUID = T.R.value('@ID', 'uniqueidentifier')
insert into dbo.USERROLES ([CLIENTUSERSID],[CLIENTROLESID],[ManuallyAdded])
select
CU.ID,
@CLIENTROLESID,
1
from @XMLDATA.nodes('/t/r') T(R)
inner join dbo.CLIENTUSERS CU on CU.GUID = T.R.value('@ID', 'uniqueidentifier')
end
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0