USP_USERSETTINGSBATCHTEMPLATE_CREATEORUPDATEBYBATCHID

Parameters

Parameter Parameter Type Mode Description
@APPUSERID uniqueidentifier IN
@BATCHID uniqueidentifier IN
@SETTINGS xml IN

Definition

Copy


create procedure dbo.USP_USERSETTINGSBATCHTEMPLATE_CREATEORUPDATEBYBATCHID
(
  @APPUSERID uniqueidentifier,
    @BATCHID uniqueidentifier,
    @SETTINGS xml
)
as
begin
  declare @BATCHTEMPLATEID uniqueidentifier;
  select @BATCHTEMPLATEID = BATCHTEMPLATEID from dbo.BATCH where ID = @BATCHID;

  declare @EXISTINGID uniqueidentifier;
    select @EXISTINGID = ID from dbo.USERSETTINGSBATCHTEMPLATE where APPUSERID = @APPUSERID and BATCHTEMPLATEID = @BATCHTEMPLATEID;

    if @EXISTINGID is null
    begin
        insert into dbo.USERSETTINGSBATCHTEMPLATE (
            APPUSERID,
            BATCHTEMPLATEID,
            SETTINGS)
        values (
            @APPUSERID,
            @BATCHTEMPLATEID,
            @SETTINGS);
    end
    else
    begin
        update dbo.USERSETTINGSBATCHTEMPLATE 
        set SETTINGS = @SETTINGS
        where ID = @EXISTINGID;
    end;
end