Name
logical_and, logical_or, logical_not — n-ary Boolean operators with SQL three-valued logic
Synopsis
integer logical_and(
|
in arg1 any, |
... ); |
integer logical_or(
|
in arg1 any, |
... ); |
integer logical_not(
|
in arg any); |
Description
These functions implement n-ary Boolean operators that follow SQL's
three-valued logic. They are aliases for the internal
__and, __or and
__not BIFs and accept any number of arguments (one
for logical_not).
: logical_and returns 1 if every argument is non-zero, 0 if any argument is zero, NULL if any argument is SQL NULL and no argument is zero.
: logical_or returns 1 if any argument is non-zero (non-NULL), 0 if every argument is zero, NULL if any argument is SQL NULL and no argument is non-zero.
: logical_not returns 0 if the argument is non-zero, 1 if zero, NULL if SQL NULL.
Unlike the SQL AND, OR and
NOT operators, these can be referenced as functions and
used in contexts such as SELECT lists, expression
contexts, and dynamic SQL.