DB2 DCLGEN All You Need About it

When you use DCLGEN to generate a Table declaration, it will not have the correct information for the below list of items.

DCLGEN can’t Generate Correct Output.

  1. (a) The null indicators of the columns/fields.
  2. (b) The primary key of the table.
  3. (c) The datatypes of columns/fields.
  4. (d) The data structures specific to the programming language.

Reason: 

DCLGEN produces output that is intended to meet the needs of most users, but occasionally, you need to edit the DCLGEN output to work in your specific case.

For example, DCLGEN is unable to determine whether a column that is defined as NOT NULL also contains the DEFAULT clause, so you must edit the DCLGEN output to add the DEFAULT clause to the appropriate column definitions.

DCLGEN OUTPUT.

DCLGEN TABLE(VEMPL) –
LIBRARY(‘prefix.SRCLIB.DATA(DSN8MPEM)’) –
LANGUAGE(PLI) –
APOST
The output looks like this:

/*********************************************************************/
/* DCLGEN TABLE(VEMPL) – */
/* LIBRARY(‘prefix.SRCLIB.DATA(DSN8MPEM)’) – */
/* LANGUAGE(PLI) – */
/* APOST */
/* … IS THE DCLGEN COMMAND THAT MADE THE FOLLOWING STATEMENTS */
/*********************************************************************/
EXEC SQL DECLARE VEMPL TABLE
( EMPNO CHAR(6) NOT NULL,
FIRSTNME VARCHAR(12) NOT NULL,
MIDINIT CHAR(1) NOT NULL,
LASTNAME VARCHAR(15) NOT NULL,
WORKDEPT CHAR(3) NOT NULL
) ;
/*********************************************************************/
/* PLI DECLARATION FOR TABLE VEMPL */
/*********************************************************************/
DCL 1 DCLVEMPL,
5 EMPNO CHAR(6),
5 FIRSTNME CHAR(12) VAR,
5 MIDINIT CHAR(1),
5 LASTNAME CHAR(15) VAR,
5 WORKDEPT CHAR(3);
/*********************************************************************/
/* THE NUMBER OF COLUMNS DESCRIBED BY THIS DECLARATION IS 5 */
/*********************************************************************/

Keep Reading

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.