Example: Adding DCLGEN declarations to a library
You can use DCLGEN to generate table and variable declarations for C, COBOL, and PL/I programs. If you store these declarations in a library, you can later integrate them into your program with a single SQL INCLUDE statement.
- The library name is prefix.TEMP.COBOL.
- The member is a new member named VPHONE.
- The table is a local table named DSN8D10.VPHONE.
- The host-variable structure is for COBOL.
- The structure receives the default name DCLVPHONE.
Throughout this example, information that you must enter on each panel is in bold-faced type.
In this scenario, to add a table declaration and a corresponding host variable structure for DSN8D10.VPHONE to the library prefix.TEMP.COBOL, complete the following steps:
- Specify COBOL as the host language by completing the following
actions:
- On the ISPF/PDF menu, select option D to display the DB2I DEFAULTS PANEL l panel.
- Specify IBMCOB as the application language,
as shown in the following figure and press Enter.
Figure 1. DB2I defaults panel—changing the application language DSNEOP01 DB2I DEFAULTS PANEL 1 COMMAND ===>_ Change defaults as desired: 1 DB2 NAME ............. ===> DSN (Subsystem identifier) 2 DB2 CONNECTION RETRIES ===> 0 (How many retries for DB2 connection) 3 APPLICATION LANGUAGE ===> IBMCOB (ASM, C, CPP, IBMCOB, FORTRAN, PLI) 4 LINES/PAGE OF LISTING ===> 80 (A number from 5 to 999) 5 MESSAGE LEVEL ........ ===> I (Information, Warning, Error, Severe) 6 SQL STRING DELIMITER ===> DEFAULT (DEFAULT, ' or ") 7 DECIMAL POINT ........ ===> . (. or ,) 8 STOP IF RETURN CODE >= ===> 8 (Lowest terminating return code) 9 NUMBER OF ROWS ===> 20 (For ISPF Tables) 10 CHANGE HELP BOOK NAMES?===> NO (YES to change HELP data set names) 11 AS USER ===> (Userid to associate with the trusted connection) PRESS: ENTER to process END to cancel HELP for more informationThe DB2I DEFAULTS PANEL 2 panel for COBOL is then displayed.
- Complete the DB2I DEFAULTS PANEL 2 panel, shown in the following
figure, as needed and press Enter to save the new defaults, if any.
Figure 2. The COBOL defaults panel. Shown only if the field APPLICATION LANGUAGE on the DB2I DEFAULTS PANEL l panel is IBMCOB. DSNEOP02 DB2I DEFAULTS PANEL 2 COMMAND ===>_ Change defaults as desired: 1 DB2I JOB STATEMENT: (Optional if your site has a SUBMIT exit) ===> //ADMF001A JOB (ACCOUNT),'NAME' ===> //* ===> //* ===> //* COBOL DEFAULTS: (For IBMCOB) 2 COBOL STRING DELIMITER ===> DEFAULT (DEFAULT, ' or ") 3 DBCS SYMBOL FOR DCLGEN ===> G (G/N - Character in PIC clause)The DB2I Primary Option menu is displayed.
- Generate the table and host structure declarations by completing
the following actions:
- On the DB2I Primary Option menu, select the DCLGEN option and press Enter to display the DCLGEN panel.
- Complete the fields as shown in the following figure and press
Enter.
Figure 3. DCLGEN panel—selecting source table and destination data set DSNEDP01 DCLGEN SSID: DSN ===> Enter table name for which declarations are required: 1 SOURCE TABLE NAME ===> DSN8D10.VPHONE 2 TABLE OWNER ..... ===> 3 AT LOCATION ..... ===> (Optional) Enter destination data set: (Can be sequential or partitioned) 4 DATA SET NAME ... ===> TEMP(VPHONEC) 5 DATA SET PASSWORD ===> (If password protected) Enter options as desired: 6 ACTION .......... ===> ADD (ADD new or REPLACE old declaration) 7 COLUMN LABEL .... ===> NO (Enter YES for column label) 8 STRUCTURE NAME .. ===> (Optional) 9 FIELD NAME PREFIX ===> (Optional) 10 DELIMIT DBCS .... ===> YES (Enter YES to delimit DBCS identifiers) 11 COLUMN SUFFIX ... ===> NO (Enter YES to append column name) 12 INDICATOR VARS .. ===> NO (Enter YES for indicator variables) 13 ADDITIONAL OPTIONS===> NO (Enter YES to change additional options) PRESS: ENTER to process END to exit HELP for more informationA successful completion message, such as the one in the following figure, is displayed at the top of your screen.Figure 4. Successful completion message DSNE905I EXECUTION COMPLETE, MEMBER VPHONEC ADDED ***Db2 again displays the DCLGEN screen, as shown in the following figure.
Figure 5. DCLGEN panel—displaying system and user return codes DSNEDP01 DCLGEN SSID: DSN ===> Enter table name for which declarations are required: 1 SOURCE TABLE NAME ===> DSN8D10.VPHONE 2 TABLE OWNER ..... ===> 3 AT LOCATION ..... ===> (Optional) Enter destination data set: (Can be sequential or partitioned) 4 DATA SET NAME ... ===> TEMP(VPHONEC) 5 DATA SET PASSWORD ===> (If password protected) Enter options as desired: 6 ACTION .......... ===> ADD (ADD new or REPLACE old declaration) 7 COLUMN LABEL .... ===> NO (Enter YES for column label) 8 STRUCTURE NAME .. ===> (Optional) 9 FIELD NAME PREFIX ===> (Optional) 10 DELIMIT DBCS .... ===> YES (Enter YES to delimit DBCS identifiers) 11 COLUMN SUFFIX ... ===> NO (Enter YES to append column name) 12 INDICATOR VARS .. ===> NO (Enter YES for indicator variables) 13 ADDITIONAL OPTIONS===> NO (Enter YES to change additional options) PRESS: ENTER to process END to exit HELP for more information - Press Enter to return to the DB2I Primary Option menu.
- Exit from DB2I.
- Examine the DCLGEN output by selecting either the browse or the
edit option from the ISPF/PDF menu to view the results in the specified
data set member.
For this example, the data set to edit is prefix.TEMP.COBOL(VPHONEC). This data set member contains the following information.
***** DCLGEN TABLE(DSN8D10.VPHONE) *** ***** LIBRARY(SYSADM.TEMP.COBOL(VPHONEC)) *** ***** QUOTE *** ***** ... IS THE DCLGEN COMMAND THAT MADE THE FOLLOWING STATEMENTS *** EXEC SQL DECLARE DSN8D10.VPHONE TABLE ( LASTNAME VARCHAR(15) NOT NULL, FIRSTNAME VARCHAR(12) NOT NULL, MIDDLEINITIAL CHAR(1) NOT NULL, PHONENUMBER VARCHAR(4) NOT NULL, EMPLOYEENUMBER CHAR(6) NOT NULL, DEPTNUMBER CHAR(3) NOT NULL, DEPTNAME VARCHAR(36) NOT NULL ) END-EXEC. ***** COBOL DECLARATION FOR TABLE DSN8D10.VPHONE ****** 01 DCLVPHONE. 10 LASTNAME. 49 LASTNAME-LEN PIC S9(4) USAGE COMP. 49 LASTNAME-TEXT PIC X(15). 10 FIRSTNAME. 49 FIRSTNAME-LEN PIC S9(4) USAGE COMP. 49 FIRSTNAME-TEXT PIC X(12). 10 MIDDLEINITIAL PIC X(1). 10 PHONENUMBER. 49 PHONENUMBER-LEN PIC S9(4) USAGE COMP. 49 PHONENUMBER-TEXT PIC X(4). 10 EMPLOYEENUMBER PIC X(6). 10 DEPTNUMBER PIC X(3). 10 DEPTNAME. 49 DEPTNAME-LEN PIC S9(4) USAGE COMP. 49 DEPTNAME-TEXT PIC X(36). ***** THE NUMBER OF COLUMNS DESCRIBED BY THIS DECLARATION IS 7 ******You can now pull these declarations into your program by using an SQL INCLUDE statement.