Sample CAF scenarios
One or more tasks can use call attachment facility (CAF) to connect to Db2. This connection can be made either implicitly or explicitly. For explicit connections, a task calls one or more of the CAF connection functions.
A single task with implicit connections
The simplest connection scenario is a single task that makes calls to Db2 without using explicit CALL DSNALI statements. The task implicitly connects to the default subsystem name and uses the default plan name.
- If termination was normal, any database changes are committed.
- If termination was abnormal, any database changes are rolled back.
- The active plan and all database resources are deallocated.
- The task and address space connections to Db2 are terminated.
A single task with explicit connections
CONNECT
OPEN allocate a plan
SQL or IFI call
···
CLOSE deallocate the current plan
OPEN allocate a new plan
SQL or IFI call
···
CLOSE
DISCONNECT
A task can have a connection to only one Db2 subsystem at any point in time. A CAF error occurs if the subsystem name in the OPEN call does not match the subsystem name in the CONNECT call. To switch to a different subsystem, the application must first disconnect from the current subsystem and then issue a connect request with a new subsystem name.
Multiple tasks
TASK 1 TASK 2 TASK 3 TASK n
CONNECT
OPEN OPEN OPEN
SQL SQL SQL
... ... ...
CLOSE CLOSE CLOSE
OPEN OPEN OPEN
SQL SQL SQL
... ... ...
CLOSE CLOSE CLOSE
DISCONNECT