Function group: string function
The VALUE_OF_REP() function returns a value of the specified data type from the internal presentation provided (sequence of bytes).
It is the inverse function of REP_OF_VALUE().
VALUE_OF_REP (
expression ,
data_type )
expression
The internal presentation of the result value. For the internal presentation of the various data types, see table 16.
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 internal presentation.
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 is the value of expression.
Data type: the specified data_type
Length of expression in characters | data_type |
n | CHAR(n) |
0 to n | VARCHAR(n) |
2*n | NCHAR(n) |
0 to 2*n, even | NVARCHAR(n) |
2 | SMALLINT |
4 | INTEGER |
p | NUMERIC(p,s) |
q 1 | DECIMAL(p,s) |
4 | REAL, FLOAT (<= 21 characters) |
8 | DOUBLE PRECISION, FLOAT (>= 22 characters) |
6 | DATE |
8 | TIME(3) |
14 | TIMESTAMP(3) |
Table 19: Data types and lengths in the case of VALUE_OF_REP
1q=(p + 2)/2 if p is even; q=(p + 1)/2 if p is odd
Examples
VALUE_OF_REP (X'00fe', SMALLINT) 254 VALUE_OF_REP ('ABC', CHAR(3)) ABC