Subject Re: [firebird-support] unique constraint on a pair, one NOT NULL, one NULL
Author Helen Borrie
At 05:42 AM 6/05/2009, you wrote:
>I have a number of tables in which there are two fields:
>
>TEXTID CHAR(10) NOT NULL,
>ENDDATE TIMESTAMP NULL
>
>I need to put a unique constraint on the system so that there can only be one row with a given TEXTID and have an ENDDATE of NULL. Interbase 7.5 is not allowing me to create such a contraint. It is possible or must it be done in triggers?

In Firebird, since Fb 1.5, it has been possible to create a unique *index* that contains a nullable key that could be null for only one record in the table. (If you are interested, the rules are in the Fb 1.5 release notes.) However, Firebird does not allow a unique CONSTRAINT that contains nullable columns, since the purpose of a unique constraint is to provide an alternative key for foreign key references.

I don't know whether the nullability change was ever harvested into InterBase 7.5, which is closed source. This list is about Firebird. You need to use an appropriate Embarcadero newsgroup to find out about InterBase stuff.

./heLen