Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

constraint that prevents overlapping

200754Jan 8 2005 — edited Jan 10 2005
Hi 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 7 2005
Added on Jan 8 2005
10 comments
7,085 views