
>>-HEX--(--expression--)---------------------------------------><
The HEX function returns a hexadecimal representation
of a value as a character string.
The argument can be an expression that is a value of any
built-in data type with a maximum length of 16 336 bytes.
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 code page is the section code page.
The result is a string of hexadecimal digits. The first
two represent the first byte of the argument, the next two represent
the second byte of the argument, and so forth. If the argument is
a datetime value or a numeric value the result is the hexadecimal
representation of the internal form of the argument. The hexadecimal
representation that is returned may be different depending on the
application server where the function is executed. Cases where differences
would be evident include:
- Character string arguments when the HEX function is performed
on an ASCII client with an EBCDIC server or on an EBCDIC client with
an ASCII server.
- Numeric arguments (in some cases) when the HEX function is performed
where client and server systems have different byte orderings for
numeric values.
The type and length of the result vary based on the type
and length of character string arguments.
- Character string
- Fixed length not greater than 127
- Result is a character string of fixed length twice the defined
length of the argument.
- Fixed length greater than 127
- Result is a character string of varying length twice the defined
length of the argument.
- Varying length
- Result is a character string of varying length with maximum length
twice the defined maximum length of the argument.
- Graphic string
- Fixed length not greater than 63
- Result is a character string of fixed length four times the defined
length of the argument.
- Fixed length greater than 63
- Result is a character string of varying length four times the
defined length of the argument.
- Varying length
- Result is a character string of varying length with maximum length
four times the defined maximum length of the argument.
Assume the use of a DB2® for AIX® application server for the following
examples.