Stored Procedures [dbo].[CheckForPreexistingContactInfoForSakariAccount]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@inSysUserIDint4
@inOrderPriKeyint4
@inSakariAccountPriKeyint4
@inProgrammaticPhoneNumbersVarChar16Listmax
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
create procedure [dbo].[CheckForPreexistingContactInfoForSakariAccount]
    @inSysUserID int,
    @inOrderPriKey int,
    @inSakariAccountPriKey int,
    @inProgrammaticPhoneNumbers VarChar16List readonly
as
begin
    set nocount on
    select
        ProgrammaticPhone = SakariContact.PhoneNumber,
        ContactPriKey = SakariContact.SakariContactID,
        UserIsSubscribedToContact = convert(bit, isnull(SakariContactSysUserMap.Subscribed,0)),
        ContactIsMappedToOrder = convert(bit, case when SakariContactOrderMap.OrderFID is null then 0 else 1 end),
        SakariContact.ContactName
    from @inProgrammaticPhoneNumbers inPhoneNumbers
    inner join SakariContact on
        SakariContact.SakariAccountFID = @inSakariAccountPriKey and
        inPhoneNumbers.Item = SakariContact.PhoneNumber
    left outer join SakariContactSysUserMap on
        SakariContact.SakariContactID = SakariContactSysuserMap.SakariContactFID and
        SakariContactSysuserMap.SysuserFID = @inSysUserID and
        SakariContactSysuserMap.Subscribed =  1
    left outer join SakariContactOrderMap on
        SakariContact.SakariContactID = SakariContactOrderMap.SakariContactFID and
        SakariContactOrderMap.OrderFID = @inOrderPriKey
end
GO
GRANT EXECUTE ON  [dbo].[CheckForPreexistingContactInfoForSakariAccount] TO [MssExec]
GO
Uses