Professional Documents
Culture Documents
DB 27 Prep
DB 27 Prep
DB2-Prep-1
Program Preparation
COBOL Program with Embedded SQL
DB2 Precompiler
DBRM
DB2 Catalog
Compile and Linkedit
Load Module Plan/Package
DB2-Prep-2
BIND
Pre-compiler
The Precompiler
Comments all SQL statements and replaces them with COBOL CALL statements Checks for errors Does not access the DB2 Catalog Places Consistency Token in the modified source program and the DBRM
DB2-Prep-3
Pre-compile parameters
BIND
The BIND routine Checks for errors, using the DB2 catalog Develops access strategy for each SQL statement Stores strategies as Plans or Packages
DB2-Prep-4
PLAN
PLAN
DBRM
DBRM
DBRM
DBRM
DBRM
DB2-Prep-6
BIND PLAN
BIND PLAN (PLAN1) MEMBER ( PROG1, PROG2, PROG3) LIBRARY (TRG1T01.DBRMLIB) QUALIFIER (TRG001) OWNER (TRG001) ..
DB2-Prep-7
PROG1
PROG2
PROG3
Optimization of all SQL statements in all DBRMs even if only one of them changes.
PLAN1
PLAN2
PLAN3
When the same DBRM is bound into multiple plans. all the plans need to be rebound when the DBRM changes.
PROG1
DB2-Prep-9
Package
Package
Package
Package
DBRM
DBRM
DBRM
DBRM
DB2-Prep-10
BIND PACKAGE
BIND PACKAGE (COLL1) MEMBER ( PROG1 ) LIBRARY (TRG1T01.DBRMLIB) OWNER (TRG001) QUALIFIER (TRG001) ..
DB2-Prep-11
Example:
loc1.coll1.prog1.test loc1.coll1.prog1
DB2-Prep-13
Collection
Collection
Collection
DBRM
Package
Package
Package
Package
Package
DBRM
DBRM
DBRM
DBRM
DBRM
DB2-Prep-14
DB2-Prep-15
Package Search
PLAN1
COLL1.*
COLL2.*
COLL3.*
PACK1
PACK2
PACK3
PACK4
PACK5
Search Direction
DB2-Prep-16
COLL2.*
COLL3.*
PACK1
PACK2
PACK3
PACK4
PACK5
Package Versions
Prog1 Prog1
TEST
PROD
Prog1
DBRMs
Prog1
With Packages, the precompiler option VERSION can be used to bind multiple versions of the programs into packages.
Prog1.prod Prog1.test
PACKAGE
DB2-Prep-12
VERSION Revisited
PROG1
Version(TEST)
Precompiler
Version(PROD)
BIND PACKAGE
BIND PACKAGE
PROG1
PRODUCTION LOAD LIBRARY
QUALIFIER Parameter
SELECT NAME
FROM
EMPLOYEE
PROG1
TEST
QUALIFIER
PROD
TEST.EMPLOYEE
PROD.EMPLOYEE
DB2-Prep-20
ACQUIRE
ACQUIRE(USE) - Opens table spaces and acquires locks only when the application program bound to the plan first uses them. ACQUIRE(ALLOCATE) - Opens all table spaces and acquires all table space locks when the plan is allocated. ACQUIRE(USE) - Fixed for Packages
DB2-Prep-21
RELEASE
RELEASE(COMMIT) Releases resources at each commit point RELEASE(DEALLOCATE) Releases resources only when the application plan terminates.
DB2-Prep-22
CONCURRENCY
ISOLATION : RR
Row1
Row2 LOCK LOCKS LOCKS Row3
ISOLATION : CS
Row1
Row2 LOCK LOCKS LOCKS Row3
DB2-Prep-25
ISOLATION : UR
DB2-Prep-26
Repeatable Read (RR) Cursor Not Possible Stability (CS) Uncommitted Possible Read (UR)
VALIDATE
How to handle "OBJECT NOT FOUND" and "NOT AUTHORIZED" errors that occur at bind time.
RUN - At run-time if failed during bind time BIND - Only during Bind time
DB2-Prep-28
ACTION
ADD Add a new plan/package that does not already exist REPLACE replace old plan/package with a new one of the same name
COPY Parameter
BIND PACKAGE (MYCOLL1) COPY (MYCOLL2.PACK1) COPYVER(PROD) .. COPY - SQL statements from an existing package are copied to the package
DB2-Prep-30
FREE PLAN
FREE PLAN (PLAN1) Delete the plan PLAN1
DB2-Prep-32
FREE PACKAGE
FREE PACKAGE(MYCOLL1.*) FREE PACKAGE(MYCOLL1.MYPACK1)
FREE PACKAGE(MYCOLL1.MYPACK1.TEST)
DB2-Prep-33
bind jcl
//BINDDBZ1 EXEC PGM=IKJEFT01 //SYSUDUMP DD SYSOUT=* //SYSTSPRT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SYSTSIN DD * DSN SYSTEM(DBZ1) BIND LIBRARY(DBRM LIBRARY) ACTION(REPLACE), VALIDATE(BIND), ISOLATION(CS), FLAG(I), ACQUIRE(USE) , RELEASE(COMMIT), EXPLAIN (NO) , OWNER(SSG1T00) QUALIFIER(SSG1T01), PLAN (planname), MEMBER (dbrmname) END
Executing a Program
RUN PROGRAM(PROG1) PLAN(PLAN1) LIBRARY (TRG001.LOADLIB) PARMS (01-01-1996) RUN subcommand can be issued in the TSO foreground or in the TSO background as well as from the DB2I RUN panel
DB2-Prep-34
Run jcl
//SQLSTEP EXEC PGM=IKJEFT01 //SYSTSPRT DD SYSOUT=X //SYSTSIN DD * DSN SYSTEM(DBZ1) RUN PROGRAM(progname) PLAN(planname) LIBRARY (load library) END //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=*,DCB=LRECL=81 //SYSABOUT DD SYSOUT=* //SYSDBOUT DD SYSOUT=*
Load Module
Plan/Package
Consistency Token
DBRM
DB2-Prep-5