Boolean predicate

A Boolean predicate returns the truth value of a Boolean expression.

Read syntax diagramSkip visual syntax diagramboolean-expressionISNOTTRUEFALSE
boolean-expression
An expression that returns the Boolean value (or representation of a Boolean value) that is to be evaluated by the function. The data type of the returned value must be of one of the following data types (SQLSTATE 42884):
  • BOOLEAN
  • SMALLINT, INTEGER, BIGINT (binary integer)
  • DECFLOAT (floating decimal)
  • CHAR or VARCHAR (string)
  • GRAPHIC or VARGRAPHIC (graphic; applies only to a Unicode database)
Non-Boolean values are implicitly cast to Boolean values as described in Boolean values.

If the returned value is a string, it must be a valid representation of a Boolean value as described in Boolean values (SQLSTATE 22018).

Null values are treated differently by different predicates:
  • The IS TRUE predicate returns:
    • TRUE when the truth value of the value returned by input expression is TRUE
    • FALSE when the truth value is FALSE or NULL
  • The IS FALSE predicate returns:
    • TRUE when the truth value of the value returned by input expression is FALSE
    • FALSE when the truth value is TRUE or NULL
  • The IS NOT TRUE predicate returns:
    • TRUE when the truth value of the value returned by input expression is FALSE or NULL
    • FALSE when the truth value is TRUE
  • The IS NOT FALSE predicate returns
    • TRUE when the truth value of the value returned by input expression is TRUE or NULL
    • FALSE when the truth value is FALSE

Alternative syntax: The keyword ON can be used instead of TRUE; OFF can be used instead of FALSE.

Example

The following statement returns those values from COLA that are not equal to the corresponding value in COLX.
  SELECT COLA FROM TBLAB WHERE COLA = COLX IS NOT TRUE