AND

The AND operator is the logical intersection operator.

Syntax

bool-expr AND bool-expr
  1. bool-expr is a boolean expression.

Usage

The AND operator is used to perform a logical conjunction on two boolean expressions.

Possible values of the operands are TRUE, FALSE and NULL. If one of the operands is NULL, the logical AND expression evaluates to NULL or FALSE, depending on the value of the second operand:
  • The result of AND is TRUE, if both operands are TRUE.
  • The result of AND is FALSE, if one of the operands is FALSE and the other operand is TRUE, FALSE or NULL.
  • The result of AND is NULL, if one of the operands is NULL and the other operand is NULL or TRUE.

By default, the runtime system evaluates both operands on the left and right side of the AND keyword. This is the traditional behavior of the Genero language, but in fact the right operand does not need to be evaluated if the first operand evaluates to FALSE. This method is called short-circuit evaluation, and can be enabled by adding the OPTIONS SHORT CIRCUIT clause at the beginning of the module.

Example

MAIN
    DISPLAY "T&T: ", NVL( TRUE AND TRUE, "NULL" )
    DISPLAY "T&F: ", NVL( TRUE AND FALSE, "NULL" )
    DISPLAY "T&N: ", NVL( TRUE AND NULL, "NULL" )
    DISPLAY "F&T: ", NVL( FALSE AND TRUE, "NULL" )
    DISPLAY "F&F: ", NVL( FALSE AND FALSE, "NULL" )
    DISPLAY "F&N: ", NVL( FALSE AND NULL, "NULL" )
    DISPLAY "N&T: ", NVL( NULL AND TRUE, "NULL" )
    DISPLAY "N&F: ", NVL( NULL AND FALSE, "NULL" )
    DISPLAY "N&N: ", NVL( NULL AND NULL, "NULL" )
END MAIN
Output:
T&T:      1
T&F:      0
T&N: NULL
F&T:      0
F&F:      0
F&N:      0
N&T: NULL
N&F:      0
N&N: NULL