DISCONNECT function for CAF
The CAF DISCONNECT function terminates a connection to Db2.
DISCONNECT removes the calling task's connection to Db2. If no other task in the address space has an active connection to Db2, Db2 also deletes the control block structures that were created for the address space and removes the cross memory authorization.
If an OPEN call is in effect, which means that a plan is allocated, when the DISCONNECT call is issued, CAF issues an implicit CLOSE with the SYNC parameter.
Using the DISCONNECT function is optional. Consider the following rules and recommendations about when to use and not use the DISCONNECT function:
- Only those tasks that explicitly issued a CONNECT call can issue a DISCONNECT call. If a CONNECT call was not used, a DISCONNECT call causes an error.
- When shutting down your application you can improve the performance of this shut down by explicitly calling the DISCONNECT function before the task terminates. If you omit the DISCONNECT call, Db2 performs an implicit DISCONNECT. In this case, Db2 performs the same actions when your task terminates.
- If Db2 terminates, any task that issued a CONNECT call must issue a DISCONNECT call to reset the CAF control blocks. The DISCONNECT function returns the reset accomplished return codes and reason codes (+004 and X'00C10824'). This action ensures that future connection requests from the task work when Db2 is back on line.
- A task that did not explicitly issue a CONNECT call must issue a CLOSE call instead of a DISCONNECT call. This action resets the CAF control blocks when Db2 terminates.
The following diagram shows the syntax for the DISCONNECT function.
- function
- A 12-byte area that contains the word DISCONNECT followed by two blanks.
- retcode
- A 4-byte area in which CAF places the return code.
This field is optional. If you do not specify retcode, CAF places the return code in register 15 and the reason code in register 0.
- reascode
- A 4-byte area in which CAF places a reason code.
This field is optional. If you do not specify reascode, CAF places the reason code in register 0. If you specify reascode, you must also specify retcode.
Examples of CAF DISCONNECT calls
The following table shows a DISCONNECT call in each language.
Language | Call example |
---|---|
Assembler |
|
C1 |
|
COBOL |
|
Fortran |
|
PL/I1 |
|
- For C and PL/I applications, you must include the appropriate compiler directives, because DSNALI is an assembler language program. These compiler directives are described in the instructions for invoking CAF.