Subject | Re: [firebird-support] null in triggers |
---|---|
Author | Ivan Prenosil |
Post date | 2003-09-18T13:11:12Z |
> From: "Paul Vinkenoog"Wrong.
> > 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 )
...
> PS:If A is regular value and B is NULL, the result will be NULL ...
> Shortest general field equality test (with NULL considered equal to
> NULL) that I've been able to come up with is:
>
> A = B or A is null and B is null
>
> or with parens:
>
> ( A = B ) or ( A is null and B is null )
> The shortest inequality test is just the negation of this:... and hence negation of null is also NULL !!
>
> not ( A = B or A is null and B is null )
It is possible to write e.g.
IF ( New.Quantity = Old.Quantity OR New.Quantity is null and Old.Quantity is null )
THEN ... equal
ELSE ... not equal
but you can't reduce it into
IF (NOT ( New.Quantity = Old.Quantity OR New.Quantity is null and Old.Quantity is null ))
THEN ... not equal
Ivan Prenosil
http://www.volny.cz/iprenosil/interbase