Running a DB2 Program

 <  Day Day Up  >  

After a program has been prepared as outlined in Figure 13.1, two separate, physical components have been produced: a DB2 plan and a link edited load module. Neither is executable without the other. The plan contains the access path specifications for the SQL statements in the program. The load module contains the executable machine instructions for the COBOL statements in the program.

If you attempt to run a load module for a DB2 program outside the control of DB2, the program will abend when it encounters the first SQL statement. Furthermore, a load module is forever tied to a specific DBRM ”the DBRM produced by the same precompile that produced the modified source used in the link-edit process that produced the load module in question.

When you run an application program containing SQL statements, you must specify the name of the plan that will be used. The plan name must include the DBRM that was produced by the precompile process in the program preparation that created the load module being run. This is enforced by a timestamp token placed into both the DBRM and the modified source by the DB2 precompiler. At execution time, DB2 checks that the tokens indicate the compatibility of the plan and the load module. If they do not match, DB2 will not allow the SQL statements in the program to be run. A -818 SQL code is returned for each SQL call attempted by the program.

DB2 programs can be executed in one of following four ways:

  • Batch TSO

  • Call attach

  • CICS

  • IMS

Listing 13.1 provides the JCL to execute the program using TSO batch. For information about other methods , see Chapter 18.

Listing 13.1. Running a DB2 Program in TSO Batch
 //DB2JOBB  JOB (BATCH),'DB2 BATCH',MSGCLASS=X,CLASS=X, //      NOTIFY=USER //* //************************************************************ //* //*         JCL TO RUN A DB2 PROGRAM IN BATCH //*         USING THE TSO TERMINAL MONITOR PROGRAM //* //************************************************************ //* //JOBLIB     DD DSN=SYS1.DB2V810.DSNEXIT,DISP=SHR //           DD DSN=SYS1.DB2V810.DSNLOAD,DISP=SHR //BATCHPRG   EXEC PGM=IKJEFT1B,DYNAMNBR=20 //SYSTSPRT   DD  SYSOUT=* //SYSPRINT   DD  SYSOUT=* //SYSUDUMP   DD  SYSOUT=* //SYSTSIN    DD  *   DSN SYSTEM(DSN)   RUN PROGRAM(  Place program name here  )  -   PLAN(  Place plan name here  )  -   LIB('SYS1.DB2V810.RUNLIB.LOAD')   END /* // 

 <  Day Day Up  >  


DB2 Developers Guide
DB2 Developers Guide (5th Edition)
ISBN: 0672326132
EAN: 2147483647
Year: 2004
Pages: 388

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net