Re: NULL peeve
Posted in 1993
->From: Jack Parker <jparker@hpbs2561.boi.hp.com> ->Subject: peeve ->To: informix-list@rmy.emory.edu (Informix Users Net) ->Date: Tue, 11 May 93 11:32:28 MDT -> ->I hate fixing a statement from: -> ->IF a != b THEN ..... -> ->TO -> ->IF a != b ->OR (a IS NULL AND b IS NOT NULL) ->OR (a IS NOT NULL AND b IS NULL ) THEN ..... -> ->Are there others out there with this prob? Or is it just us? -> ->Why is it that NULL is NOT EQUAL to "xxx", but it is not NOT EQUAL to "xxx" ->either? -> ->I'm not looking for the real answer, I'm looking for the explanation ->of why grunts like me have to deal with this when it's 'intuitively obvious ->to the most casual observer' that NULL should not not NOT EQUAL "xxx". -> 1 2 3 ->Even better, when is it going to be fixed? -> ->HP/UX 8.02 ->Online 5.0 ->ISQL/4GL 4.10.UD2 -> ->j. -> Sorry, Jack. Don't hold your breath waiting for this to be "fixed", since Informix does not consider it to be broken. In at least two places, User Guide 3-18 and Ref. Manual 2-18 (both version 4.00), Informix states that NULL values in Boolean expressions always evaluate to FALSE, except of course with the IS NULL keywords. It seems to me the problem comes from mapping three value TRUE/FALSE/NULL logic onto two value logic in an IF statement. Informix has chosen to map "expression with NULL" onto FALSE, even "a OR NOT a", which is normally tautologically true. (They even use this example.) Informix won't fix what they don't see as broken, but maybe we can get them to *enhance* the IF statement to include NULL logic, maybe like this: IF expression THEN statement(s) ELSE statement(s) NULL { or maybe ON NULL } statement(s) END IF With this enhancement, if the (ON) NULL part of the IF structure were omitted, then "expression with NULL" should still take the ELSE branch, for compatibility with existing programs. Regards, Alan +------------------------------+---------------------------------------+ | R. Alan Popiel | Internet: alan@den.mmc.com | | Martin Marietta, LSC | ( Please note: My opinions do not ) | | P.O. Box 179, M/S 5422 | ( represent official Martin policy. ) | | Denver, Colorado 80201-0179 | Voice: 303-977-9998 | +------------------------------+---------------------------------------+