USP_DATAFORMTEMPLATE_EDIT_GIFTFEESTRUCTURE

The save procedure used by the edit dataform template "Gift Fee Structure Edit Data Form".

Parameters

Parameter Parameter Type Mode Description
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.
@GIFTFEESTRUCTURE xml IN Gift fees

Definition

Copy


CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_GIFTFEESTRUCTURE (
    @CHANGEAGENTID uniqueidentifier = null,
    @GIFTFEESTRUCTURE xml
)
as

    set nocount on;

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

    begin try
        --JamesWill WI121757 throw a more correct error message when specifying duplicate FROMAMOUNTs. 

        declare @DUPLICATESEXIST bit = 0;
        with [CTE] as
        (
            select count(FROMAMOUNT) as COUNT
            from dbo.UFN_GIFTFEE_GETGIFTFEESTRUCTURE_FROMITEMLISTXML(@GIFTFEESTRUCTURE)
            group by FROMAMOUNT
        )
        select @DUPLICATESEXIST = 1 
        from [CTE] 
        where COUNT > 1

        if @DUPLICATESEXIST = 1
            raiserror('BBERR_FROMAMOUNT_UNIQUE', 13, 1);

        exec dbo.USP_GIFTFEE_GETGIFTFEESTRUCTURE_CUSTOMUPDATEFROMXML @GIFTFEESTRUCTURE, @CHANGEAGENTID

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

return 0;