With EGL, you can create SQL record fields from the definition of an SQL table, view, or join.
Record myTable type sqlRecord end
EGL host variables of type HEX support access to any SQL column of a data type that does not correspond to an EGL primitive type.
If character data is read from an SQL table column into a shorter host variable, content is truncated on the right. To test for truncation, use the reserved word trunc in an EGL if statement.
EGL uses a default mapping when it creates records with the Retrieve SQL feature. The following table shows the default mapping.
SQL data type | EGL variable characteristics | ||
---|---|---|---|
Primitive type | Digits/characters | Number of bytes | |
BIGINT | BIGINT | n/a | 8 |
BIT | SMALLINT | n/a | 2 |
BLOB | BLOB | n/a | n/a |
BOOLEAN | BOOLEAN | n/a | 1 |
CHAR | CHAR | 1–32767 | 1–32767 |
CLOB | CLOB | n/a | n/a |
DATE | DATE | n/a | 8 |
DECIMAL | DECIMAL | 1-18 | 1–10 |
DOUBLE | FLOAT | n/a | 8 |
FLOAT | FLOAT | n/a | 8 |
GRAPHIC | DBCHAR | 1–16383 | 2–32766 |
INTEGER | INT | n/a | 4 |
LONG VARBINARY | HEX | 65534 | 32767 |
LONG VARCHAR | CHAR | >4000 | >4000 |
LONG VARGRAPHIC | DBCHAR | >2000 | >4000 |
NUMERIC | DECIMAL | 1-18 | 1–10 |
REAL | SMALLFLOAT | n/a | 4 |
SMALLINT | SMALLINT | n/a | 2 |
TIME | TIME | n/a | 6 |
TIMESTAMP | TIMESTAMP | n/a | 14 |
VARBINARY | HEX | 2–65534 | 1–32767 |
VARCHAR | CHAR | ≤4000 | ≤4000 |
VARGRAPHIC | DBCHAR | ≤2000 | ≤4000 |
The definition of an SQL table column of the type VARCHAR or VARGRAPHIC includes a maximum length, and the retrieve command uses that maximum to assign a length to the EGL host variable. The definition of an SQL table column of the type LONG VARCHAR or VARGRAPHIC, however, does not include a maximum length, and the retrieve command uses the SQL-data-type maximum to assign a length.
Platform | Issue |
---|---|
Java™ generation | If numeric data is read from an SQL table column into a shorter host variable, EGL treats the situation as it would an overflow on an assignment statement. |
COBOL generation | If numeric data is read from an SQL table column into a shorter host variable, leading zeros are truncated on the left. If the number still does not fit into the host variable, fractional parts of the number (in decimal) are deleted on the right, with no indication of error. If the number still does not fit, a negative SQL code is returned to indicate an overflow condition. |