Subject Re: CHECK Constraints (was: Re: [firebird-support] Re: Checking periods don't overlap)
Author Martijn Tonies
Hi John,

> My point is that check constraints should work in a way consistent
> with indexes, which at the moment they don't.

In the case that both of use tried, things are a bit different. The
same goes for the thing you put up at Sourceforge --

We were using "new.<column>" - now, this works, because
internally, a CHECK constraint gets implemented as two
triggers (BEFORE UPDATE and INSERT). Nevertheless,
I think this is the wrong approach and you should be able
to construct a valid constraint for a row without the NEW
thingy...

Something like:

not exists(select * from mytable
where mytable.pkcol <> current.pkcol
and mytable.uniquecol = current.uniquecol)

This is a different constraint that with the NEW thingy.

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com