The CAF is a general purpose facility that can be used to establish threads from nearly any MVS address space (IMS and CICS are special exceptions). The DB2/SQL Service of Shadow REXXTOOLS use the CAF in two ways. First, the CAF is called implicitly, whenever an SQL statement is executed and the SQL host command environment routines detect that a plan has not been opened. Second, you can explicitly call the CAF using the DSNALI function. Each of these methods are discussed in the sections that follow.
Implicit OPENs | Using DSNALI |
Note: You may also dynamically modify the default plan and
subsystem name using the
OPTIONS
statement.
Using DSNALI
You can explicitly control the DB2 subsystem to which your
program is connected and the name of the plan to be opened,
using the
DSNALI
function. An example OPEN call is shown in the program fragment
that follows:
if dsnali("open", "dsna", "sdbr1010") <> 0 then do say "Open for plan failed. RC="rc "REASON="reason exit rc endIn this example, the DB2 subsystem to be connected to is "DSNA" and the plan to be opened is the "SDBR1010" plan that is bound using the "repeatable read" isolation parameter.
DSNALI can also be used with the DB2INFO function to make your programs portable from one system to another. In the following example, DB2INFO is called to determine the name of the default DB2 subsystem (returned in $SWXDB2_SSID), which is then used in the DSNALI OPEN call:
call db2info "defaults" if dsnali("open", $swxdb2_ssid, "sdbc1010") <> 0 then do say "Open for plan failed. RC="rc "REASON="reason exit rc endTo close a plan and terminate an active thread, you use the CLOSE option of DSNALI, shown below:
if dsnali("close", "sync") <> 0 then do say "Close for plan failed. RC="rc "REASON="reason exit rc endThe termination option "sync" ensures that DB2 will commit all changes before closing the plan.