It is important to note the restrictions on the Boolean
data type before you use it or when troubleshooting problems with
their use.
The following restrictions apply to the boolean data type:
- The Boolean data type can only be referenced as:
- Local variables declared in SQL functions
- Local variables declared in SQL procedures
- Local variables declared in triggers with a compound SQL (compiled)
statement as trigger body
- Parameter to SQL functions with a compound SQL (compiled) statement
as function body
- Parameter to SQL procedure with a compound SQL (compiled) statement
as procedure body
- Return type
- Global variable in a module
- The Boolean data type cannot be used to define the data type of
a column in a table or view.
- The system-defined values TRUE and FALSE cannot be referenced
as values to be inserted into a table.
- The Boolean data type cannot be referenced in external routines
or client applications.
- The Boolean data type cannot be cast to other data types.
- The Boolean data type cannot be returned as a return code value
from an SQL procedure.
- Variables of the Boolean data type can only be assigned one of
the following values: TRUE, FALSE, or NULL. Numeric or other data
type assignments are not supported.
- Selecting or fetching values into variables of the Boolean data
type is not supported.
- The Boolean data type cannot be returned in a result set.
- A Boolean variable cannot be used as a predicate. For example,
the following SQL clause is not supported:
IF (gb) THEN ...
Use of predicates is only supported in the SET statement
and RETURN statement from a UDF.
If these restrictions prevent you from using this data type consider
using an integer data type instead and assign it values such as 1
for TRUE, 0 for FALSE, and -1 for NULL.