USP_DATAFORM_ADD_SOLICITCODE
The save procedure used by the add dataform template "Solicit Code Add Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | INOUT | The output parameter indicating the ID of the record added. |
@DESCRIPTION | nvarchar(100) | IN | Name |
@EXCLUSIONCODE | tinyint | IN | Type |
@SITEID | uniqueidentifier | IN | Site |
@CURRENTAPPUSERID | uniqueidentifier | IN | Input parameter indicating the ID of the current user. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@CONSENTCODE | tinyint | IN | |
@SOLICITCODECHANNELCODE | tinyint | IN | |
@COMMENTS | nvarchar(255) | IN |
Definition
Copy
CREATE procedure dbo.USP_DATAFORM_ADD_SOLICITCODE
(
@ID uniqueidentifier = null output,
@DESCRIPTION nvarchar(100) = '',
@EXCLUSIONCODE tinyint = null,
@SITEID uniqueidentifier = null,
@CURRENTAPPUSERID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@CONSENTCODE tinyint = 0,
@SOLICITCODECHANNELCODE tinyint = null,
@COMMENTS nvarchar(255) = ''
)
as
set nocount on;
declare @CURRENTDATE datetime;
if @CONSENTCODE <> 0 and @SOLICITCODECHANNELCODE is null
raiserror('BBERR_CHANNEL_REQURIED', 13, 1)
if @ID is null
set @ID = newid()
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
set @CURRENTDATE = getdate();
declare @SEQUENCE int;
select @SEQUENCE=coalesce(max(SEQUENCE),0)+1 from dbo.SOLICITCODE;
if @SITEID is null
begin
if dbo.UFN_SITEREQUIREDFORUSER(@CURRENTAPPUSERID) = 1
begin
raiserror('Site is required.',13,1)
return
end
end
begin try
insert into dbo.[SOLICITCODE]
([ID],[DESCRIPTION],[EXCLUSIONCODE],[SITEID],[SEQUENCE],[CONSENTCODE],[SOLICITCODECHANNELCODE],[COMMENTS],[ADDEDBYID],[CHANGEDBYID],[DATEADDED],[DATECHANGED])
values
(@ID,@DESCRIPTION,@EXCLUSIONCODE,@SITEID,@SEQUENCE,@CONSENTCODE,isnull(@SOLICITCODECHANNELCODE,0),@COMMENTS,@CHANGEAGENTID,@CHANGEAGENTID,@CURRENTDATE,@CURRENTDATE);
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0