Conversion functions

Scalar functions (see Table 2, following) allow the conversion of a value from one data type to another.

Table 2. Conversion Functions
Function and Syntax Argument Result
DECIMAL(V,P,S)
V = A number
P = Precision of the
result
S = Scale of the result
Decimal representation of V
DIGITS(argument) A binary integer or decimal number A character string representing the digits of the argument
FLOAT(argument) A number Single-precision floating point number representing the argument
HEX(argument) Any data type other than a long character or long graphic string A character string representing actual hex digits of the argument
INTEGER(argument) A number within the range of binary integers Fullword representation of the argument
VARGRAPHIC(argument) Short character string Graphic string that is the DBCS representation of the argument

This query:

SELECT SALARY,          --SALARY
DECIMAL(SALARY,9,3),    --COL1
DIGITS(SALARY),         --COL2
FLOAT(SALARY),          --COL3
HEX(NAME),              --COL4
VARGRAPHIC(JOB)         --COL5
FROM Q.STAFF
WHERE DEPT = 10

Produces this report:

 SALARY          COL1 COL2             COL3  COL4               COL5
-------- ------------ ------- -------------  ------------------ --------
22959.20    22959.200 2295920  2.295920E+04  D4D6D3C9D5C1D9C5   -M-G-R
20010.00    20010.000 2001000  2.001000E+04  D3E4               -M-G-R
19260.25    19260.250 1926025  1.926025E+04  C4C1D5C9C5D3E2     -M-G-R
21234.00    21234.000 2123400  2.123400E+04  D1D6D5C5E2         -M-G-R
[ Previous Page | Next Page | Contents | Index ]