The base SQLTYPE and SQLLEN of host variables are determined according to the following table. If a host variable appears with an indicator variable, the SQLTYPE is the base SQLTYPE plus one.
| PL/I Data Type | SQLTYPE of Host Variable | SQLLEN of Host Variable | SQL Data Type |
|---|---|---|---|
| BIN FIXED(n), n < 16 | 500 | 2 | SMALLINT |
| BIN FIXED(n), n ranges from 16 to 31 | 496 | 4 | INTEGER |
| DEC FIXED(p,s) | 484 | p (byte 1) s (byte 2) | DECIMAL(p,s) |
| BIN FLOAT(p), 22 <= p <= 53 | 480 | 8 | FLOAT |
| DEC FLOAT(m), 7 <= m <= 16 | 480 | 8 | FLOAT |
| CHAR(n), 1 <= n <= 254 | 452 | n | CHAR(n) |
| CHAR(n) VARYING, 1 <= n <= 4000 | 448 | n | VARCHAR(n) |
| CHAR(n) VARYING, n > 4000 | 456 | n | LONG VARCHAR |
| GRAPHIC(n), 1 <= n <= 127 | 468 | n | GRAPHIC(n) |
| GRAPHIC(n) VARYING, 1 <= n <= 2000 | 464 | n | VARGRAPHIC(n) |
| GRAPHIC(n) VARYING, n > 2000 | 472 | n | LONG VARGRAPHIC |
Since SQL does not have single or extended precision floating-point data type, if a single or extended precision floating-point host variable is used to insert data, it is converted to a double precision floating-point temporary and the value in the temporary is inserted into the database. If the single or extended precision floating-point host variable is used to retrieve data, a double precision floating-point temporary is used to retrieve data from the database and the result in the temporary variable is assigned to the host variable.
The following table can be used to determine the PL/I data type that is equivalent to a given SQL data type.
| SQL Data Type | PL/I Equivalent | Notes |
|---|---|---|
| SMALLINT | BIN FIXED(15) | |
| INTEGER | BIN FIXED(31) | |
| DECIMAL(p,s) | DEC FIXED(p) or DEC FIXED(p,s) | p = precision and s = scale; 1 <= p <= 31 and 0 <= s <= p |
| FLOAT | BIN FLOAT(p) or DEC FLOAT(m) | 22 <= p <= 53 7 <= m <= 16 |
| CHAR(n) | CHAR(n) | 1 <= n <= 254 |
| VARCHAR(n) | CHAR(n) VAR | 1 <= n <= 4000 |
| LONG VARCHAR | CHAR(n) VAR | n > 4000 |
| GRAPHIC(n) | GRAPHIC(n) | n is a positive integer from 1 to 127 that refers to the number of double-byte characters, not to the number of bytes |
| VARGRAPHIC(n) | GRAPHIC(n) VAR | n is a positive integer that refers to the number of double-byte characters, not to the number of bytes; 1 <= n <= 2000 |
| LONG VARGRAPHIC | GRAPHIC(n) VAR | n > 2000 |
| DATE | CHAR(n) | n must be at least 10 |
| TIME | CHAR(n) | n must be at least 8 |
| TIMESTAMP | CHAR(n) | n must be at least 26 |