USP_DATAFORMTEMPLATE_EDIT_IMPORTSELECTION

The save procedure used by the edit dataform template "Import Selection Edit Data 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.
@NAME nvarchar(255) IN Name
@DESCRIPTION nvarchar(1024) IN Description
@QUERYCATEGORYCODEID uniqueidentifier IN Category
@SITEID uniqueidentifier IN Site
@USEINQUERYDESIGNER bit IN Show this selection in the Query Designer

Definition

Copy


CREATE procedure dbo.[USP_DATAFORMTEMPLATE_EDIT_IMPORTSELECTION]
(
  @ID uniqueidentifier,
  @CHANGEAGENTID uniqueidentifier = null,
  @NAME nvarchar(255),
  @DESCRIPTION nvarchar(1024),
  @QUERYCATEGORYCODEID uniqueidentifier,
  @SITEID uniqueidentifier,
  @USEINQUERYDESIGNER bit
)
as
  set nocount on;

  declare @IDSETREGISTERID uniqueidentifier;
  declare @CURRENTDATE datetime;

  begin try
    if @CHANGEAGENTID is null  
      exec dbo.[USP_CHANGEAGENT_GETORCREATECHANGEAGENT] @CHANGEAGENTID output;

    set @CURRENTDATE = getdate();

    if @SITEID = '00000000-0000-0000-0000-000000000000' 
      set @SITEID = null;

    if @USEINQUERYDESIGNER is null
      set @USEINQUERYDESIGNER = 0;

    -- update the import selection information

    update dbo.[IMPORTSELECTIONPROCESS] set
      [NAME] = @NAME,
      [DESCRIPTION] = @DESCRIPTION,
      [QUERYCATEGORYCODEID] = @QUERYCATEGORYCODEID,
      [SITEID] = @SITEID,
      [USEINQUERYDESIGNER] = @USEINQUERYDESIGNER,
      [CHANGEDBYID] = @CHANGEAGENTID,
      [DATECHANGED] = @CURRENTDATE
    where [ID] = @ID;

    select
      @IDSETREGISTERID = [IDSETREGISTERID]
    from dbo.[IMPORTSELECTIONPROCESS]
    where [ID] = @ID;

    -- update the IDSETREGISTER information, if it exists

    if @IDSETREGISTERID is not null and exists(select [ID] from dbo.[IDSETREGISTER] where [ID] = @IDSETREGISTERID)
      exec dbo.[USP_IDSETREGISTER_CREATEORUPDATEFORIMPORTSELECTION] 
        @IMPORTSELECTIONID = @ID,
        @USEINQUERYDESIGNER = @USEINQUERYDESIGNER,
        @CHANGEAGENTID = @CHANGEAGENTID,
        @IDSETREGISTERID = @IDSETREGISTERID;
  end try

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

  return 0;