Was this helpful?
Nulls in Expressions
Because the NULL value cannot be compared to another value, the only test you can perform is to check whether a value is NULL or not. To test this, use the IS NULL and IS NOT NULL operators in a conditional statement. The syntax is similar to that of any other comparison operator:
[expression] is [not] null
Here is an example:
if salary is null then
    message 'Salary amount is unknown.';
endif;
Nulls in expressions follow these general rules:
If any item in an expression has a NULL value, then the value of the entire expression is NULL.
In the following example, if the variable empno has the value Null, then msg has the value Null after the statement is executed:
    msg := char (empno) + 
        ' is not a valid employee number';
If any of the variables contain a Null value, then the result of any comparison involving them is Unknown.
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 Unknown; hence, the callframe statement is not performed.
This rule holds true for more complicated expressions, as in the following statements:
    man_days := char(days) + ' days';
    if (start_date + man_days) > 'today' then
        statements
    endif;
If start_date or man_days has a Null value, then the entire Boolean expression evaluates to Unknown. Again the "statements" are not performed.
Last modified date: 08/28/2024