Re: SQL Question: CHECK constraint or trigger?

From: Anne-Marie Ternes <anne-marie.ternes_at_cie.smtp.etat.lu>
Date: 1998/03/05
Message-ID: <34FEB220.EF84ED3_at_cie.smtp.etat.lu>#1/1


John Wiberg wrote:
> Try changing the check constraint to (CURRENT='Y'). That will allow
> values of 'Y' or NULL, NULL replacing 'N' in your application logic.
> Then add a unique key constraint on (NAMEID, CURRENT). This combination
> of constraints will allow one instance of NAMEID + 'Y' and multiple
> instances of NAMEID + NULL.

The last sentence is wrong. This method will not allow multiple instances of NAMEID + NULL, because this is the one and only exceptional case where NULL is equal to NULL. This is done by Oracle to enforce unique constraints.

Anne-Marie Ternes

anne-marie.ternes_at_cie.etat.lu Received on Thu Mar 05 1998 - 00:00:00 CET

Original text of this message