The HEX function returns a hexadecimal representation of a value.
The result of the function is a character string. If the argument can be null, the result can be null; if the argument is null, the result is the null value.
The result is a string of hexadecimal digits, the first two digits represent the first byte of the argument, the next two digits represent the second byte of the argument, and so forth. If the argument is a datetime value, the result is the hexadecimal representation of the internal form of the argument.44
If the argument is not a graphic string, the actual length of the result is twice the length of the argument. If the argument is a graphic string, the actual length of the result is four times the length of the argument. The length of the argument is the value that would be returned if the argument were passed to the LENGTH scalar function. For more information, see LENGTH.
The data type and length attribute of the result depends on the attributes of the argument:
The length attribute of the result cannot be greater than the product-specific length attribute of CHAR or VARCHAR. See Table 79 for more information.
The CCSID of the string is the default SBCS CCSID at the current server.
SELECT FIRSTNME, MIDINIT, LASTNAME, HEX(EDLEVEL) FROM EMPLOYEE
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.