Subject Re: [firebird-support] Check and null values
Author Helen Borrie
At 07:00 AM 20/04/2005 +0000, you wrote:

>Hi all,
>I'm trying to covert an old sqlanywhere database to firebird 1.5. The
>current database schema uses several checks on colums.
>I have the following problem, if there is a check on a column to check
>if a value is eg 1 or 2 and the column can have null values,
>sqlanywhere seems to accept null values, while firebird does not.
>Firebird wants to enforce the check, and discards the "can be null" thing?

No; but you have to specify NULL as an allowed option, viz.

CHECK (TheValue is null or TheValue in (1,2)). Of course, this check
constraint is not valid if the column TheValue is declared as NOT NULL.

>Is this correct? And is there some property that can disable this?
>I could also change my schema to include null in all checks, but what
>happens if I do that, and there is a column that has "not null"?

As I mentioned before, it is not valid the have a check constraint that
allows null on a non-nullable column. Think about it....