ESQL provides the following logical operators:
- Operator AND
- The result is the logical AND of the two operands. Both operands
must be Boolean values.
- Operator OR
- The result is the logical OR of the two operands. Both operands
must be Boolean values.
- Operator NOT
- The result is the logical NOT of the operand, which must be a
Boolean value.
NULL and UNKNOWN values are treated as special values by these operators, according to the
following rules:
- NULL and UNKNOWN are treated the same.
- If an operand is NULL, the result is NULL unless the operation result is already dictated by the
other parameter.
The evaluation of the individual clauses in a statement that includes the AND or OR logical
operators is stopped as soon as the overall statement can be resolved. For example, see the
following statements:
IF A OR B THEN ...
- If A is false, B is evaluated.
- If A is true, B is not evaluated because the statement is already resolved to be true.
IF A AND B THEN ...
- If A is true, B is evaluated.
- If A is false, B is not evaluated because the statement is already resolved to be false.
The result of AND and OR operations is defined by the following table:
Value of P |
Value of Q |
Result of P AND
Q |
Result of P OR Q |
TRUE |
TRUE |
TRUE |
TRUE |
TRUE |
FALSE |
FALSE |
TRUE |
TRUE |
UNKNOWN |
UNKNOWN |
TRUE |
FALSE |
TRUE |
FALSE |
TRUE |
FALSE |
FALSE |
FALSE |
FALSE |
FALSE |
UNKNOWN |
FALSE |
UNKNOWN |
UNKNOWN |
TRUE |
UNKNOWN |
TRUE |
UNKNOWN |
FALSE |
FALSE |
UNKNOWN |
UNKNOWN |
UNKNOWN |
UNKNOWN |
UNKNOWN |
The result of NOT operations is defined by the following
table.
Operand |
Result of NOT |
TRUE |
FALSE |
FALSE |
TRUE |
UNKNOWN |
UNKNOWN |