Using QMF

Converting a value from one data type to another

The scalar functions DECIMAL, DIGITS, FLOAT, HEX, INTEGER, and VARGRAPHIC allow you to convert a value from one data type to another.

The DECIMAL function returns a decimal representation of a number.

The DIGITS function returns values without a decimal point.

The FLOAT function returns a floating-point representation of a number.

The HEX function uses the hexadecimal numeration system.

The INTEGER function returns an integer representation of a number.

The VARGRAPHIC function converts a mixed single-byte and double-byte character string to a pure double-byte character string. VARGRAPHIC returns a varying length graphic string (data type VARGRAPHIC) result.

The first or only argument of each of these functions is an expression that gives the value to convert.

For example, when you run this SQL statement:

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

QMF produces this report:

+--------------------------------------------------------------------------------+
|    SALARY          COL1  COL2           COL3  COL4                COL5         |
|----------  ------------  -------  ----------  ------------------  ----------   |
|  22959.20     22959.200  2295920   2.296E+04  D4D6D3C9D5C1D9C5    -M-G-R       |
|  20010.00     20010.000  2001000   2.001E+04  D3E4                -M-G-R       |
|  19260.25     19260.250  1926025   1.926E+04  C4C1D5C9C5D3E2      -M-G-R       |
|  21234.00     21234.000  2123400   2.123E+04  D1D6D5C5E2          -M-G-R       |
+--------------------------------------------------------------------------------+


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]