Name
bin2hex, hex2bin — convert between binary bytes and their hexadecimal string representation
Synopsis
varchar bin2hex(
|
in bytes any); |
varbinary hex2bin(
|
in hex_string varchar); |
Description
bin2hex returns a hexadecimal string containing two
lowercase hex digits per input byte. The input may be a
varchar or varbinary; any other type raises SQL
state 22023 (ENC01).
hex2bin performs the inverse conversion: it parses
hex_string as a sequence of two-digit hex bytes and
returns the corresponding varbinary. Returns SQL NULL when
the input is NULL. The input length must be even (SQL state 22023,
ENC02); each pair must form a valid hex byte (SQL state
22023, ENC03).
Examples
Example 24.241. Round-trip a value
SQL> select bin2hex ('Hello');
-- 48656c6c6f
SQL> select cast (hex2bin ('48656c6c6f') as varchar);
-- Hello