IS NULL

The IS NULL operator checks for NULL values.

Syntax

expr IS [NOT] NULL
  1. expr can be any expression supported by the language.
  2. The NOT keyword negates the comparison.

Usage

The IS NULL operator can be used to test whether the left-hand expression is null, while IS NOT NULL operator can be used to test for non-null values.

This operator applies to expressions that evaluate to primitive data types such as INTEGER, VARCHAR, DATE. It does not apply to the BYTE and TEXT types.

Structured variables defined with RECORD, DYNAMIC ARRAY, DICTIONARY types cannot be used with the IS [NOT] NULL operator.

Always use the IS [NOT] NULL operator to check for nulls: Comparing an expression to NULL with the == or != operators evaluates to NULL, which is not TRUE. The next code example displays twice the value 1/TRUE, because both sub-expressions using the equal and not equal operators evaluate to NULL:
MAIN
  DEFINE s STRING
  LET s = NULL
  DISPLAY ( (s != NULL) IS NULL )
  DISPLAY ( (s == NULL) IS NULL )
END MAIN

Example

MAIN
  DEFINE n INTEGER
  LET n = NULL
  IF n IS NULL THEN
     DISPLAY "The variable is NULL."
  END IF
END MAIN