Subject Re: [firebird-support] null in triggers
Author Alexandre Benson Smith
At 00:58 17/09/2003 +0200, you wrote:

>Hi Alexandre,
> > if (New.Quantity <> Old.Quantity) or
> > ((New.Quantity is null) and (Old.Quantity is not null)) or
> > ((New.Quantity is not null) and (Old.Quantity is null))
>You can make this shorter:
> if not ( New.Quantity = Old.Quantity
> or
> New.Quantity is null and Old.Quantity is null )

Sometimes (or in almost all cases) I try to make the code more readable so
I don't even tried to reduce the boolean sentence, of course your sugestion
is shorter and more elegant, but I think it does not show in a first glance
what it is supposed to do (since it inverts the original question)... But
it's perfect and smarter than my code

>Now if you know the laws of De Morgan, you might be tempted to
>reformulate the inequality test like this:
> ( A <> B ) and ( A is not null or B is not null )
>Don't do that! SQL's null handling BREAKS boolean logic. If A is null
>and B isn't, the above test returns false. The test starting with
>"not" does exactly what you want.

Good point!

As I said above I would prefer this sentence instead of the other (the one
with "not") once it does not invert the question. But it does not work
(better, "work as designed" but fails to test what I want)... :-(

Masters, the function "updated" could be a feature request ?

By the way, Firebird does complete boolean evaluation ? (since my English
is terrible I think showing code more "readable" than my English)

if (A > B) and (A < C)

if "A" is less than or equal to "B" firebird continues to evaluate the rest
of the expression or just stops and go to "else"

if (A > B) or (A < C)

if "A" is greater than "B" firebird continues to evaluate the rest of the
expression or just stops and go with a true result for the entire
expression, since (A < C) is not relevant to the result ?

Alexandre Benson Smith
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
Version: 6.0.514 / Virus Database: 312 - Release Date: 28/08/2003

[Non-text portions of this message have been removed]