hextoraw
1. HEXTORAW Function
=======hextoraw
1. HEXTORAW Function
>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62beThe HEXTORAW function in H2 database is used to convert a hexadecimal string representation into a raw binary value.
2. Syntax
The syntax for the HEXTORAW function in H2 database is as follows:
HEXTORAW(hexString)
Arguments
hexString
: The hexadecimal string that needs to be converted into a raw binary value. It should be a string literal or a column containing hexadecimal values.
Return
- The HEXTORAW function returns the raw binary value corresponding to the given hexadecimal string.
3. Notes
- The HEXTORAW function expects a valid hexadecimal string as input. If the input string is not a valid hexadecimal representation, an error will occur.
- The length of the input hexadecimal string should be an even number. If the length is odd, a leading zero can be added to make it even.
- The HEXTORAW function can be useful when working with binary data stored as hexadecimal strings, such as in cases of data conversion or manipulation.
4. Examples
Here are a few examples demonstrating the usage of the HEXTORAW function in H2 database:
Example 1 - Converting a hexadecimal string into a raw binary value:
SELECT HEXTORAW('48656C6C6F20576F726C64') AS rawValue;
Output:
rawValue
-------------------
Hello World
Example 2 - Converting hexadecimal values stored in a column:
CREATE TABLE hex_values (
id INT PRIMARY KEY,
hexString VARCHAR(100)
);
INSERT INTO hex_values VALUES (1, '48656C6C6F'), (2, '576F726C64');
SELECT id, hexString, HEXTORAW(hexString) AS rawValue
FROM hex_values;
Output:
id | hexString | rawValue
---+-------------+-------------------
1 | 48656C6C6F | Hello
2 | 576F726C64 | World
5. Related Functions
- rawtohex - Convert a raw binary value into a hexadecimal string.