cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with logic in SQL condition

former_member459477
Participant
0 Kudos

hi experts

I am trying to set up Stored procedure to prevent mistakes in discounts for BP on SO & QU.

I am struggling with getting query correct for my requirement.

This BP has 2 options for discount - discount must be either 5.5% or -5% (Null is not allowed either)

I think I understand problem is that the red condition below must always be TRUE therefore SP is always blocking.

but my knowledge of SQL is not adequate to correct this.

I have tried different operators 'NOT IN' and 'LIKE' but I am still unsuccessful

Please can someone advise solution?

IF (@object_type='17' OR @object_type='23') and @transaction_type IN ('A','U')

BEGIN

If Exists (Select T0.DocEntry from [dbo].[ORDR] T0 Inner Join RDR1 T1 On T0.DocEntry=T1.DocEntry

Where T0.DocEntry = @list_of_cols_val_tab_del AND (T1.DiscPrcnt != -5.00 OR T1.DiscPrcnt !=+5.50) AND T0.CardCode = 'CDBI002')

BEGIN

Select @error = -1,

@error_message = 'Remember special discount for this BP'

End

End

Thanks for any assistance

Regards,

karen

Accepted Solutions (1)

Accepted Solutions (1)

former_member186712
Active Contributor
0 Kudos

Hi Andrew,

Try this:

 

IF (@object_type='17' OR @object_type='23') and @transaction_type IN ('A','U')

 

BEGIN

If Exists (Select T0.DocEntry from [dbo].[ORDR] T0 Inner Join RDR1 T1 On T0.DocEntry=T1.DocEntry

Where T0.DocEntry = @list_of_cols_val_tab_del AND T0.CardCode = 'CDBI002' AND (T1.DiscPrcnt not in (-5, 5.5) ))

 

BEGIN

     Select @error = -1,@error_message  = 'Remember special discount for this BP' 

End

End

It works

Regards

former_member459477
Participant
0 Kudos

Thank you very much for assistance, this is now working correctly!

Regards,

Karen

Answers (0)