HEX Function
The HEX function returns the hexadecimal encoding
of an integer expression.
Element | Description | Restrictions | Syntax |
---|---|---|---|
int_expression | Expression for which you want the hexadecimal equivalent | Must be a literal integer or some other expression that returns an integer | Expression |
The next example displays the data type and column length
of the columns of the orders table in hexadecimal format. For
MONEY and DECIMAL columns, you can then determine the precision and
scale from the lowest and next-to-the-lowest bytes. For VARCHAR and
NVARCHAR columns, you can determine the minimum space and maximum
space from the lowest and next-to-the-lowest bytes. For more information
about encoded information, see the IBM®
Informix Guide to SQL: Reference.
SELECT colname, coltype, HEX(collength)
FROM syscolumns C, systables T
WHERE C.tabid = T.tabid AND T.tabname = 'orders';
The following example lists the names of all the tables
in the current database and their corresponding tblspace number in
hexadecimal format.
SELECT tabname, HEX(partnum) FROM systables;
The two most significant bytes in the hexadecimal number constitute the dbspace number. They identify the table in oncheck output in Informix®.
The HEX function can operate on an expression,
as the next example shows:
SELECT HEX(order_num + 1) FROM orders;