Subject | RE: [firebird-support] Re: The New command in triggers |
---|---|
Author | Helen Borrie |
Post date | 2006-02-16T03:02:19Z |
At 10:31 AM 16/02/2006, you wrote:
result will be true if the condition is met and false otherwise. An
UNKNOWN result in Firebird resolves to a result of False, not NULL.
In many expressions, the result of a calculation involving NULL and
value will return NULL, representing an UNKNOWN result.
doesn't exist) and you meant that both tests were predicates for IF,
then, in both cases, they will evaluate to False, not NULL.
The predicates IS NULL and IS NOT NULL exist. Both return True or
False to the engine but there is no output result of True or False
returned to the caller.
However, to partly answer your question, Boolean evaluation works
from left to right and from inner conditions to outer conditions.
false and can never be "NULL". The flow of execution proceeds
directly from the result of the test, viz.
If (New.ID=Old.ID) then .. Whatever
Firebird doesn't support a Boolean type, per se. You can predicate a
result for further reference by declaring and setting a variable to
store something you will later use as a reference to the result of your test.
declare variable IsTrue smallint = 0;
....
If (New.ID=Old.ID) then
begin
IsTrue = 1;
...
...
if (IsTrue = 0) then .. Whatever
...
end
If you want to return a Boolean result from a stored procedure,
define an output variable of your preferred type for Boolean use,
assign a value to it according to your IF (..) result and return that.
./heLen
>I have some further questions based on Milan's advice since I have not comeBut you might have heard of UNKNOWN? In Boolean evaluation, the
>across the concept of NULL in Boolean evaluation before.
result will be true if the condition is met and false otherwise. An
UNKNOWN result in Firebird resolves to a result of False, not NULL.
In many expressions, the result of a calculation involving NULL and
value will return NULL, representing an UNKNOWN result.
>Assuming you meant to say "a value" rather than NOTNULL (which
>If NULL=NOTNULL evaluates to NULL does
>
>NULL<>NOTNULL also evaluate to NULL?
doesn't exist) and you meant that both tests were predicates for IF,
then, in both cases, they will evaluate to False, not NULL.
>Does NULL within any Boolean expression such asThere is no such syntax and there are no predicates named as False and True.
>
>IF ((Null OR False) and True) make the whole expression evaluate to NULL?
The predicates IS NULL and IS NOT NULL exist. Both return True or
False to the engine but there is no output result of True or False
returned to the caller.
However, to partly answer your question, Boolean evaluation works
from left to right and from inner conditions to outer conditions.
>Is it valid to test the result of a Boolean expression for NULL as well asNo. For one thing, the result of the inner test is either true or
>true and false?
>
>Eg.
>
>If (New.ID=Old.ID) is Null then .. Whatever
false and can never be "NULL". The flow of execution proceeds
directly from the result of the test, viz.
If (New.ID=Old.ID) then .. Whatever
Firebird doesn't support a Boolean type, per se. You can predicate a
result for further reference by declaring and setting a variable to
store something you will later use as a reference to the result of your test.
declare variable IsTrue smallint = 0;
....
If (New.ID=Old.ID) then
begin
IsTrue = 1;
...
...
if (IsTrue = 0) then .. Whatever
...
end
If you want to return a Boolean result from a stored procedure,
define an output variable of your preferred type for Boolean use,
assign a value to it according to your IF (..) result and return that.
./heLen