USP_DATAFORMTEMPLATE_EDITLOAD_RESEARCHGROUPFUNDRAISERASSIGNMENT

The load procedure used by the edit dataform template "Research Group Fundraiser Assignment Edit Form"

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter used to load the fields defined on the form.
@DATALOADED bit INOUT Output parameter indicating whether or not data was actually loaded.
@TSLONG bigint INOUT Output parameter indicating the TSLONG value of the record being edited. This is used to manage multi-user concurrency issues when multiple users access the same record.
@PROSPECTMANAGERFUNDRAISERID uniqueidentifier INOUT Prospect manager
@OVERWRITEEXISTINGPROSPECTMANAGER bit INOUT Overwrite existing prospect manager
@PREVIOUSMANAGERENDDATE date INOUT
@NEWMANAGERSTARTDATE date INOUT

Definition

Copy

                    CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDITLOAD_RESEARCHGROUPFUNDRAISERASSIGNMENT (
                        @ID uniqueidentifier,
                        @DATALOADED bit = 0 output,
                        @TSLONG bigint = 0 output,
                        @PROSPECTMANAGERFUNDRAISERID uniqueidentifier = null output,
                        @OVERWRITEEXISTINGPROSPECTMANAGER bit = null output,
                        @PREVIOUSMANAGERENDDATE date = null output,
                        @NEWMANAGERSTARTDATE date = null output
                    ) as
                        set nocount on;

                        -- be sure to set these, in case the select returns no rows
                        set @DATALOADED = 0;
                        set @TSLONG = 0;

                        select
                            @DATALOADED = 1,
                            @TSLONG = RG.[TSLONG]
                        from
                            dbo.[RESEARCHGROUP] RG
                        where
                            RG.[ID] = @ID;

                        declare @MEMBERCOUNT integer;
                        select
                            @MEMBERCOUNT = count(RGM.[CONSTITUENTID])
                        from
                            dbo.[RESEARCHGROUPMEMBER] RGM
                        where
                            RGM.[RESEARCHGROUPID] = @ID;

                        if @MEMBERCOUNT > 500 begin
                            set @DATALOADED = 0;
                        end

                        set @NEWMANAGERSTARTDATE = getdate();
                        set @PREVIOUSMANAGERENDDATE = dateadd(day, -1, @NEWMANAGERSTARTDATE);
                        return 0;