Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Let you guys please examine the following scenario:
I have a table called Salesman_customer and want to use this table for enter customers and their respective salesman, with a condition that. at a time a customer can belongs to only one salesman during a time period(eg:Customer A belongs to Salesman1 during 1-Oct-2010 to 30_Oct-2010, during this month(october) no other salesman can't Add A as his/her customer, but it is possible to add before October or after October )

Now please examine the condition:
1.A is a Customer of salesman1 From 1-Oct-2010 to ----

if the table contain record of case1. the users should not be able enter the record of following type

a. Can't enter A as customer during 1-Oct-2010 to -----
b.can't enter A as Customer during greater than October(becoz the TO_DATE) is null

I acheived this with the following query
SQL
AND ((MC_FM_DT >= :NEW.MC_FM_DT and MC_TO_DT <= :NEW.MC_TO_DT)
                        OR MC_TO_DT Is Null);

but my problem is am not able add A as a Customer for the period 1-Sep-2010 to 30-Sep-2010 with my query.when i try to enter like this it return message displaying record already exist but actually there is no such record.

Some one please help me to modify the query without violating the above condition(no change on the query but some addition).
Posted
Updated 25-Oct-10 7:02am
v3

1 solution

Currently MC_TO_DT is null in the Salesman_Customer table. The OR clause will always return true. If you still want to check for null then you will also want to make sure that the :NEW.MC_TO_DT is less than the MC_FM_DT as well.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900