NVL()
The NVL()
operator
returns the second parameter if the first argument evaluates to NULL
.
Syntax
NVL( main-expr, subst-expr )
- main-expr and subst-expr are any expression supported by the language.
Usage
The NVL()
operator evaluates the first argument, and returns the result if the
value is not null, otherwise it returns the second argument.
This allows you to write the equivalent of the following IF
statement, in a simple scalar expression:
IF main-expr IS NOT NULL THEN
RETURN main-expr
ELSE
RETURN subst-expr
END IF
Example
MAIN
DEFINE var VARCHAR(100)
LET var = arg_val(1)
DISPLAY "The argument value is: ", NVL(var, "NULL")
END MAIN