|< Day Day Up >|
CAF (Call Attach Facility)
CAF programs can be executed as one of the following:
CAF is used to control a program's connection to DB2, as shown in Figure 18.30. The DB2 program communicates to DB2 through the CAF language interface, DSNALI . The primary benefit of using CAF is that the application can control the connection with CAF calls. Five CAF calls are used to control the connection:
Figure 18.30. The Call Attach Facility.
Typically, a control program is created to handle the establishment and termination of the DB2 connection. It is the CAF module shown in Figure 18.30. Although this module is not required, it is recommended so that you can eliminate the repetitious coding of the
CAF programs must be link-edited with the CAF language interface module, DSNALI .
Thread Creation and Use
Figure 18.31. Explicit CAF thread creation.
As I mentioned in the TSO section, an online TSO/DB2 program can tie up a thread for a long time when the
command is used to attach to DB2. When users of this type of application
If the program instead uses CAF to create a thread, each time the
The second method of thread creation is shown in Figure 18.32. This figure shows the implicit creation and termination of CAF threads. If the OPEN and CLOSE calls are not used, a thread is created when the first SQL statement is issued.
Figure 18.32. Implicit CAF thread creation.
Benefits and Drawbacks of CAF
Before deciding to use CAF, you should consider all the
One benefit of using CAF is that it provides explicit control of thread creation. In addition, CAF is more efficient than DSN because of the
CAF has its drawbacks too, though. For example, CAF requires more complex error handling procedures. DSN automatically formats error messages for connection failures, but CAF returns only a return code and a reason code. Another drawback is that DSN handles the connection automatically, but CAF requires the program to handle the connection. These drawbacks can be eliminated, however, if you modify the CAF interface module used at your site. Note that by modifying the CAF module your shop must support logic that
Some vendor tools provide an interface to the Call Attach Facility. They are
Sample CAF Code
You can use several sample CAF programs provided with DB2 as models for the development of your own CAF applications. These programs follow:
|< Day Day Up >|