Find Access Path Selected by Optimizer for SQL Statement in DB2

Mandalika
Updated on 11-Sep-2020 12:45:17

607 Views

The access path gives us the path selected by the optimizers in order to fetch the result of the SQL query. It gives us an idea about what all indexes and parameters will be used by the optimizer.To get the details of the access path used for the SQL statements within COBOL-DB2 program we can use the EXPLAIN option during the BIND step. Below is the JCL step which can be used.//BIND EXEC PGM=IKJEFT01 //STEPLIB DD DSN=DIS.TEST.LOADLIB, DISP=SHR //SYSOUT DD SYSOUT=* //SYSTSIN DD * DSN SYSTEM(TB3) BIND PLAN(PLANA) - PKLIST(PACKA) - ACQUIRE(ALLOCATE) - ISOLATION (RS) - EXPLAIN(YES) /*The EXPLAIN BIND ... Read More

Implement Isolation Levels CS, RR, UR, and RS in a DB2 Program

Mandalika
Updated on 11-Sep-2020 12:39:53

8K+ Views

The isolation level defines the degree to which the DB2 data which is being accessed in the COBOL-DB2 program is isolated with another parallelly executing COBOL- DB2 program. There are 4 main types of Isolation levels in DB2.Cursor stability (CS) - The cursor stability isolation level locks only the current row which the program is accessing. As soon as the program shifts to the next row, the lock in the previous row gets released. The cursor stability fetches only committed rows for the program to access. This is a default isolation level.Read stability (RS) - This isolation level places a ... Read More

Implementation of Table Level Locks in a COBOL DB2 Program

Mandalika
Updated on 11-Sep-2020 12:34:54

2K+ Views

The COBOL-DB2 program can place the lock into a DB2 table in two ways.When the SQL statement using that table is executed within the program.When the program is loaded in the main memory and it is ready to be executed. It acquires a lock on all the DB2 tables which are used in the SQL statements within the program.To acquire the lock on all DB2 tables once the program is loaded in the main memory or allocated to a thread, we have to BIND the plan using appropriate options and parameters. Below is a JCL step which can be used.//BIND ... Read More

Implementation of Table-Level Locks in COBOL DB2 Program During SQL Execution

Mandalika
Updated on 11-Sep-2020 12:30:31

1K+ Views

The locks in DB2 are acquired on table and tablespaces to avoid the issues arising due to LOST UPDATE, DIRTY READ and PHANTOM.We need to define the lock parameter during the BIND package/plan step using the ACQUIRE option.A COBOL-DB2 program PROGA is using SQL statements to access table TA. If we need to place a lock on the table only when that particular SQL statement is executed within the program, then we need to define the BIND JCL step as below−//BIND EXEC PGM=IKJEFT01 //STEPLIB DD DSN=DIS.TEST.LOADLIB, DISP=SHR //SYSOUT DD SYSOUT=* //SYSTSIN DD * DSN SYSTEM(TB3) BIND PLAN(PLANA) - PKLIST(PACKA) - ... Read More

Steps Involved in Compilation of a COBOL DB2 Program

Mandalika
Updated on 11-Sep-2020 12:22:04

13K+ Views

To prepare a COBOL-DB2 program for execution, we have to go through certain steps. These steps include pre-compilation - compilation - binding - linkediting.The pre-compilation is done using the utility DSNHPC. In the pre-compilation step all the SQL statements which are present in the source program are replaced by corresponding COBOL calls. All the SQL statements are taken in an object known as database resource module (DBRM) and passed on to the BIND step. The modified source code is passed on to the compilation step.In the compilation step, the modified source is compiled and the object module is generated. The ... Read More

Execution Result of Non-SQL Changes in DB2 Program Without Bind

Mandalika
Updated on 11-Sep-2020 12:15:33

314 Views

In each execution of a COBOL-DB2 program, the timestamp of load module and package/DBRM are compared. If there is a change in the length of the variable (and no SQL change) in the program and it is compiled, then the load module will have the newly generated timestamp and on the other hand if the BIND is not performed then the package/DBRM would have an old timestamp. When this program is executed, the JCL step calling this program will fail with SQL error code -818.If we have a COBOL-DB2 program for which SQL statement is never going to change in ... Read More

Execution Result of DB2 Program When Compiled and Bound on Separate Days

Mandalika
Updated on 11-Sep-2020 12:12:19

157 Views

The program will run successfully (unless there are no logical errors in the program)because the timestamp is inserted in the DBRM during pre-compilation and pre-compilation is done before the compilation step. Therefore, the DBRM and the load module will have the same timestamp.The timestamp inserted in the DBRM is further passed to the package also. So in case, if we are using DBRM-package-plan combination, In that case also the program will run successfully as there is the consistency in the timestamp throughout.

Binding DB2 Subprograms After Changes

Mandalika
Updated on 11-Sep-2020 12:07:32

892 Views

When any COBOL-DB2 program is pre-compiled, the current timestamp is inserted in the DBRM and if the DBRM is binded to a package then the timestamp is further copied to a package. Similarly, the timestamp is also inserted in the load module during the compilation process.When any COBOL-DB2 program is executed, the system matches the timestamp of the load module with that in the DBRM/package, if there is mismatch then the program fails.In case DBRM directly binds to a plan, we need to bind both the plans - PLANA and PLANB again even if only the subprogram has gone through ... Read More

Bind a DBRM into a Package and Package into a Plan

Mandalika
Updated on 11-Sep-2020 12:03:38

4K+ Views

A DBRM can be directly bound to a plan or we can first bind DBRM into a package and then bind that package into PLAN.In case DBRM binds to a plan directly, if there is some change in the source code, the new DBRM has to be generated and then we have to bind the entire plan again. Since, plan contains multiple DBRMs, the system will process all the DBRMs again in order to bind that plan (even if the other DBRMs have not gone through any changes). This process takes a lot of resources like memory, processor and valuable ... Read More

Bind a DBRM Directly into a Plan

Mandalika
Updated on 11-Sep-2020 11:56:40

745 Views

A DBRM is a DB2 object which is generated from the pre-compilation of the source code. It contains all the SQL statements/queries of the source code. DBRM could not be executed directly due to its format, hence it is binded into a plan first. There can be multiple DBRM which can be binded in a single plan.Whenever there is a source code change, corresponding DBRM has to be generated again with changed SQL statements/queries. Then the entire plan (which contains the old DBRM) has to be bound again.Using the below JCL step we can BIND a DBRM directly into a ... Read More

Advertisements