A special version of TO_BOOLEAN that performs the same operation (that is, converts an input expression to a Boolean value), but with error-handling support. If the conversion can’t be performed, TRY_TO_BOOLEAN returns a NULL value instead of raising an error.
For more information, see Error-handling conversion functions.
Syntax¶TRY_TO_BOOLEAN( <string_expr> )
Copy
Arguments¶string_expr
A string expression that can be evaluated to a BOOLEAN value.
This function returns a value of type BOOLEAN.
Usage notes¶The input argument must be a string expression. The function evaluates the string expression in the following way:
'true'
, 't'
, 'yes'
, 'y'
, 'on'
, '1'
return TRUE.
'false'
, 'f'
, 'no'
, 'n'
, 'off'
, '0'
return FALSE.
All other strings return NULL.
The evaluations of the strings are case-insensitive.
Examples¶This example uses the TRY_TO_BOOLEAN function:
SELECT TRY_TO_BOOLEAN('True') AS "T", TRY_TO_BOOLEAN('False') AS "F", TRY_TO_BOOLEAN('Not valid') AS "N";
Copy
+------+-------+------+ | T | F | N | |------+-------+------| | True | False | NULL | +------+-------+------+
For more examples, see TO_BOOLEAN.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4