USP_RECORDOPERATION_WEALTHCAPACITYFORMULARECALCULATECONSTITUENTS

Executes the "Wealth Capacity Formula: Recalculate Constituents" record operation.

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN Input parameter indicating the ID of the record being updated.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the update.

Definition

Copy


                    CREATE procedure dbo.USP_RECORDOPERATION_WEALTHCAPACITYFORMULARECALCULATECONSTITUENTS (
                        @ID uniqueidentifier,
                        @CHANGEAGENTID uniqueidentifier
                    ) as
                        set nocount on;

                        declare @APPLYTOID uniqueidentifier;
                        declare APPLYTOCURSOR cursor local fast_forward for
                            select
                                WC.ID
                            from
                                dbo.WEALTHCAPACITY WC
                            where
                                WC.WEALTHCAPACITYFORMULAID = @ID and
                                WC.CONFIRMED = 0;

                        open APPLYTOCURSOR;
                        fetch next from APPLYTOCURSOR into @APPLYTOID;
                        while @@fetch_status = 0 begin
                            exec dbo.USP_WEALTHCAPACITY_UPDATE @APPLYTOID, @CHANGEAGENTID;
                            fetch next from APPLYTOCURSOR into @APPLYTOID;
                        end
                        --When a cursor is used, it should be explicitly closed/deallocated in case of blocking or USP running long

                        close APPLYTOCURSOR;
                        deallocate APPLYTOCURSOR;

                        return 0;