Function group: string function
REP_OF_VALUE() presents a value of any data type as a alphanumeric string (sequence of bytes).
REP_OF_VALUE (
expression )
expression
Expression whose value is to be presented as a string.
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 as a sequence of bytes in an alphanumeric string. For the internal presentation of the various data types, see table 16.
Data type: CHARACTER VARYING(n), where the maximum length n of the data type expression is dependent on the values shown in the table on the next page.
Data type of expression | Data type of the result | Length of the result |
CHAR(n) | VARCHAR(n) | n |
VARCHAR(n) | VARCHAR(n) | 0 to n |
NCHAR(n) | VARCHAR(2*n) | 2*n |
NVARCHAR(n) | VARCHAR(2*n) | 0 to 2*n, even |
SMALLINT | VARCHAR(2) | 2 |
INTEGER | VARCHAR(4) | 4 |
NUMERIC(p,s) | VARCHAR(n) | p |
DECIMAL(p,s) | VARCHAR(q 1) | q 1 |
REAL, FLOAT (<= 21 characters) | VARCHAR(4) | 4 |
DOUBLE PRECISION, FLOAT (>= 22 characters) | VARCHAR(8) | 8 |
DATE | VARCHAR(6) | 6 |
TIME(3) | VARCHAR(8) | 8 |
TIMESTAMP(3) | VARCHAR(14) | 14 |
Table 17: Data types and lengths in the case of REP_OF_VALUE
1q=(p + 2)/2 if p is even; q=(p + 1)/2 is p is odd.
Examples
REP_OF_VALUE (CAST (254 AS SMALLINT))
254 is presented in binary format as X'00fe' (2 bytes).
These 2 bytes (not printable) are also the result of the expression.
REP_OF_VALUE ('ABC')
The result is the string 'ABC'.