DB2 Server for VSE & VM: SQL Reference


Appendix E. Data Conversion Chart

Figure 10. Data Conversion Chart


















 Source Data Type
Target Data Type
CHAR
DATE
DECIMAL
FLOAT- DOUBLE
FLOAT- SINGLE
GRAPHIC
INTEGER
 CHAR 
 YES3 
 YES6 
 NO 
 NO 
 NO 
 NO 
 NO 
 DATE 
 YES7 
 YES 
 NO 
 NO 
 NO 
 NO 
 NO 
 DECIMAL 
 NO 
 NO 
 YES1,4 
 YES13 
 YES12,13 
 NO 
 YES1,2 
 FLOAT-DOUBLE 
 NO 
 NO 
 YES1,4,5 
 YES 
 YES11 
 NO 
 YES1,2 
 FLOAT-SINGLE 
 NO 
 NO 
 YES1,4,5 
 YES10 
 YES 
 NO 
 YES1,2 
 GRAPHIC 
 NO 
 NO 
 NO 
 NO 
 NO 
 YES3 
 NO 
 INTEGER 
 NO 
 NO 
 YES1 
 YES 
 YES12 
 NO 
 YES 
 LONG VARCHAR 
 YES3 
 NO 
 NO 
 NO 
 NO 
 NO 
 NO 
 LONG VARGRAPHIC 
 NO 
 NO 
 NO 
 NO 
 NO 
 YES3 
 NO 
 SMALLINT 
 NO 
 NO 
 YES1 
 YES 
 YES12 
 NO 
 YES 
 TIME 
 YES7 
 NO 
 NO 
 NO 
 NO 
 NO 
 NO 
 TIMESTAMP 
 YES7 
 NO 
 NO 
 NO 
 NO 
 NO 
 NO 
 VARCHAR8 
 YES3 
 YES6 
 NO 
 NO 
 NO 
 NO 
 NO 
 VARGRAPHIC9 
 NO 
 NO 
 NO 
 NO 
 NO 
 YES3 
 NO 


















 Source Data Type
Target Data Type
LONG VARCHAR
LONG VAR- GRAPHIC
SMALL-INT
TIME
TIME- STAMP
VAR- CHAR8
VAR- GRAPHIC9
 CHAR 
 YES 
 NO 
 NO 
 YES6 
 YES6 
 YES3 
 NO 
 DATE 
 NO 
 NO 
 NO 
 NO 
 NO 
 YES 
 NO 
 DECIMAL 
 NO 
 NO 
 YES1,2 
 NO 
 NO 
 NO 
 NO 
 FLOAT-DOUBLE 
 NO 
 NO 
 YES1,2 
 NO 
 NO 
 NO 
 NO 
 FLOAT-SINGLE 
 NO 
 NO 
 YES1,2 
 NO 
 NO 
 NO 
 NO 
 GRAPHIC 
 NO 
 YES 
 NO 
 NO 
 NO 
 NO 
 YES3 
 INTEGER 
 NO 
 NO 
 YES1 
 NO 
 NO 
 NO 
 NO 
 LONG VARCHAR 
 YES 
 NO 
 NO 
 NO 
 NO 
 YES3 
 NO 
 LONG VARGRAPHIC 
 NO 
 YES 
 NO 
 NO 
 NO 
 NO 
 YES3 
 SMALLINT 
 NO 
 NO 
 YES 
 NO 
 NO 
 NO 
 NO 
 TIME 
 NO 
 NO 
 NO 
 YES 
 NO 
 YES7 
 NO 
 TIMESTAMP 
 NO 
 NO 
 NO 
 NO 
 YES 
 YES7 
 NO 
 VARCHAR8 
 YES 
 NO 
 NO 
 YES6 
 YES6 
 YES3 
 NO 
 VARGRAPHIC9 
 NO 
 YES 
 NO 
 NO 
 NO 
 NO 
 YES3 

Notes to Figure 10:

  1. An overflow error may result.
  2. The fractional part of the value is dropped.
  3. On output, if the length of the target is smaller than the length of the source, truncation occurs. On input, an error occurs.
  4. The database manager automatically aligns the decimal point. Overflow of the integer part may result. The fractional part may be truncated.
  5. The database manager attempts to create the best possible result in converting from |System/390 floating point to scaled fixed point decimal.
  6. The character string must contain a valid representation of a date, time, or timestamp value. However, you cannot transfer data from a CHAR or VARCHAR column into a host variable defined as a date, time, or timestamp type.
  7. On output, when the source is a datetime data type and the corresponding target is a character data type, certain truncation occurs for time and timestamp. On input, an error occurs.
  8. This applies to VARCHAR fields less than or equal to 254. VARCHAR fields greater than 254 are treated like LONG VARCHAR in data conversion.
  9. This applies to VARGRAPHIC fields less than or equal to 127. VARGRAPHIC fields greater than 127 are treated like LONG VARGRAPHIC in data conversion.
  10. The single-precision data is padded with eight hex zeros.
  11. The double-precision data is converted and rounded up on the seventh hex digit.
  12. Conversion is first done in double precision and then rounded to single precision.
  13. Some accuracy may be lost when converting DECIMAL data type numbers to single- or double-precision floating point numbers.


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