SQL HEX scalar function in DB2 for i SQL |
HEX
The HEX function returns a hexadecimal value as a character string.
Syntax
HEX(expression)
where, expression is any built-in data type other than XML. If the argument is NULL then the result is NULL. The result is a string of hexadecimal digits. The first two denotes the first byte of the argument, the next two denotes the second byte of the argument and so on.
Example #1
SELECT hex('ABCD') FROM SYSIBM.SYSDUMMY1
Output
HEX ( 'ABCD' ) C1C2C3C4
C1 is for A, C2 is for B and C3 is for C and C4 is for D.
Example #2
SELECT hex(graphic('ABCD',4,1200)) FROM SYSIBM.SYSDUMMY1
Output
HEX 0041004200430044
With graphic fields, the returned hex value would be of 4 character digits for the first byte in the argument. 0041 is for A, 0042 is for B and 0043 is for C and 0044 is for D.