USP_DATAFORMTEMPLATE_EDITLOAD_MKTSEGMENTATIONSEGMENT_DRAGDROPINSERT

The load procedure used by the edit dataform template "Marketing Effort Segment Drag and Drop Edit Form"

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter used to load the fields defined on the form.
@DATALOADED bit INOUT Output parameter indicating whether or not data was actually loaded.
@BRIEFS xml INOUT Briefs
@SEGMENTS xml INOUT Segments
@SEGMENTSEQUENCE int INOUT Segment Sequence
@BRIEFSEQUENCE int INOUT Brief Sequence
@MARKETINGPLANBRIEFID uniqueidentifier INOUT Marketing Plan Brief ID
@NEXTBRIEFSEQUENCE int INOUT Next Brief Sequence
@TSLONG bigint INOUT Output parameter indicating the TSLONG value of the record being edited. This is used to manage multi-user concurrency issues when multiple users access the same record.

Definition

Copy


CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDITLOAD_MKTSEGMENTATIONSEGMENT_DRAGDROPINSERT
(
  @ID uniqueidentifier,                                   /* The mailing ID. */
  @DATALOADED bit = 0 output,                             /* Returns true if the mailing exists. */
  @BRIEFS xml = null output,
  @SEGMENTS xml = null output,
  @SEGMENTSEQUENCE int = null output,
  @BRIEFSEQUENCE int = null output,
  @MARKETINGPLANBRIEFID uniqueidentifier = null output,
  @NEXTBRIEFSEQUENCE int = null output,
  @TSLONG bigint = 0 output
)
as
  set nocount on;

  set @DATALOADED = 0;
  set @TSLONG = 0;

  with [SEGMENTS_CTE] ([ID], [TSLONG]) as
  (
    select
      [ID],
      [TSLONG]
    from dbo.[MKTSEGMENTATIONSEGMENT]
    where [SEGMENTATIONID] = @ID
  )
  select
    @DATALOADED = 1,
    @TSLONG = (select max([TSLONG])
               from (
                 select isnull(max([TSLONG]), 0) as [TSLONG] from [SEGMENTS_CTE]
                 union all
                 select isnull(max([TSLONG]), 0) as [TSLONG] from dbo.[MKTSEGMENTATIONTESTSEGMENT] where [SEGMENTID] in (select [ID] from [SEGMENTS_CTE])
                 union all
                 select isnull(max([TSLONG]), 0) as [TSLONG] from dbo.[MKTMARKETINGPLANBRIEF] where [MARKETINGPLANITEMID] = [MKTSEGMENTATION].[MARKETINGPLANITEMID]
               ) as [T])
  from dbo.[MKTSEGMENTATION]
  where [ID] = @ID;

  if @DATALOADED = 1
    begin
      --Check if the mailing is currently being activated...

      declare @R int;
      exec @R = dbo.[USP_MKTSEGMENTATION_CHECKACTIVATION] @ID;
      if @R <> 0
        return 1;
    end

  return 0;