DCLGEN
A tool that reads a Db2 table and writes the matching COBOL fields.
Also written declarations generator
Why it matters. A program's fields must match the table's columns exactly. DCLGEN writes them for you, so nobody types them by hand.
See it
A DCLGEN declarationCOBOL
( ACCT_NO CHAR(8) NOT NULL,
OWNER_NAME VARCHAR(40) NOT NULL,
BALANCE DECIMAL(9, 2) NOT NULL
) END-EXEC.
49 OWNER-NAME-TEXT PIC X(40).
DCLGEN is a Db2 tool. It writes this code from the table definition.
Syntax
DCLGEN TABLE(owner.table) LIBRARY(dsname(member)) LANGUAGE(COBOL) [ACTION(REPLACE)] [STRUCTURE(name)] [NAMES(prefix)]
- TABLE
- The table to describe.
- LIBRARY
- Where to save the output, as a library and member.
- LANGUAGE
- COBOL, PLI or C.
- ACTION
- ADD or REPLACE the member.
- STRUCTURE
- The name of the host-variable group.
- NAMES
- A prefix for the field names.
- INDVAR
- Also write indicator variables for nullable columns.
Remember
- DCLGEN reads a table and writes COBOL fields for it. A DECIMAL column becomes COMP-3, and a VARCHAR becomes a length and a text field.
- The output is saved as a copybook, and the program includes it with EXEC SQL INCLUDE.
- Run it again when the table changes.
The usual mistake
Typing the table's fields into the program by hand
One wrong length or type, and the values do not line up with the columns.
Generate the fields with DCLGEN, then INCLUDE them
On real z/OS
DCLGEN isn't modelled in MF/OS. There is nothing to run, and the COBOL programs there don't need generated declarations.
Where can I practise DCLGEN?
Right here, at ZedBank. You take a junior job at a simulated bank and use DCLGEN in real work, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- Embedded SQLSQL statements written directly inside a COBOL program, marked off so they can be prepared before compiling.
- CopybookA shared block of COBOL declarations kept in a library and included into programs, so a record layout is defined once.
- DB2 for z/OSIBM's relational database on the mainframe, where a great deal of the world's banking and insurance data is stored.
- COBOLThe programming language most business logic on the mainframe is written in. Verbose by design, and still running the world's payments.
- BINDPreparing a program's SQL for execution, working out how each statement will access the data and storing the result.