On Sat, 20 Sep 2003 18:55:34 -0400, Kevin Houle <kevin@houle.org>
wrote:
> SELECT INTO result * FROM table_rates WHERE
> effective_date >= NEW.effective_date AND
> expiry_date <= NEW.expiry_date AND
> cost = NEW.cost;
> IF FOUND THEN
> RAISE EXCEPTION ''record overlaps with existing record'';
> END IF;
This only catches complete inclusion of an old range in the new one. new b---------------------e old
b--------------e
TryWHERE effective_date < NEW.expiry_date AND expiry_date > NEW.effective_date
which also detects new b--------------------e old b-------------------e old
b------------------e old b--------------------------------e
ServusManfred