USP_RECURRENCE_EDITSAVE

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

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter indicating the ID of the record being edited.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.
@RECURRENCETYPE tinyint IN Recurrence Type
@INTERVAL smallint IN Interval
@DAYOFWEEK tinyint IN Day Of Week
@DAY tinyint IN Day
@WEEK tinyint IN Week
@MONTH tinyint IN Month
@STARTDATE datetime IN Start Date
@ENDDATE datetime IN End Date

Definition

Copy


CREATE procedure dbo.USP_RECURRENCE_EDITSAVE(
    @ID uniqueidentifier,
    @CHANGEAGENTID uniqueidentifier = null,
    @RECURRENCETYPE tinyint,
    @INTERVAL smallint,
    @DAYOFWEEK tinyint ,
    @DAY tinyint,
    @WEEK tinyint,
    @MONTH tinyint,
    @STARTDATE datetime,
    @ENDDATE datetime
)
as

    set nocount on;

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

    --- Ensure that the start date is a valid occurrence.  The table will not accept the data if this isn't the case.

                    set @STARTDATE = dbo.UFN_RECURRENCE_CALCULATEACTUALSTARTDATE(@RECURRENCETYPE, @DAYOFWEEK, @DAY, @WEEK, @MONTH, @STARTDATE);

    declare @CURRENTDATE datetime
    set @CURRENTDATE = getdate()

    begin try
        -- handle updating the data

        update dbo.RECURRENCE set
        RECURRENCETYPE = @RECURRENCETYPE,
        INTERVAL = @INTERVAL,
        DAYOFWEEK = @DAYOFWEEK,
        DAY = @DAY,
        WEEK = @WEEK,
        MONTH = @MONTH,
        STARTDATE = @STARTDATE,
        ENDDATE = @ENDDATE,
        CHANGEDBYID = @CHANGEAGENTID,
        DATECHANGED = @CURRENTDATE
        where ID = @ID
    end try
    begin catch
        exec dbo.USP_RAISE_ERROR
        return 1
    end catch

return 0;