TRY_TO_BINARY
functionsupportedCore SQL functionsA special version of TO_BINARY that performs the same operation (i.e. converts an input expression to a binary value), but with error handling support (i.e. if the conversion cannot be performed, it returns a NULL value instead of raising an error). For more information, see: - Error-handling conversion functions. - TO_BINARY. - Binary input and output.
Syntax
supportedpartialnot supportednot scored
TRY_TO_BINARY( <string_expr> [, '<format>'] )
Parameters
| Name | Required | Description |
|---|---|---|
string_expr | required | A string expression. |
format | optional | The binary format for conversion: HEX, BASE64, or UTF-8 (see Binary input and output). The default is the value of the BINARY_INPUT_FORMAT session parameter. If this parameter is not set, the default is HEX. |
Returns
Returns a value of type BINARY.
Usage notes
- Only works for string expressions.
- If format is specified but is not HEX, BASE64, or UTF-8, the result will be a NULL value.