Function group: string function
HEX_OF_VALUE() presents a value of any data type in hexadecimal format, i.e. in a string consisting of the hexadecimal characters 0,1,2,...,9,a,b,...,f.
This enables any bit patterns to be output in readable format.
HEX_OF_VALUE (
expression )
expression
Expression whose value is to be presented in hexadecimal format.
The data type may not be CHARACTER VARYING(n) with a maximum length of n > 16000 and not NATIONAL CHARACTER VARYING(n) with a maximum length of n > 8000.
expression may not be a multiple value with dimension > 1.
Result
If the value of expression is the NULL value, the result is the NULL value.
Otherwise:
The internal presentation of the value of expression in hexadecimal format as an alphanumeric string. Its length is specified in the table on the next page.
Data type: CHARACTER VARYING with a maximum length in accordance with the table on the next page.
Data type of expression | Data type of the result | Length of the result |
CHAR(n) | VARCHAR(2*n) | 2*n |
VARCHAR(n) where n <= 16000 | VARCHAR(2*n) | 0 to 2*n, even |
NCHAR(n) | VARCHAR(4*n) | 4*n |
NVARCHAR(n) where n <= 8000 | VARCHAR(4*n) | 0 to 4*n, divisible by 4 |
SMALLINT | VARCHAR(4) | 4 |
INTEGER | VARCHAR(8) | 8 |
NUMERIC(p,s) | VARCHAR(2*p) | 2*p |
DECIMAL(p,s) | VARCHAR(q 1) | q 1 |
REAL, FLOAT (<= 21 characters) | VARCHAR(8) | 8 |
DOUBLE PRECISION, FLOAT (>= 22 characters) | VARCHAR(16) | 16 |
DATE | VARCHAR(12) | 12 |
TIME(3) | VARCHAR(16) | 16 |
TIMESTAMP(3) | VARCHAR(28) | 28 |
Table 15: Data types and lengths in the case of HEX_OF_VALUE()
1q=p+2 if p is even; q=p+1 if p is odd.
Examples
HEX_OF_VALUE (CAST (254 AS SMALLINT)) 00fe HEX_OF_VALUE ('ABC') c1c2c3
Internal presentation of values in SESAM/SQL
The internal presentation of values which are not equal to NULL in SESAM/SQL as returned by the REP_OF_VALUE() and HEX_OF_VALUE() functions is similar to the internal presentation of corresponding values in other programming languages (e.g. COBOL, C).
SQL data_type | Sample value | internal presentation |
CHAR, VARCHAR | 'ABC' |
|
NCHAR, NVARCHAR | N'ABC' |
|
SMALLINT | +300 |
|
INTEGER | +300 |
|
NUMERIC(p,s) | +123.5 |
|
DECIMAL(p,s) FLOOR(p/2)1 bytes with 2 digits each, | +123.5 |
|
REAL, FLOAT (<= 21 characters) | +2.550625e+2 |
|
DOUBLE PRECISION, FLOAT (>=22 characters) | +2.5506250000e+2 |
|
DATE | DATE'2000-08-11' |
|
TIME(3) | TIME'12:34:56.123' |
|
TIMESTAMP(3) | TIMESTAMP |
|
Table 16: Overview of the internal presentation of values in SESAM/SQL
1FLOOR(p/2) is the largest whole number<= p/2