constraint that prevents overlapping
200754Jan 8 2005 — edited Jan 10 2005Hi all,
Can I write a trigger on a table that prevents overlapping among period dates when insert or update?
For example:
Table1
Col1 number,
D1 date, -- start date of a period
D2 date, -- end date of a period
if data in the table are
1 1-1-05 30-1-05
2 1-3-05 31-3-05
then
the following insert will fail because it overlaps with period of first row:
3 3-1-05 10-2-05
the following insert will fail because it overlaps with period of second row:
3 20-2-05 10-4-05
whears the following insert will succeed it won't overlap with any of existing rows:
3 2-2-05 10-2-05
I hope to find any kind of solutions that can be implemented in the database side.
Thank in advance.