Stored Procedures [rdld].[CheckCustomerNumber]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@inCustomerNumbervarchar(15)15
@inCustomerAddressCodevarchar(15)15
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
/****** Object:  StoredProcedure [rdld].[CheckCustomerNumber] ******/
-- =============================================
-- Author:     Jeff Spindler
-- Date: 1/26
-- Description:  Validates customer number/address code
-- Note:
--0 GetCustomerAddressInformation_Synonym] synonym               for [GetCustomerAddressInformation_Legacy]
--0 [GetCustomerAddressInformation_Legacy] table-valued function selecting on CustomerAddressInformation_Synonym where custnum & address code match (isnull to '')
--0 CustomerAddressInformation_Synonym     synonym               for CustomerAddressInformation_Legacy
--0 CustomerAddressInformation_Legacy      view                  selecting thru RM00101_Synonym and RM00102_Synonym which point to Corrigan's CMS database
-- =============================================
CREATE PROCEDURE [rdld].[CheckCustomerNumber]
@inCustomerNumber varchar(15),
@inCustomerAddressCode varchar(15)
AS
    BEGIN
        SET NOCOUNT ON;
        SET DEADLOCK_PRIORITY LOW;

        DECLARE    @customerNumberGood int;

        set @customerNumberGood = isnull( ( select 1 from dbo.GetCustomerAddressInformation_Synonym( @inCustomerNumber, isnull(@inCustomerAddressCode, '') ) ), 0 );

        if(@customerNumberGood = 1)
            BEGIN
                select 0 as ErrorCode, 'Customer Number good' as ErrorMessage for xml RAW;
            END
        ELSE
            BEGIN
                select 1 as ErrorCode, 'Customer Number, Address Code ' + @inCustomerNumber + ', ' + @inCustomerAddressCode + ' not found' as ErrorMessage for xml RAW;
            END

    END
GO
GRANT EXECUTE ON  [rdld].[CheckCustomerNumber] TO [MssExec]
GO
Uses