USP_DATAFORMTEMPLATE_ADD_GLACCOUNT2

The save procedure used by the add dataform template "Account Add Form 2".

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.
@ACCOUNTNUMBER nvarchar(100) IN Account number
@ACCOUNTDESCRIPTION nvarchar(100) IN Description
@PDCATEGORYDEFINITIONID uniqueidentifier IN Category
@PDACCOUNTSYSTEMID uniqueidentifier IN Input parameter indicating the context ID for the record being added.
@ACCOUNTALIAS nvarchar(100) IN Account alias

Definition

Copy


CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_GLACCOUNT2
(
    @ID uniqueidentifier = null output,
    @CHANGEAGENTID uniqueidentifier = null,
    @ACCOUNTNUMBER nvarchar(100),
    @ACCOUNTDESCRIPTION nvarchar(100),
    @PDCATEGORYDEFINITIONID uniqueidentifier = null,
    @PDACCOUNTSYSTEMID uniqueidentifier,
    @ACCOUNTALIAS nvarchar(100) = ''
)
as
    set nocount on;

    if @ID is null
        set @ID = newid();

    if @CHANGEAGENTID is null 
        exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;

    declare @CURRENTDATE datetime;
    set @CURRENTDATE = getdate();

    -- Removed account category

    -- select @PDCATEGORYDEFINITIONID = dbo.UFN_GLACCOUNT_GETCATEGORY(@ACCOUNTNUMBER)

    -- if @PDCATEGORYDEFINITIONID is null

    --   raiserror('ERR_PDCATEGORYDEFINITION_ISNULL',13,1) 


    begin try
        insert into dbo.GLACCOUNT
        (
            ID,
            ACCOUNTNUMBER,
            ACCOUNTDESCRIPTION,
            PDCATEGORYDEFINITIONID,
            PDACCOUNTSYSTEMID,
            ADDEDBYID,
            CHANGEDBYID,
            DATEADDED,
            DATECHANGED,
      ACCOUNTALIAS
        )
        values
        (
            @ID,
            @ACCOUNTNUMBER,
            @ACCOUNTDESCRIPTION,
            @PDCATEGORYDEFINITIONID,
            @PDACCOUNTSYSTEMID,
            @CHANGEAGENTID,
            @CHANGEAGENTID,
            @CURRENTDATE,
            @CURRENTDATE,
      @ACCOUNTALIAS
        );
    end try

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

    return 0;