USP_DATAFORMTEMPLATE_EDIT_IMAGECATEGORY

The save procedure used by the edit dataform template "Image Category Edit Data Form".

Parameters

Parameter Parameter Type Mode Description
@ID int IN The input ID parameter indicating the ID of the record being edited.
@NAME nvarchar(100) IN Name

Definition

Copy

CREATE procedure dbo.[USP_DATAFORMTEMPLATE_EDIT_IMAGECATEGORY]
(
  @ID integer,
  @NAME nvarchar(100)
)
as
  set nocount on;

  if exists (
    select top 1 1
    from dbo.SiteFolders
    where 
      FolderName = @NAME
      and ParentFolderID is null
      and Type = 2
      and Deleted = 0
      and ClientSitesID = 1
      and FolderID != @ID
  )
  begin
    raiserror('ERR_NAMEALREADYEXISTS',13,1);
    return 1
  end

  declare @GUID uniqueidentifier = newid();

  begin try
    exec dbo.spAddUpdate_SiteFolders 
      @PKID = @ID
      , @CurrentUsersID = 1
      , @ClientSitesID = 1
      , @FolderName = @NAME
      , @ParentFolderID = NULL
      , @Sequence = 0
      , @Type = 2
      , @Guid = @GUID
  end try

  begin catch
    exec dbo.USP_RAISE_ERROR
    return 1
  end catch

  return 0;