TO_BOOLEAN
functionsupportedCore SQL functionsConverts the input text or numeric expression to a BOOLEAN value.
Syntax
TO_BOOLEAN( <string_or_numeric_expr> )
Parameters
| Name | Required | Description |
|---|---|---|
string_or_numeric_expr | required | A string expression or numeric expression that can be evaluated to a BOOLEAN value. |
Returns
Returns a BOOLEAN value or NULL. - Returns TRUE if string_or_numeric_expr evaluates to TRUE. - Returns FALSE if string_or_numeric_expr evaluates to FALSE. - If the input is NULL, returns NULL without reporting an error.
Usage notes
- For a string expression: 'true', 't', 'yes', 'y', 'on', '1' return TRUE.
- 'false', 'f', 'no', 'n', 'off', '0' return FALSE.
- All other strings return an error.
- The evaluations of the strings are case-insensitive.
- For a numeric expression: 0 returns FALSE.
- All non-zero numeric values return TRUE.
- When converting from the FLOAT data type, non-numeric values, such as NaN (not a number) and INF (infinity), return an error.