UFN_NAMINGOPPORTUNITY_GETREMAINING

Gets the number of remaining naming opportunities.

Return

Return Type
int

Parameters

Parameter Parameter Type Mode Description
@QUANTITY int IN
@NAMINGOPPORTUNITYID uniqueidentifier IN

Definition

Copy


            CREATE function dbo.UFN_NAMINGOPPORTUNITY_GETREMAINING
            (
                @QUANTITY int,
                @NAMINGOPPORTUNITYID uniqueidentifier
            )
            returns int
            as
            begin
                declare @REMAINING int;
                declare @USED int;

                set @USED = (select coalesce(sum(QUANTITY), 0)
                             from NAMINGOPPORTUNITYRECOGNITION
                             where NAMINGOPPORTUNITYID = @NAMINGOPPORTUNITYID);

                set @REMAINING = @QUANTITY - @USED;

                return @REMAINING

            end