Your Browser is not longer supported

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

{{viewport.spaceProperty.prod}}

VALUE_OF_HEX() - Present hexadecimal format as a value

Function group: string function

The VALUE_OF_HEX() function returns a value of the specified data type from the internal presentation provided in hexadecimal format.
It is the inverse function of HEX_OF_VALUE().


VALUE_OF_HEX ( expression , data_type )



expression

The internal presentation of the result value in hexadecimal format.
The value of expression may only contain the characters '0' through '9', 'a' through 'f' and 'A' through 'F'.
expression must have the data type CHARACTER(n) (n even) or CHARACTER VARYING(n).
Its value must either be the NULL value or have a length which suits the data type data_type (see the table on the next page). The data type of expression must permit values of this length or of the maximum length.
expression may not be a multiple value with dimension > 1.


data_type

Data type of the value (without dimension specification), expression being the presentation 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.


Result

If the value of expression is the NULL value, the result is the NULL value.

Otherwise:

The value of the specified data_type whose internal presentation in hexadecimal format is the value of expression. For the internal presentation of the various data types, see table 16.


Data type: the specified data_type

When this function is executed, no check is made to see whether data_type is the same data type which was used beforehand for the corresponding presentation in internal formal using HEX_OF_VALUE().

Length of expression in characters

data_type

2*n

CHAR(n)

0 to 2*n

VARCHAR(n)

4*n

NCHAR(n)

0 to 4*n, divisible by 4

NVARCHAR(n)

4

SMALLINT

8

INTEGER

2*p

NUMERIC(p,s)

q 1

DECIMAL(p,s)

8

REAL, FLOAT (<= 21 characters)

16

DOUBLE PRECISION, FLOAT (>= 22 characters)

12

DATE

16

TIME(3)

28

TIMESTAMP(3)

Table 18: Data types and lengths in the case of VALUE_OF_HEX

1q=p+2 if p is even; q=p+1 if p is odd.


Examples

VALUE_OF_HEX ('00fe', SMALLINT) 
   254
VALUE_OF_HEX ('c1c2c3', CHAR(3)) 
   ABC