Detecting whether the CICS attachment facility is operational

Before you execute SQL statements in a CICS® program, you should determine if the CICS attachment facility is available. You do not need to do this test if the CICS attachment facility is started and you are using standby mode.

About this task

When an SQL statement is executed, and the CICS attachment facility is in standby mode, the attachment issues SQLCODE -923 with a reason code that indicates that Db2 is not available.

Procedure

To detect whether the CICS attachment facility is operational:

Use the INQUIRE EXITPROGRAM command for the CICS Transaction Server in your application.
The following example shows how to use this command. In this example, the INQUIRE EXITPROGRAM command tests whether the resource manager for SQL, DSNCSQL, is up and running. CICS returns the results in the EIBRESP field of the EXEC interface block (EIB) and in the field whose name is the argument of the CONNECTST parameter (in this case, STST). If the EIBRESP value indicates that the command completed normally and the STST value indicates that the resource manager is available, you can then execute SQL statements.
STST     DS    F
ENTNAME  DS    CL8
EXITPROG DS    CL8
⋮
         MVC   ENTNAME,=CL8'DSNCSQL'
         MVC   EXITPROG,=CL8'DSN2EXT1'
         EXEC CICS INQUIRE EXITPROGRAM(EXITPROG)                       X
               ENTRYNAME(ENTNAME) CONNECTST(STST) NOHANDLE
         CLC   EIBRESP,DFHRESP(NORMAL)
         BNE   NOTREADY
         CLC   STST,DFHVALUE(CONNECTED)
         BNE   NOTREADY
UPNREADY DS    0H
         attach is up
NOTREADY DS    0H
         attach is not up yet

If you use the INQUIRE EXITPROGRAM command to avoid AEY9 abends and the CICS attachment facility is down, the storm drain effect can occur. The storm drain effect is a condition that occurs when a system continues to receive work, even though that system is down.