Subject Re: clearing comboBox in grid does not produce NULL
Author Marco Menardi
--- In IBObjects@yahoogroups.com, "scronkey" <nilsson@b...> wrote:
> Thanks for the reply,
>
> After further investigation, I have realised that it IS setting the
> field to NULL when I clear the combobox.
>
> The only way to detect it though, is through
> IF (new.STK_ID IS NULL) THEN
> ...
>
> But why doesn't IF (old.STK_ID <> new.STK_ID) THEN
>
> work?
>
> I don't really want to explicitly test for NULL, I just want to
> react when the value changes.
> And going from a value to NULL, to my knowledge, is a change.
> But it is not being picked up like this.
>
> Any ideas why IF (new.STK_ID IS NULL) works, but the other option
> does not?
>
> Is it because, like you said, NULL is a state not a value, and you
> cannot compare a value with a state?
>
> Is my only option to explicitly test for NULL first?
>
> -Ryan
>

That's because NULL is considered a state (so can't be compared with
values) and also a value (if you use the value syntax, like myfield =
NULL).
This originates a lot of misunderstanding upon how manage fields "values".
In the FB developer forum has be suggested to introduce a new
comparison operator, like "==", that will consider and compare NULL as
a value to override the above problems.
Until then (and I don't know if it will be introduced, since some
"purist" does not want it, but this is another story) you must use
something like this to catch field OLD/NEW changes:
not ( A = B or ((A is null) and (B is null)) )

and beware this situation too:
( A = B ) <==> not ( A <> B )
doesn't hold as soon as nulls are involved!

regards
Marco Menardi