Subject | Re: Odp: [firebird-support] Bug? Come back |
---|---|
Author | Kjell Rilbe |
Post date | 2014-05-07T08:26:36Z |
Kjell Rilbe skriver:
clauses. Also, note that boolean operators and and or always return NULL
if either operand is NULL and that operand has any significance in the
expression, so it's not until the entire expression is evaluated and a
yes/no decision HAS to be made, that NULL degenerates to false:
where NULL and true
will not return any records, because "NULL and true" evaluates to "NULL"
which then degenerates to false. But
where NULL or true
will return all records, because the expression will be true no matter
what the unknown value would be, so "NULL or true" evaluates to true.
Regards,
Kjell
>Sorry, that should be "case when..." not "if...". Same goes for where
> liviuslivius@... skriver:
> >
> > Hi,
> >
> > I back with this question. Is this really correct because after
> > discussion with team i have now doubt.
> >
> > We have here parenthesis. Any expression in parenthesis should be
> > first calculated
> > Then this is not test
> > NOT NULL - > NULL only
> > Not ( NULL -> NULL)
> >
>
> What do you mean with that last line "Not (NULL -> NULL)"?
>
> Think of "NULL" as "UNKNOWN" and add that if the value is forced to
> true/false NULL evaluates to false, the logic becomes rather intuitive:
>
> 1. "if NULL then 1 else 2 end" returns 2
>
> 2. "if not NULL then 1 else 2 end" returns 2 because "not NULL" is NULL
> and the expression degenerates to the same as example 1 above.
>
> Regards,
> Kjell
>
clauses. Also, note that boolean operators and and or always return NULL
if either operand is NULL and that operand has any significance in the
expression, so it's not until the entire expression is evaluated and a
yes/no decision HAS to be made, that NULL degenerates to false:
where NULL and true
will not return any records, because "NULL and true" evaluates to "NULL"
which then degenerates to false. But
where NULL or true
will return all records, because the expression will be true no matter
what the unknown value would be, so "NULL or true" evaluates to true.
Regards,
Kjell