USP_DATAFORMTEMPLATE_ADD_MKTMARKETINGPLANBRIEF
The save procedure used by the add dataform template "Marketing Plan Segment Summary Add Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | INOUT | The output parameter indicating the ID of the record added. |
@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. |
@MARKETINGPLANITEMID | uniqueidentifier | IN | Input parameter indicating the context ID for the record being added. |
@MARKETINGPLANID | uniqueidentifier | IN | Marketing plan |
@NAME | nvarchar(100) | IN | Name |
@DESCRIPTION | nvarchar(max) | IN | Selection |
Definition
Copy
CREATE procedure dbo.[USP_DATAFORMTEMPLATE_ADD_MKTMARKETINGPLANBRIEF]
(
@ID uniqueidentifier = null output,
@CURRENTAPPUSERID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@MARKETINGPLANITEMID uniqueidentifier,
@MARKETINGPLANID uniqueidentifier = null,
@NAME nvarchar(100) = '',
@DESCRIPTION nvarchar(max) = ''
)
as
set nocount on;
declare @CURRENTDATE datetime;
declare @SEQUENCE int;
declare @BASECURRENCYID uniqueidentifier;
if @ID is null set @ID = newid();
if @CHANGEAGENTID is null
exec dbo.[USP_CHANGEAGENT_GETORCREATECHANGEAGENT] @CHANGEAGENTID output;
set @CURRENTDATE = getdate();
select @BASECURRENCYID = [BASECURRENCYID] from dbo.[MKTMARKETINGPLANITEM] where [ID] = @MARKETINGPLANITEMID;
begin try
select
@SEQUENCE = isnull(max([SEQUENCE]), 0) + 1
from dbo.[MKTMARKETINGPLANBRIEF]
where [MARKETINGPLANITEMID] = @MARKETINGPLANITEMID;
insert into dbo.[MKTMARKETINGPLANBRIEF]
(
[ID],
[MARKETINGPLANITEMID],
[MARKETINGPLANID],
[NAME],
[DESCRIPTION],
[SEQUENCE],
[BASECURRENCYID],
[ADDEDBYID],
[CHANGEDBYID],
[DATEADDED],
[DATECHANGED]
) values (
@ID,
@MARKETINGPLANITEMID,
@MARKETINGPLANID,
@NAME,
@DESCRIPTION,
@SEQUENCE,
@BASECURRENCYID,
@CHANGEAGENTID,
@CHANGEAGENTID,
@CURRENTDATE,
@CURRENTDATE
)
end try
begin catch
exec dbo.[USP_RAISE_ERROR];
return 1;
end catch
return 0;