USP_CONSTITUENTDATAREVIEW_PHONE_CHECKGUIDS

Checks the values of foreign key fields during rollback in constituent data review.

Parameters

Parameter Parameter Type Mode Description
@INVALIDFIELDS nvarchar(256) INOUT
@PHONETYPECODEID uniqueidentifier INOUT
@INFOSOURCECODEID uniqueidentifier INOUT
@COUNTRYID uniqueidentifier INOUT
@DONOTCALLREASONCODEID uniqueidentifier INOUT

Definition

Copy


create procedure dbo.USP_CONSTITUENTDATAREVIEW_PHONE_CHECKGUIDS (
    @INVALIDFIELDS nvarchar(256) output,
    @PHONETYPECODEID uniqueidentifier = null output,
    @INFOSOURCECODEID uniqueidentifier = null output,
    @COUNTRYID uniqueidentifier = null output,
    @DONOTCALLREASONCODEID uniqueidentifier = null output
)
as
begin
    declare @C tinyint;

    set @INVALIDFIELDS = '';

    if @PHONETYPECODEID is not null
    begin
        select @C = count(*)
        from dbo.PHONETYPECODE
        where ID = @PHONETYPECODEID;

        if @C = 0
        begin
            set @INVALIDFIELDS = @INVALIDFIELDS + ',Type';
            set @PHONETYPECODEID = null;
        end
    end

    if @INFOSOURCECODEID is not null
    begin
        select @C = count(*)
        from dbo.INFOSOURCECODE
        where ID = @INFOSOURCECODEID;

        if @C = 0
        begin
            set @INVALIDFIELDS = @INVALIDFIELDS + ',Information source';
            set @INFOSOURCECODEID = null;
        end
    end

    if @COUNTRYID is not null
    begin
        select @C = count(*)
        from dbo.COUNTRY
        where ID = @COUNTRYID;

        if @C = 0
        begin
            set @INVALIDFIELDS = @INVALIDFIELDS + ',Country';
            set @COUNTRYID = null;
        end
    end

    if @DONOTCALLREASONCODEID is not null
    begin
        select @C = count(*)
        from dbo.DONOTCALLREASONCODE
        where ID = @DONOTCALLREASONCODEID;

        if @C = 0
        begin
            set @INVALIDFIELDS = @INVALIDFIELDS + ',Do not call reason';
            set @DONOTCALLREASONCODEID = null;
        end
    end

    if @INVALIDFIELDS <> ''
        set @INVALIDFIELDS = substring(@INVALIDFIELDS,2,len(@INVALIDFIELDS)-1);
end