- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the usage and purpose of DCLGEN and host variables used in COBOL-DB2 program
A COBOL-DB2 program can query/update/insert/delete data from multiple DB2 tables. However, in order to achieve this, we must fulfill two main conditions.
Notify the structure of the DB2 table to the COBOL-DB2 program. This includes all the columns and data types of these columns.
The respective host variables for each column. The host variables are used in the program logic to move the data from DB2 to program and vice versa. There is one host variable for every table column based on its data type. For example, for a table column with data type CHAR(2), there should be a host variable with equivalent COBOL data type as PIC X(2).
The DCLGEN utility helps us to generate the table structures and host variables automatically. Using this utility, we just need to give the DB2 table name and it will return the table structure and the host variables in a PDS member. We can simply use this PDS member in our COBOL-DB2 program in the working storage section using the INCLUDE statement as below−
EXEC SQL INCLUDE ORDERD END-EXEC
The ORDERD is a PDS member which is generated using a DCLGEN utility. This will have the structure of the ORDERS table and host variables for all the columns. For example,the columns ORDER_ID and ORDER_DATE with data type as CHAR(30) and TIMESTAMP will have a host variable as ORDER-ID PIC X(30) and ORDER-DATE PIC X(26) respectively.If we want to use this host variable to move the data from DB2 to program, then we can have−
EXEC SQL EXEC SQL SELECT ORDER_DATE INTO :ORDER-DATE, FROM ORDERS WHERE ORDER_ID = :ORDER-ID END-EXEC END-EXEC
- Purpose and usage of SAVEPOINT in COBOL-DB2 program
- What is the purpose and usage of SQLCODE within the SQLCA in a COBOL-DB2 program
- What is the purpose and usage of “WHERE CURRENT OF” clause in a COBOL-DB2 program?
- What is the purpose and usage of “FOR UPDATE OF” clause in a COBOL-DB2 program
- How will the COBOL-DB2 program behave if the DCLGEN member is not included?
- How to use SQLCA in a COBOL-DB2 program? What is the purpose of SQLCA?
- Purpose and usage of ROW-ID and SEQUENCE in a DB2
- What is COBOL host variable equivalent for various DB2 data types?
- What is the purpose and usage of SCROLLABLE CURSOR in COBOLDB2 program?
- What is the usage of host variables in case of multi row fetch?
- What are the COBOL host variable equivalent for various DB2 data types?
- How will the COBOL-DB2 program behave when there is a mismatch between the host variable and number of columns in the SELECT statement?
- What is the definition and usage of alternate key in a DB2 table?
- Example and usage of JOINS in DB2
- What is the purpose and usage of ATOMIC and NON-ATOMIC clause in multi row insert?