The HEX function returns a hexadecimal representation of a value as a character string.
The schema is SYSIBM.
The result of the function is a character string with string units of OCTETS. If the argument can be null, the result can be null; if the argument is null, the result is the null value.
The code page is the section code page.
Argument data type1 | Length attribute2 | Result data type |
---|---|---|
CHAR(A) | A<128 | CHAR(A*2) |
CHAR(A) | A>127 | VARCHAR(A*2) |
VARCHAR(A) or CLOB(A) | A<16337 | VARCHAR(A*2) |
GRAPHIC(A) | A<64 | CHAR(A*2*2) |
GRAPHIC(A) | A>63 | VARCHAR(A*2*2) |
VARGRAPHIC(A) or DBCLOB(A) | A<8169 | VARCHAR(A*2*2) |
CHAR(A CODEUNITS32) | A<64 | VARCHAR(A*4*2) |
VARCHAR(A CODEUNITS32) or CLOB(A CODEUNITS32) | A<4085 | VARCHAR(A*4*2) |
GRAPHIC(A CODEUNITS32) | A<64 | VARCHAR(A*2*2*2) |
VARGRAPHIC(A CODEUNITS32) or DBCLOB(A CODEUNITS32) | A<4085 | VARCHAR(A*2*2*2) |
1. If string units are not specified,
then the string units for the data type are not CODEUNITS32. 2. The maximum length attributes reflect a data type limit or the limit of 16336 bytes for the input argument. |
Assume the use of a database application server on AIX® or Linux for the following examples.
SELECT HEX(MGRNO)
INTO :HEX_MGRNO
FROM DEPARTMENT
WHERE DEPTNAME = 'PLANNING'
HEX_MGRNO will
be set to '303030303230' when using the sample table (character value
is '000020').