HEX_TO_INTEGER
Translates the given VARCHAR hexadecimal representation into an INTEGER value.
Vertica completes this conversion as follows:
- Adds the 0x prefix if it is not specified in the input
- Casts the VARCHAR string to a NUMERIC
- Casts the NUMERIC to an INTEGER
Behavior Type
Syntax
HEX_TO_INTEGER ( [ 0x ] expression )
Parameters
expression |
VARCHAR is the string to translate. |
0x |
Is the optional prefix. |
Examples
You can enter the string with or without the Ox prefix. For example:
=> SELECT HEX_TO_INTEGER ('0aedc') AS hex1,HEX_TO_INTEGER ('aedc') AS hex2; hex1 | hex2 -------+------- 44764 | 44764 (1 row)
If you pass the function an invalid hex value, Vertica returns an invalid input syntax
error; for example:
=> SELECT HEX_TO_INTEGER ('0xffgf'); ERROR 3691: Invalid input syntax for numeric: "0xffgf"