Tuesday, 16 February 2021

COBOL DB2 Compilation Process | DB2 Precompilation Process | DB2 Precompiler | DB2 Coprocessor.

COBOL DB2 Precompiler, COBOL+Db2+CICS

COBOL DB2 Compilation Process (COBOL+DB2)

DB2 precompilation is the first step in the COBOL DB2 program Compilation Process.  DB2 precompilation is mandatory because host language compilers cannot process a SQL statement. DB2 precompiler or DB2 SQL coprocessor processes the embedded SQL statements.

Scenario: Let’s say you have been asked to compile a COBOL DB2 program but being a new team member you don’t know how to compile a COBOL DB2 program or what the steps are involved in compiling a COBOL DB2 program.

In this session, you’ll learn the basic concept of the  DB2 precompilation process. You’ll get an overview of the DB2 precompiler, DB2 coprocessor, Database Request Model (DBRM), and Consistency token. You'll go through a complete flow diagram of the COBOL compilation process. Let’s get started with the COBOL DB2 compilation process.

COBOL+DB2 Compliation Process - Agenda. 

  • Introduction to DB2 precompilation process. 
  • What are COBOL DB2 Programs or DB2 Applications?
  • DB2 Precompilation process functions. 
  • DB2 precompiled flow diagram.
  • DB2 coprocessor flow diagram.
  • COBOL DB2 programming performance tips.
  • Conclusion.

Introduction to DB2 precompilation process. 

COBOL DB2 Applications included SQL statements to perform various data manipulation operations and SQL statements cannot be processed by host language compiler such as COBOL, C++, Java, etc. To process these SQL statements, you required either a DB2 precompiler or DB2 coprocessor.

What is COBOL DB2 Program or COBOL DB2 Application?

In layman term, a COBOL program that reads or write data to the DB2 database with the help of an SQL statement is known as COBOL DB2 program. Refer to details below. 

COBOL DB2 Programs, COBOL DB2 batch program

DB2 Precompilation Function 


Why do you need a DB2 precompilation process for any COBOL DB2 application?

COBOL DB2 Applications included SQL statements to perform various data manipulation operations and SQL statements cannot be processed by host language compilers such as COBOL, C++, Java, etc. To process these SQL statements, you required either a DB2 precompiler or a DB2 coprocessor.

SQL statement processor performs the following actions:
  1. Replaces the embedded SQL statements with equivalent calls to DB2 language interface modules.
  2. Generate a database request module (DBRM), which communicates your embedded SQL requests to the DB2 database engine during the binding process.

Now. let's focus on the DB2 precompilation process by using the DB2 precompiled.




COBOL Db2 Compilation process

DB2 Precompilation Process by using DB2 precompiled.


COBOL DB2 Compilation Process 

COBOL DB2 program compilation process is slightly different from the normal COBOL program compilation process. Now, let's try to understand the flow:

  1. COBOL DB2 program source code is processed by a DB2 precompiler. It generates two outputs (i.e. Modified Source code and Database Request Module (DBRM)).
  2. Modified source code is a compiled and link-edit like a simple COBOL program because it does not have any SQL statements. The SQL statements are already replaced with an equivalent call to the DB2 language interface.
  3. Database request modules (DBRM) are bind into the package or directly into an application plan. The DB2 bind process converts the SQL statement into an executable runtime instruction.

Note: DB2 Bind process performs three important functions. First, it verifies that you are authorized to do a bind. Second, it validates your SQL statement syntax. Third, the DB2 optimizer will turn your SQL statement into an executable code after SQL query optimization. Also, DBRM includes a consistency token to distinguish it from other DBRM which is derived from the other version of the program.

Now. let's focus on the DB2 precompilation process by using the DB2 coprocessor processor.

DB2 coprocessor. COBOL Db2 precompilation

DB2 precompilation by using DB2 coprocessor.


Now, if you look at the DB2 precompiler and DB2 coprocessor diagram, then you can easily make out the difference.

DB2 precompilation by using DB2 coprocessor.

When you use DB2 coprocessor the compiler automatically handles your source code that contains embedded SQL statements. You don’t require a separate pre-compiled step.

When the compiler encounters the SQL statement in the source program it interfaces with the DB2 coprocessor and the complete SQL statement between EXEC SQL and END SQL is passed to the DB2 SQL statement coprocessor.

DB2 coprocessor analyses SQL statement and indicate compiler to generate native COBOL statement corresponding to the SQL statement and the remaining process of generating a load module and binding DBRM into a plan or a package will remain the same.

Note: You’ve to specify the SQL compiler option to use DB2 coprocessor instead of DB2 pre-compiler.

Topictrick Youtube: The DB2 precompilation process is associated with a youtube video tutorial.




Conclusion. 

Finally, this marks an end to our today's COBOL+DB2 compilation process tutorial. COBOL DB2 compilation process is a two-step process i.e. COBOL+DB2 Pre compilation process and COBOL program compilation process.  Do check out COBOL LEVEL 88 Condition.


Subscribe to Topictrick & Don't forget to press THE BELL ICON to never miss any updates. Also, Please visit mention the link below to stay connected with Topictrick and the Mainframe forum on - 

► Youtube
► Facebook 
► Reddit

Thank you for your support. 
Mainframe Forum™

No comments:

Post a Comment