Subject Re: [firebird-support] Re: The New command in triggers
Author Milan Babuskov
Christian Danner wrote:
> So if the number of comparisons really matters (3:5):
>
> if (not( ( (old.field is null)
> and (new.field is null))
> or (old.field = new.field)))
> then
> ...

Not good.

Take for example if old.field is NULL and new.field is not NULL.

step 1:
> if (not( ( (NULL is null)
> and (NOTNULL is null))
> or (old.field = new.field)))

step 2:
> if (not( ( TRUE
> and FALSE)
> or (old.field = new.field)))

step 3:
> if (not( (FALSE)
> or (old.field = new.field)))

step 4:
> if (not( (FALSE)
> or (NULL = NOTNULL)))

step 5:
> if (not( (FALSE)
> or (NULL)))

step 6:
> if (not( NULL))

step 7:
> if (NULL)

The expression doesn't evaluate to TRUE, so body will not execute.


One of the main problems people encounter is that not(null) does not
give TRUE, but rather NULL.

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