IN()
The IN()
operator compares an expression to a
list of values.
Syntax
IN ( expr [
,...]
)
- expr is any expression supported by the language.
Usage
The IN()
operator compares the left operand to all values specified in
the parenthesis. If one of the values matched, the operator evaluates to TRUE
.
The IN()
list can contain NULL
values. However, if the left
operand is NULL
, the IN()
expression evaluates to
NULL
. Use the IS NULL
operator to check if an expression is
NULL
.
Example
MAIN
DEFINE x INTEGER
LET x = 3
DISPLAY x IN(1,2,3) -- Shows 1
LET x = NULL
DISPLAY x IN(1,2,3) -- Evalutes to NULL
END MAIN
Typical usage examples:
IF SQLCA.SQLCODE IN (-231,-234,-345,100) THEN ...
CASE
WHEN cust_rec.cust_state IN ("CA","NY","WA") ...
WHEN cust_rec.cust_state IN ("AL","AK") ...
...
END CASE