Checking the connection status
When it is possible to have a read-only connection, your program should check the status of the connection before doing any committable updates. This prevents the unit of work from entering the rollback required state.
The following COBOL example shows how to check the connection status. Figure 1. Example of checking connection status
… EXEC SQL SET CONNECTION SYS5 END-EXEC. … * Check if the connection is updatable. EXEC SQL CONNECT END-EXEC. * If connection is updatable, update sales information otherwise * inform the user. IF SQLERRD(3) = 1 THEN EXEC SQL INSERT INTO SALES_TABLE VALUES(:SALES-DATA) END-EXEC ELSE DISPLAY 'Unable to update sales information at this time'. …
Parent topic:
Distributed unit of work