Usually a restart of your application will correct the problem.
What I do in my DB2 applications is execute the same code, for example,
3-times for -904, -911, and -913. Basically give your application 3-tries before abendinig.
It works something like this:
01 WS-COUNTS.
05 WS-904-911-913-COUNT PIC 9(02) VALUE 0.
05 WS-904-911-913-MAX PIC 9(01) VALUE 3.
01 WS-SQLCODE PIC S9(03) VALUE ZERO.
88 SQL-UNAVAILABLE-RESOURCE VALUE -904.
88 SQL-ROLLBACK-DEADLOCK-TIMEOUT VALUE -911.
88 SQL-DEADLOCK-TIMEOUT VALUE -913.
88 SQL-904-911-913 VALUE -904
-911
-913.
MOVE ZERO TO WS-904-911-913-COUNT
PERFORM 850-DECLARE-CURSOR
THRU 859-EXIT
...
*----------------------------------
850-DECLARE-CURSOR.
*---------------------------------
EXEC SQL
DECLARE CUR1 INSENSITIVE SCROLL CURSOR
FOR SELECT GOODID,INDATE,INPIECE
FROM STSTORAGE
WHERE GOODID = :COMM-GOID
END-EXEC
MOVE SQLCODE TO WS-SQLCODE
*--- ALLOW FOR WS-904-911-913-MAX OCCURANCES (IE 3)
*--- OF -904, -911, -913.
IF SQL-904-911-913
ADD 1 TO WS-904-911-913-COUNT
IF WS-904-911-913-COUNT < WS-904-911-913-MAX
GO TO 850-DECLARE-CURSOR
END-IF
END-IF
IF SQL-SUCCESSFUL
CONTINUE
...
*------------
859-EXIT.
*------------
EXIT.
05 WS-904-911-913-COUNT PIC 9(02) VALUE 0.
05 WS-904-911-913-MAX PIC 9(01) VALUE 3.
01 WS-SQLCODE PIC S9(03) VALUE ZERO.
88 SQL-UNAVAILABLE-RESOURCE VALUE -904.
88 SQL-ROLLBACK-DEADLOCK-TIMEOUT VALUE -911.
88 SQL-DEADLOCK-TIMEOUT VALUE -913.
88 SQL-904-911-913 VALUE -904
-911
-913.
MOVE ZERO TO WS-904-911-913-COUNT
PERFORM 850-DECLARE-CURSOR
THRU 859-EXIT
...
*----------------------------------
850-DECLARE-CURSOR.
*---------------------------------
EXEC SQL
DECLARE CUR1 INSENSITIVE SCROLL CURSOR
FOR SELECT GOODID,INDATE,INPIECE
FROM STSTORAGE
WHERE GOODID = :COMM-GOID
END-EXEC
MOVE SQLCODE TO WS-SQLCODE
*--- ALLOW FOR WS-904-911-913-MAX OCCURANCES (IE 3)
*--- OF -904, -911, -913.
IF SQL-904-911-913
ADD 1 TO WS-904-911-913-COUNT
IF WS-904-911-913-COUNT < WS-904-911-913-MAX
GO TO 850-DECLARE-CURSOR
END-IF
END-IF
IF SQL-SUCCESSFUL
CONTINUE
...
*------------
859-EXIT.
*------------
EXIT.