Subject Re: The New command in triggers
Author Adam
--- In firebird-support@yahoogroups.com, Christian Danner
<christian@...> 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
> ...
>
> Christian
>

Milan was right, I forgot about the null OLD=NEW resolving to NULL in
some cases. Of course if you use his selection you must make sure
CompleteBooleanEvaluation = 0 in firebird.conf (this is the default btw).

Personally I think this probably needs some attention. It is a common
problem and given triggers are not supported on a field by field
level, perhaps a function like

FieldChanged(FIELD) could return true if

a) NULL state was different between OLD and NEW; or
b) Value was different if both not null

So then the logic would be:

IF FIELDCHANGED(MYFIELD) THEN ....
ELSE ....

Adam