USP_MKTACKNOWLEDGEMENTMAILINGTEMPLATERULE_MOVEDOWN
Executes the "Marketing Acknowledgement Template Rule: Move Down" 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_MKTACKNOWLEDGEMENTMAILINGTEMPLATERULE_MOVEDOWN]
(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null
)
as
set nocount on;
declare @ACKNOWLEDGEMENTMAILINGTEMPLATEID uniqueidentifier;
declare @BELOWRULEID uniqueidentifier;
declare @SEQ int;
declare @MAXSEQ int;
declare @CURRENTDATE datetime;
begin try
if @CHANGEAGENTID is null
exec dbo.[USP_CHANGEAGENT_GETORCREATECHANGEAGENT] @CHANGEAGENTID output;
set @CURRENTDATE = getdate();
select
@ACKNOWLEDGEMENTMAILINGTEMPLATEID = [ACKNOWLEDGEMENTMAILINGTEMPLATEID],
@SEQ = [SEQUENCE]
from dbo.[MKTACKNOWLEDGEMENTMAILINGTEMPLATERULE]
where [ID] = @ID;
begin
--Only move if not the last segment in the mailing
select @MAXSEQ = max([SEQUENCE])
from dbo.[MKTACKNOWLEDGEMENTMAILINGTEMPLATERULE]
where [ACKNOWLEDGEMENTMAILINGTEMPLATEID] = @ACKNOWLEDGEMENTMAILINGTEMPLATEID;
if (@SEQ < @MAXSEQ)
begin
select @BELOWRULEID = [ID]
from dbo.[MKTACKNOWLEDGEMENTMAILINGTEMPLATERULE]
where [ACKNOWLEDGEMENTMAILINGTEMPLATEID] = @ACKNOWLEDGEMENTMAILINGTEMPLATEID
and [SEQUENCE] = (@SEQ + 1);
exec dbo.[USP_MKTACKNOWLEDGEMENTMAILINGTEMPLATE_SWAPRULES] @ID, @BELOWRULEID, @CHANGEAGENTID;
end
end
end try
begin catch
exec dbo.[USP_RAISE_ERROR];
return 1;
end catch
return 0;