Writing exits for EGL access of DB2®
The purpose of each exit is to format or change the value of the CHAR-type values that correspond to Date, Time, and Timestamp columns. The exits are particularly useful if you cannot fulfill your intent by using another mechanism such as JBDC driver properties or DB2® precompiler options.
- Input and output for Date columns that correspond to an EGL field of type CHAR(10).
- Input and output for Time columns that correspond to an EGL field of type CHAR(8).
- Input and output for Timestamp columns that correspond to an EGL field of type CHAR(26).
On input to the database, the content of the host variable is unaffected; only the value sent to the database column is changed. On output, the content of the host variable is changed, but the column value is unaffected.
- If your data-access code is being generated to COBOL, you place each exit in its own load module. For details, see "Writing exits for DB2® and COBOL generation."
- If your data-access code is being generated to Java™, you write the exits in a single Java™ class. For details, see "Writing exits for DB2® and Java™ generation."
The exits that are delivered are templates that have no effect.
Enabling the user exit by including a sqlDataCode value
Record TstabN type SQLRecord
{tableNames = [["ME.MYTABLE"]], fieldsMatchColumns = yes}
10 TS2 char(26) {column="TS2", isSqlNullable=yes, sqlDataCode=392};
10 TS1 char(26) {column="TS1", isSqlNullable=yes, sqlDataCode=392};
10 DATE1 char(10) {column="DATE1", isSqlNullable=yes, sqlDataCode=384};
10 TIME1 char(8) {column="TIME1", isSqlNullable=yes, sqlDataCode=388};
enddataitem tstype char(26) {sqlDataCode=392} end
dataitem datetype char(10) {sqlDataCode=384} end
dataitem timetype char(8) {sqlDataCode=388} endAny of the following sqlDataCode values causes an exit invocation:
| sqlDataCode values | Nullable | SQL column type |
|---|---|---|
| 384 385 |
YES NO |
DATE |
| 388 389 |
YES NO |
TIME |
| 392 393 |
YES NO |
TIMESTAMP |
You can set a preference so that use of the EGL SQL retrieve feature automatically places the sqlDataCode values in a Record part that is created for you. For details, see "Setting preferences for SQL retrieve."
The exit for a specific field is not invoked during database input when the field is null, or during database output when the column is null.