NULL Values

Previous Next

Sybase and MS SQL Server differ from other RDBMS types in the way NULL values are handled. This can have an effect when writing constraints. (e.g. if you want to port).

On these RDBMS types, the following is sufficient to ensure that a constraint is only evaluated in case of UPDATES:

WHERE    OLD(VALUE) != VALUE

However, for transparency you are advised to write:

WHERE    OLD(VALUE) != VALUE

AND    OLD(KEY) IS NOT NULL

AND    KEY IS NOT NULL

 

The first AND clause ensures that INSERTS are excluded, the second AND clause ensures that DELETES are excluded.