TSO

Team-Fly    

 
DB2 Universal Database for OS/390 v7.1 Application Certification Guide
By Susan Lawson
Table of Contents
Chapter 14.  Attachment Programming

TSO

The TSO attachment facility is the default and most frequently used interface. This interface is used in both foreground and background modes and all programs that use the TSO attachment must run under TSO. The reverse, however, is not true, as programs running under TSO may use the TSO attachment facility, CAF, or RRSAF.

Capabilities

The TSO attachment facility provides the main interface to DB2 for developers and administrators. Running in the TSO foreground environment, programs can be invoked by ISPF panels or use the Dialog Manager interfaces. Programs can be tested interactively using the TSO TEST command or the IBM Debug Tool.

Many of the DSN subcommands, like BIND, are necessary for implementation of application programs. The DB2I panels provided by IBM supply an administrative interface that uses the TSO attachment.

Restrictions

The TSO user or batch job must execute on the same MVS image as the DB2 subsystem.

Requirements

In order to use the TSO attachment, the DB2 load libraries must be in the link list or steplib concatenation of the TSO user or batch job.

Execution

The DSN command processor is used to execute programs that use the TSO attachment facility. The DSN command can be used in interactive mode or background mode. In either mode, the RUN subcommand is used to invoke the application program, as in the following example:

 //MYJOB  JOB  //BKGRND EXEC PGM=IKJEFT01 //SYSPRINT DD  SYSOUT=* //SYSOUT   DD  SYSOUT=* //SYSTSPRT DD  SYSOUT=* //SYSTSIN  DD  *   DSN SYSTEM(DSN1)       RUN PROGRAM(MYPGM) PLAN(MYPGM) -           LIBRARY(MY.LOADLIB)   END /* // 

This differs from non-DB2 program execution where the application program name would normally be specified on the EXEC card in the Job Control Language (JCL). Instead, one of the TSO background programs is used. TSO background jobs read the SYSTSIN DD statement as if it were a terminal and send their output to the SYSTSPRT DD statement.

The DSN command processor establishes a connection to the specified (or default) DB2 subsystem. The TSO input stream is then read for subcommands, which are processed sequentially.

The RUN subcommand tells the DSN command processor to invoke a program specified by the PROGRAM parameter. The BIND parameter specifies the plan name that will be used for DB2 database access. The LIBRARY parameter specifies the load library where the program resides. If the LIBRARY parameter is omitted, the program will be loaded from the standard STEPLIB or link list libraries.

Units of Work

Because TSO is not a transaction manager, DB2 controls the logical unit of work (UOW) for programs using this attachment. There is no two-phase commit processing for programs running with the TSO interface. A UOW starts when the first DB2 object updates occur. It ends when one of the following conditions occur:

  • The program issues a COMMIT statement.

  • The program issues a ROLLBACK statement.

  • The program terminates and returns to the DSN command processor, which returns to the TSO Terminal Monitor Program (TMP).

A commit point occurs when you issue a COMMIT statement or your program terminates normally. Before you can connect to another DBMS, you must issue a COMMIT statement. If the system fails at this point, DB2 cannot know that your transaction is complete. In this case, as in the case of a failure during a one-phase commit operation for a single subsystem, you must make your own provision for maintaining data integrity. If your program abends or the system fails, DB2 backs out uncommitted data changes. Changed data returns to its original condition without interfering with other system activities.

Program Characteristics

There are some specific characteristics for coding programs to use the TSO attachment facility.

Initialization

Programs using the TSO attachment do not require any special code. The DB2 high-level interface module (DSNELI) takes care of the work. We're running under the DSN command processor, so the connection to DB2 has already been established.

Application programs running under the TSO attachment facility do not need to code CONNECT statements when using the local DB2 subsystem. They can issue CONNECT statements to connect to remote databases defined in the local communications database.

SQL Processing

Programs use embedded SQL statements. The DB2 precompiler translates the statements into the appropriate language calls to the high-level interface module.

Error Checking

Programs running under the TSO attachment should check the SQLCODE or SQLSTATE returned by DB2 to determine the status of each SQL statement. Programs may call the IBM-supplied routine DSNTIAR to generate error messages for most failure codes.

Termination

Normal termination is achieved by returning control to the caller, which in this case is the DSN command processor. DB2 will commit any work in progress, clean up, and finish the RUN subcommand. Abnormal program termination due to system abends or application-invoked abort processing will result in DB2 rolling back the UOW.

DB2 Abend

If DB2 abends while an application is running, the application is rolled back to the last commit point. If DB2 terminates while processing a commit request, DB2 either commits or rolls back any changes at the next restart. The action taken depends on the state of the commit request when DB2 terminates.


Team-Fly    
Top


DB2 Universal Database for OS. 390 v7. 1 Application Certification Guide
DB2(R) Universal Database for OS/390 V7.1 Application Certification Guide (IBM DB2 Certification Guide Series)
ISBN: 0131007718
EAN: 2147483647
Year: 2002
Pages: 163
Authors: Susan Lawson

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