UFN_REGISTRATIONPACKAGEPRICE_VALIDCURRENCY

Validates that all event prices in the package have the same currency.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@REGISTRATIONPACKAGEID uniqueidentifier IN
@EVENTPRICEID uniqueidentifier IN

Definition

Copy


            create function dbo.UFN_REGISTRATIONPACKAGEPRICE_VALIDCURRENCY
            (
                @REGISTRATIONPACKAGEID uniqueidentifier = null,
                @EVENTPRICEID uniqueidentifier = null --Include EVENTPRICEID so the constraint is checked when it changes    

            ) 
            returns bit
            with execute as caller
            as
            begin                

                if 1 <
                (
                    select
                        count(*)
                    from
                        (
                            select distinct
                                EVENT.BASECURRENCYID
                            from
                                dbo.REGISTRATIONPACKAGEPRICE
                                inner join dbo.EVENTPRICE on REGISTRATIONPACKAGEPRICE.EVENTPRICEID = EVENTPRICE.ID
                                inner join dbo.EVENT on EVENTPRICE.EVENTID = EVENT.ID
                            where
                                REGISTRATIONPACKAGEPRICE.REGISTRATIONPACKAGEID = @REGISTRATIONPACKAGEID
                        ) as DISTINCTBASECURRENCY
                )
                    return 0;

                return 1;
            end