A user wishes to access a table in order to modify its contents and store them, a single intent that may or may not consist of several transactions. For example, the normal flow of transactions might be an open for write, multiple update transactions, and a final transaction to cause the table to be stored (ST) and closed (CL).
Obtain an exclusive copy
To obtain an exclusive copy of a table which may be retained for several transactions, the user must issue an Open Write command. If the table is already opened for read, tableBASE will verify that the generation on the library is the same as that in memory. If it is the same generation, tableBASE will immediately open the table for write.
Any subsequent attempts to open a table for write when it is already opened for write will be returned to the application with a non-zero ERROR code (or an abend if that option is selected). Once the original transaction (or user with multiple transactions) has completed updating, the table can be released with the RL or CL command so that another user/transaction in another region can proceed with updating.
Protecting an open table
While a password can be used to provide security to a table in a library, the LOCK-LATCH password provides limited security for an open table. See 9. LOCK-LATCH (8 bytes) for more information.
Some examples of the use of the LOCK-LATCH field follow:
- If it is desired to share a table for updating, such as a posting table described in the Posting scenario below, the LOCK-LATCH password can be set to a value known by all users in the group.
- If it is desired that a table be updated by only one application at a time, although by as many tasks and transactions within that application as desired, the LOCK-LATCH password can be set to some application specific identifier.
- If it is desired that only tasks which are the same transactions should be updating the table simultaneously, the LOCK-LATCH password can be the Transaction ID.
- Alternatively, the LOCK-LATCH password could be set to a particular USERid to ensure exclusive control.