Skip to Content
0
Feb 07, 2017 at 09:46 AM

prevent duplicate customer reference

532 Views

Hi all

I found this prevent Duplicate Vendor Reference for same Vendor stored proc from Balakumar useful.

Please advise how to modify it to apply to only one specific Customer?

if @object_type = '18'

and (@transaction_type = 'A' or @transaction_type = 'U')

Begin

declare @venno as varchar (100)

declare @vennam as varchar (100)

declare @apdate as datetime

if (@object_type = '18')

Begin

select @venno = NumAtCard, @vennam = CardCode, @apdate = DocDate from OPCH T0 where docentry = @list_of_cols_Val_tab_del

Begin

if (@venno is not null)

Begin

if 1!= (select count (docentry) from OPCH with (nolock)where (NumatCard = @venno) and (@apdate = DocDate) and (cardcode = @vennam))

Begin

select @error = 2

select @error_message = 'Duplicate Vendor Ref Number!'

End

End

End

End

End

Kedalene