Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

HEX_OF_VALUE() - Present any value in hexadecimal format

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
if not NULL

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
(hexadecimal format)

CHAR, VARCHAR
EBCDIC string

'ABC'

c1c2c3

NCHAR, NVARCHAR
UTF16 string

N'ABC'

004100420043

SMALLINT
2 bytes with binary presentation of value
(2 Excess Code)

+300
-300

012C

fed4

INTEGER
4 bytes with binary presentation of value
(2 Excess Code)

+300
-300

0000012c

fffffed4

NUMERIC(p,s)
p bytes with EBCDIC characters for digits,
sign in the last byte

+123.5
-123.5

f1f2f3f5

f1f2f3d5

DECIMAL(p,s)

FLOOR(p/2)1 bytes with 2 digits each,
last byte with 1 digit and sign

+123.5
-123.5

01235c

01235d

REAL, FLOAT (<= 21 characters)
1 byte for sign and exponent,
3 bytes mantissa

+2.550625e+2
(=255 + 1/16)

45ff1000

DOUBLE PRECISION,

FLOAT (>=22 characters)
1 byte for sign and exponent for
base 16, 7 bytes mantissa

+2.5506250000e+2

c5ff100000000000

DATE
2 bytes each with year, month, day in
binary format

DATE'2000-08-11'

07d800008000b

TIME(3)
2 bytes each with hours, minutes, seconds
and milliseconds in binary format

TIME'12:34:56.123'

000c00220038007b

TIMESTAMP(3)
Like DATE and TIME(3)

TIMESTAMP
'2000-08-11 12:34:56.123'

07d800008000b000c00

220038007b

Table 16: Overview of the internal presentation of values in SESAM/SQL

1FLOOR(p/2) is the largest whole number<= p/2