Interview Questions   Tutorials   Discussions   Programs   

DB2 - Explain the precompilation process of cobol-db2 pgm?

asked mar August 20, 2014 11:33 AM  

Explain the precompilation process of cobol-db2 pgm?


1 Answers

answered By Mswami   0  
DB2 Precompilation:

Its function is to analyse the host language source module ie, the COBOL-DB2 program and stripping out all the db2 sql statements it finds and replaces them by the host language CALL statements to the DSNHLI module.

You have coded a program which includes some DB2 queries to fetch and/or update data in some database table. The next would be how to run this program.

The COBOL compiler does not understand the DB2 queries coded between EXEC SQL and END_EXEC. So to compile a COBOL-DB2 code, the first step is pre-compilation. The DB2 precompiler DSNHPC performs following activities.

1) Extracts all the SQL queries and prepare a DBRM.
2) Convert all the SQL queries in the source code into COBOL language calls, which can then be compiled by COBOL compiler. So the outcome is a modified code.
3) It also put a timestamp on both the DBRM and modified code. This timestamp is matched at the run time and should be same. If this is found to be different, then the job abends with the SQL code -818, which means - Timestamp Mismatch.

Once the modified code is generated, this code can be fed to the COBOL compiler and then to load editor to create the load module of this program.

On the other side, the DBRM is used to BIND the plan (or first the package and then plan). The plan is basically a optimized access path to execute the queries included in the DBRM. At this stage, Bind also checks for the existence of the table and essential authority of the programmer to perform the DB2 functions.

Now that we have the load module and plan ready, the program can be run using the utility IKJEFT01 giving these two names only as:

 RUN PROGRAM(Pgm_name) -

This is the brief of the compilation process.
   add comment

Your answer

Join with account you already have



Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!