Thanks anacedent.
I apologize that my previous post was not clear at all. I was under stress and did not revise what I wrote. Also I am new to this forum and did not know how to use the code tag.
There was a bug in the source code and someone dropped date overlap validation.
The rule is that:
* One service must end before new one start.
* Customer can have only one current service. Current service is a service with null end date or end date is in future.
The code has been fixed but I need to cleanse the database.
This is an example of current database.
Code:
CUSTNUM START_DATE END_DATE SERVICE
------- ---------- --------- ---------
A 18-JUL-08 27-SEP-09 RCBR1
A 28-SEP-09 09-MAR-10 RCBR2
A 10-MAR-10 09-JUL-10 RCBR3
A 01-JUL-10 (Null) RCBR4
B 05-JAN-09 09-JAN-09 RCBR1
B 10-JAN-09 (Null) RCBR2
B 01-JUL-10 (Null) RCBR3
...
...
Problem: Customer A's service 3 ends on 09-JUL-10 but service 4 starts on 01-JUL-10. It means that customer A has two services (3 and 4). Customer B has two open-ended services. Service 2 must have end date prior to the start date of service 3.
It was agreed with business that the end date of overlapping services would he one day before the next service start date. Therefore the fields need to be modified to:
Code:
CUSTNUM START_DATE END_DATE SERVICE
------- ---------- --------- ---------
A 18-JUL-08 27-SEP-09 RCBR1
A 28-SEP-09 09-MAR-10 RCBR2
A 10-MAR-10 30-JUN-10 RCBR3
A 01-JUL-10 (Null) RCBR4
B 05-JAN-09 09-JAN-09 RCBR1
B 10-JAN-09 30-JUN-10 RCBR2
B 01-JUL-10 (Null) RCBR3
I would really really be appreciated if you could give me an insight with your knowledge.
Regards,
Peter