USP_DATAFORMTEMPLATE_ADD_MKTSEGMENTLISTBYSELECTIONCOPY

The save procedure used by the add dataform template "List Segment By Selection Copy Add Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier INOUT The output parameter indicating the ID of the record added.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.
@SEGMENTIDTOCOPY uniqueidentifier IN Input parameter indicating the context ID for the record being added.
@NAME nvarchar(100) IN Name
@DESCRIPTION nvarchar(255) IN Description
@SEGMENTCATEGORYCODEID uniqueidentifier IN Category
@CODE nvarchar(10) IN Code
@CODEVALUEID uniqueidentifier IN Code value ID
@SELECTIONS xml IN Selections
@RENTALQUANTITY int IN Rental quantity
@RENTALCOSTADJUSTMENT money IN Rental cost adjustment
@RENTALCOSTBASISCODE tinyint IN Rental cost basis code
@EXCHANGEQUANTITY int IN Exchange quantity
@EXCHANGECOSTADJUSTMENT money IN Exchange cost adjustment
@EXCHANGECOSTBASISCODE tinyint IN Exchange cost basis code
@GROUPS xml IN Groups
@SITEID uniqueidentifier IN Site

Definition

Copy


CREATE procedure dbo.[USP_DATAFORMTEMPLATE_ADD_MKTSEGMENTLISTBYSELECTIONCOPY]
(
  @ID uniqueidentifier = null output,
  @CHANGEAGENTID uniqueidentifier = null,
  @SEGMENTIDTOCOPY uniqueidentifier,
  @NAME nvarchar(100),
  @DESCRIPTION nvarchar(255) = '',
  @SEGMENTCATEGORYCODEID uniqueidentifier = null,
  @CODE nvarchar(10) = '',
  @CODEVALUEID uniqueidentifier = null,
  @SELECTIONS xml,
  @RENTALQUANTITY int = 0,
  @RENTALCOSTADJUSTMENT money = 0,
  @RENTALCOSTBASISCODE tinyint = 1, -- per thousand

  @EXCHANGEQUANTITY int = 0,
  @EXCHANGECOSTADJUSTMENT money = 0,
  @EXCHANGECOSTBASISCODE tinyint = 1, -- per thousand

  @GROUPS xml = null,
  @SITEID uniqueidentifier = null
)
as
  set nocount on;

  declare @PARENTSEGMENTID uniqueidentifier;

  begin try
    --Grab the original parent segment...

    select
      @PARENTSEGMENTID = [MKTSEGMENTLIST].[PARENTSEGMENTID]
    from dbo.[MKTSEGMENT]
    inner join dbo.[MKTSEGMENTLIST] on [MKTSEGMENTLIST].[ID] = [MKTSEGMENT].[CURRENTSEGMENTLISTID]
    where [MKTSEGMENT].[ID] = @SEGMENTIDTOCOPY;

    set @ID = newid();

    --Add a new segment as the copy...

    exec dbo.[USP_DATAFORMTEMPLATE_ADD_MKTSEGMENTLISTBYSELECTION]
      @ID,
      @CHANGEAGENTID,
      @NAME,
      @DESCRIPTION,
      @SEGMENTCATEGORYCODEID,
      @CODE,
      @PARENTSEGMENTID,
      @SELECTIONS,
      @RENTALQUANTITY,
      @RENTALCOSTADJUSTMENT,
      @RENTALCOSTBASISCODE,
      @EXCHANGEQUANTITY,
      @EXCHANGECOSTADJUSTMENT,
      @EXCHANGECOSTBASISCODE,
      @GROUPS,
      @CODEVALUEID,
      @SITEID;
  end try

  begin catch
    exec dbo.[USP_RAISE_ERROR];
    return 1;
  end catch

  return 0;