Language Reference Guide : 2. Language Elements : Expressions : Nulls in Expressions
 
Share this page                  
Nulls in Expressions
Because a null cannot be compared to another value, the only test that you can perform is to see whether it is null or not. To perform this test, use the is null or is not null operator in a conditional expression. For more information, see Is [Not] Null Operator.
If any item (other than a reference variable) in an expression has a null value, the value of the entire expression is null, for example:
msg = varchar (empno) +
    ' is not a valid employee number';
In this expression, if the variable empno has the value null, msg is null after the statement executes.
If any of the simple variables is null, the result of any comparison involving them is null, for example:
count = null;
if count + 1 > 0 then
    callframe newproject;
endif;
Because count is null, the result of the comparison that includes count is null. Therefore, the callframe statement is never executed.
This rule holds true for more complicated expressions, as in the following statements:
man_days = varchar(days) + 'days';
if (start_date + man_days) > 'today' then
    /* processing statements */
endif;
If start_date or man_days is null, the entire boolean expression evaluates to null and the processing statements are never performed.