Subject Re: [firebird-support] Why NULL <> NULL ?
Author Paul Vinkenoog
Hi jasajona,

> In trigger I have:
> --
> if (field1 = field1) then ...
> --
> when field1 = null, field2 = null
> (field1 = field2) = false :(
> so I have to make an exception for null case, that is very ilogical.

It seems illogical, but it isn't.

Null means unknown. If field1 and field2 are both null, they are both
unknown. That is: their values are undefined.

Since you can't tell whether they are the same, the result of

field1 = field2

is also null. In an "if" construct, this has the same effect as false.

If you want to learn more about nulls, and find out about the best
workarounds, have a look at the Firebird Null Guide.

Paul Vinkenoog

PS: If you're running Firebird 2, use DISTINCT. The Null guide doesn't
cover this yet; consult the Release Notes.