USP_BBNC_CODETABLE_GETTABLENAME

Retrieves a code table name for the specified Blackbaud Internet Solutions integer value.

Parameters

Parameter Parameter Type Mode Description
@TABLEID int IN

Definition

Copy


            CREATE procedure [dbo].[USP_BBNC_CODETABLE_GETTABLENAME](@TABLEID int)
            as
                set nocount on;

                declare @TABLENAME sysname;
                declare @TABLESPECID uniqueidentifier;

                select @TABLESPECID = 
                    case @TABLEID
                        when -1005 -- Event Category

                            then 'B328E14B-9269-4B6C-BF93-7B10C70F71C3' --JamesWill 04/18/2008 CR295896-031408


                        when -1        -- EMailAddressType (this was a phone type in RE7)

                            then 'E0473233-93ED-4509-9C42-65E037405497'

                        when 6        -- Degree

                            then 'EBD199A9-14A7-40BD-8367-5AE91C788796'

                        when 7        -- TributeTypes

                            then '0D804830-26F1-4FCB-B833-AB00BB73ED9D'

                        when 41        -- ConstituentNoteType

                            then 'E2373A71-2F76-4beb-BCF9-58740AE32320'

                        when 43        -- Constituent Code

                            then 'C5B35C5A-7EF0-47C6-AA54-7A1FDF32FDA1'

                        when 47        --Name Format Type

                          then '81361861-CED3-4484-AB1E-A1B77A37247F'

                        when 4999    -- ConstituentInterests (this is some sufficiently high number)

                            then '0C51D76A-D06C-4A63-88B6-4104BE00D11C'                            

                        when 5002 -- Credit Cards

                            then 'D428EFCD-A5C7-45FA-8F34-444FDE67B05C'

                        when 5005    -- IndustryCode

                            then '7DF7C84F-84DB-4620-B620-76B4A2F67581'

            when 5006 -- Primary Business Profession (SHL)

                          then 'DBA845EF-6ABA-40DC-8A81-756C9F0D289A'    

                        when 5008    -- Relationship type

                            then 'F4ADA947-98CE-4D74-A667-101B8961AD93' --JamesWill 05/12/2008 CR299619-050108 


                        when 5011    -- SchoolType

                            then '21E9B83D-86BF-4240-BB51-112319E15FE9'

                        when 5012    -- Suffixes

                            then 'DC8EF6F2-3A35-445D-AFCB-B913604CC322'

                        when 5013    -- Titles

                            then '456FFD4C-0FBF-49DB-A503-0726F86E2A39'

                        when 5014    -- PhoneType

                            then 'D57063E8-9DEA-4651-90A7-F86FE010AFC3'

                        when 5018    -- MaritalStatus

                            then '7FB9DF6B-0411-43E8-B423-1D49AFE244D9'

                        when 5039    -- Campaign Category (DesignationLevelCategoryCode)

                            then '20204242-BA0F-4788-8A88-B235946EBECF'

                        when 5079    -- MajorMinor

                            then '651168BA-BB5F-49AF-B382-E2DDD6883149'

                        when 5080    -- EducationStatus

                            then '3FF85832-81E5-4B22-94D4-99F84D4CF78A'

                        when 5042 -- AppealCategory 

                            then 'DC960DFB-6FAF-4dbf-B3B9-6707BB3A8D7C'

                        when 5100 -- Fund Types (CampaignTypeCode)

                            then 'FA498618-5E94-4E1D-B30E-EA1F0DD95C3A'                            

                        when 5101 -- Career Level

                            then '65A81A1F-4C0D-4DB3-A5DB-2557E2AEA3B1'                            

                        when 5102 -- Profession

                            then 'DBA845EF-6ABA-40DC-8A81-756C9F0D289A'                            

                        when 5103 -- Industry

                            then '7DF7C84F-84DB-4620-B620-76B4A2F67581'                            

                        when 5104 -- Schedule

                            then '096B2584-D486-411A-88CA-DBD83CB5C45F'                                          

                        when 5105 -- Region

                            then 'F0E0E2C1-F53E-45D0-9108-5FF336DA93CE'

            when 68 -- Gender

                            then 'BE6BD11C-D5CA-4D51-92BD-BAC9E34AFE86'
                        else
                            null
                    end;

                if @TABLESPECID is null and @TABLEID >= 6000
                    select 
                        @TABLESPECID = CODETABLECATALOGID
                    from 
                        dbo.BBNCCODETABLECATALOGIDMAP 
                    where 
                        ID = @TABLEID;

                if @TABLESPECID is null
                    begin
                        declare @ERR nvarchar(max);
                        if @TABLEID is not null
                            set @ERR = 'The specified code table id (' + convert(nvarchar(20),@TABLEID) + ') has not been defined in USP_BBNC_CODETABLE_GETTABLENAME.'
                        else
                            set @ERR = 'The specified code table id has not been defined in USP_BBNC_CODETABLE_GETTABLENAME.';

                        raiserror (@ERR,13,1);
                        return 0;
                    end

                select 
                    @TABLENAME = DBTABLENAME
                from
                    dbo.CODETABLECATALOG
                where
                    CODETABLECATALOG.ID = @TABLESPECID;

                if @TABLENAME is null
                    begin
                        raiserror ('Unknown code table specified.',13,1);
                        return 0;
                    end

                select @TABLENAME as TABLENAME;