USP_DATAFORMTEMPLATE_ADD_IMAGECATEGORY

The save procedure used by the add dataform template "Image Category Add Data Form".

Parameters

Parameter Parameter Type Mode Description
@ID int INOUT The output parameter indicating the ID of the record added.
@NAME nvarchar(100) IN Name

Definition

Copy

CREATE procedure dbo.[USP_DATAFORMTEMPLATE_ADD_IMAGECATEGORY]
(
  @ID integer = null output,
  @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
  )
  begin
    raiserror('ERR_NAMEALREADYEXISTS',13,1);
    return 1
  end

  if @ID is null set @ID = 0

  declare @GUID uniqueidentifier = newid();

  begin try
    exec dbo.spAddUpdate_SiteFolders 
      @PKID = @ID output
      , @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