TO_BOOLEAN
Purpose
Use TO_BOOLEAN
to explicitly convert character value expressions or numeric value expressions to boolean values.
If expr
is a string, it must evaluate to the allowed string inputs. See Table 2-6.
expr
can take one of the following types, or null:
-
A character string of type
CHAR
,VARCHAR2
,NCHAR
,NVARCHAR2
-
A numeric value of type
NUMBER
,BINARY_FLOAT
, orBINARY_DOUBLE
-
A boolean value of type
BOOLEAN
.
Examples
SELECT TO_BOOLEAN(0), TO_BOOLEAN('true'), TO_BOOLEAN('no');
The output is:
TO_BOOLEAN( TO_BOOLEAN( TO_BOOLEAN( ----------- ----------- ----------- FALSE TRUE FALSE
SELECT TO_BOOLEAN(1) FROM DUAL;
The output is:
TO_BOOLEAN( ----------- TRUE
See Also:
-
CAST for conversion rules.
-
Boolean Data Type for more details on the built-in boolean data type.