Subject Re: The New command in triggers
Author Adam
--- In firebird-support@yahoogroups.com, "Graeme Edwards"
<g.edwards@...> wrote:
>
> Thanks for the further input from Milan and Adam.
>
>
>
> I have some further questions based on Milan's advice since I have
not come
> across the concept of NULL in Boolean
>

The 99% of the time way to think of NULL is as "unknown". It is a
reference to the state of a field or variable, not a value of the
field or variable. (ie it is a flag on a variable). It is confusing
because the SQL standard says that you can assign a value to NULL
using and =

update table set field = null;

or provide it as a field in an insert

insert into table (field) values (null);

etc, but the trick is to not think of it as a value, but just as a
flag that says that you have no idea about the value in the
particular record. When used inside IF statements, they ask for a
mathematical answer to the question. Where NULL is involved in a
comparison, you cant give an answer because it is possible that the
statement could be true or false depending on what the value actually
is when it is discovered.

>
> If NULL=NOTNULL evaluates to NULL

IF unknown value = known value then ...

Well it might, then again it might not, the result is unknown. It can
not be said to be true, but then again it cant be said to be false
either.

>
> NULL<>NOTNULL also evaluate to NULL?
>

Yes, same reasons. The first NULL field/variable is unknown, and you
are asking me if it is absolutely different to some known
field/variable. Again I can not answer a definite either way.
>
> Does NULL within any Boolean expression such as
>
> IF ((Null OR False) and True) make the whole expression evaluate to
NULL?
>
>
>
> Is it valid to test the result of a Boolean expression for NULL as
well as
> true and false?

Yes.

It goes even further than that with string manipulation

FullName = FirstName || ' ' || MiddleName || ' ' || LastName;

Is quite a frequent function. If MiddleName is null however,

FullName = FirstName_<NULL>_LastName; (_ meaning space)

FullName is therefore a string with an unknown string in the middle
of it, therefore NULL.

Read the Firebird NULL Guide and you should be fine.
http://www.firebirdsql.org/manual/nullguide.html

Adam