Subject Re: [firebird-support] Re: The New command in triggers
Author Milan Babuskov
Adam wrote:
> If you consider NULL = NULL for the purpose of comparison, then you
> will need to check each field like this.
>
> IF ((OLD.FIELD <> NEW.FIELD) OR
> (OLD.FIELD IS NOT NULL AND NEW.FIELD IS NULL) OR
> (OLD.FIELD IS NULL AND NEW.FIELD IS NOT NULL)) THEN .....

I believe this has to be done the other way around. First check for
NULLs, and then the values. The reason is that expression is evaluated
from left to right. So, if one of the values is NULL, you get:

NULL or TRUE

or

NULL or FALSE or TRUE

In any case, the final result in NULL, meaning that IF clause won't get
executed.

If you check for NULLs first, it runs into TRUE and stops the further
checking.


--
Milan Babuskov
http://njam.sourceforge.net
http://www.flamerobin.org