Re: Null string comparison.
Posted in 1999
If A or B is null, then A=B will be false, but A<>B will also be false. You could use: 1) IF NOT (A=B) THEN LET lnCount=lnCount+1 ELSE DISPLAY "Same values" END IF or 2) IF A=B THEN DISPLAY "Same values" ELSE LET lnCount=lnCount+1 END IF (may affect performance slightly depending on which condition is more common) or 3) IF A<>B OR A IS NULL OR B IS NULL THEN LET lnCount=lnCount+1 ELSE DISPLAY "Same values" END IF or variations on these. Hope this helps. JouhShenToh@pg.SLR.com on 06/08/99 11:39:40 To: informix-list@iiug.org cc: (bcc: Sue Davidson/EXE) Subject: Null string comparison. If I have two char(1) variables A and B, I need to do some actions when the two variables differ. I used IF A<>B THEN LET lnCount=lnCount+1 ELSE DISPLAY "Same values" END IF When 1 of the variable is null, I will get "Same values" which is not true. How to overcome this null comparison problem? Thanks.