USP_DATAFORMTEMPLATE_EDIT_MKTSEGMENTATIONFINDERNUMBER
The save procedure used by the edit dataform template "Marketing Effort Finder Number Edit Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | The input ID parameter indicating the ID of the record being edited. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@VENDORID | uniqueidentifier | IN | Reserved for |
@MIN | bigint | IN | Range |
@MAX | bigint | IN | Quantity |
Definition
Copy
CREATE procedure dbo.[USP_DATAFORMTEMPLATE_EDIT_MKTSEGMENTATIONFINDERNUMBER]
(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@VENDORID uniqueidentifier,
@MIN bigint,
@MAX bigint
)
as
set nocount on;
declare @CURRENTDATE datetime;
--Check to see if the finder number range is for a house file
if @VENDORID = '00000000-0000-0000-0000-000000000001' set @VENDORID = null;
--Check to make sure MAX is greater than MIN
if @MIN > @MAX
begin
raiserror('BBERR_MKTSEGMENTATIONFINDERNUMBER_INVALIDRANGE', 13, 1);
return 1;
end
--Check to make sure MAX and MIN fit inside a gap
if not exists
(
select *
from dbo.[UFN_MKTSEGMENTATIONFINDERNUMBER_GAPS](@ID) as [GAPS]
where [GAPS].[MIN] <= @MIN
and ([GAPS].[MAX] >= @MAX or [GAPS].[MAX] is null)
)
begin
raiserror('BBERR_MKTSEGMENTATIONFINDERNUMBER_OVERLAPPINGRANGE', 13, 1);
return 1;
end
begin try
if @CHANGEAGENTID is null
exec dbo.[USP_CHANGEAGENT_GETORCREATECHANGEAGENT] @CHANGEAGENTID output;
set @CURRENTDATE = getdate();
update dbo.[MKTSEGMENTATIONFINDERNUMBER] set
[MAX] = @MAX,
[MIN] = @MIN,
[VENDORID] = @VENDORID,
[CHANGEDBYID] = @CHANGEAGENTID,
[DATECHANGED] = @CURRENTDATE
where [ID] = @ID;
end try
begin catch
exec dbo.[USP_RAISE_ERROR];
return 1;
end catch
return 0;