Subject | Re: The New command in triggers |
---|---|
Author | Adam |
Post date | 2006-02-16T00:18:50Z |
--- In firebird-support@yahoogroups.com, "Graeme Edwards"
<g.edwards@...> wrote:
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.
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.
are asking me if it is absolutely different to some known
field/variable. Again I can not answer a definite either way.
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
<g.edwards@...> wrote:
>not come
> Thanks for the further input from Milan and Adam.
>
>
>
> I have some further questions based on Milan's advice since I have
> across the concept of NULL in BooleanThe 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 unknown value = known value then ...
> If NULL=NOTNULL evaluates to NULL
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.
>Yes, same reasons. The first NULL field/variable is unknown, and you
> NULL<>NOTNULL also evaluate to NULL?
>
are asking me if it is absolutely different to some known
field/variable. Again I can not answer a definite either way.
>NULL?
> Does NULL within any Boolean expression such as
>
> IF ((Null OR False) and True) make the whole expression evaluate to
>well as
>
>
> Is it valid to test the result of a Boolean expression for NULL 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