USP_RECURRENCE_ADD

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

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.
@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 date IN Start Date
@ENDDATE date IN End Date

Definition

Copy


                    CREATE procedure dbo.USP_RECURRENCE_ADD
                    (
                        @ID uniqueidentifier = null output,
                        @CHANGEAGENTID uniqueidentifier = null,
                        @RECURRENCETYPE tinyint = 0,
                        @INTERVAL smallint = 0,
                        @DAYOFWEEK tinyint = 0,
                        @DAY tinyint = 0,
                        @WEEK tinyint = 0,
                        @MONTH tinyint = 0,
                        @STARTDATE date = null,
                        @ENDDATE date = null
                    )
                    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()

                    --- 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);

                    begin try
                        -- handle inserting the data

                        insert into dbo.RECURRENCE
                            (ID, RECURRENCETYPE, INTERVAL, DAYOFWEEK, DAY, WEEK, MONTH, STARTDATE, ENDDATE, ADDEDBYID, CHANGEDBYID, DATEADDED, DATECHANGED)
                        values
                            (@ID, @RECURRENCETYPE, @INTERVAL, @DAYOFWEEK, @DAY, @WEEK, @MONTH, @STARTDATE, @ENDDATE, @CHANGEAGENTID, @CHANGEAGENTID, @CURRENTDATE, @CURRENTDATE)

                    end try

                    begin catch
                        exec dbo.USP_RAISE_ERROR
                        return 1
                    end catch

                    return 0