Opening a table

This section details the codes for opening tableBASE tables.

Open for Read (OR)

If a table is opened for read, it may not be subsequently stored. It may be updated in memory when the program is running in batch. If the table to be opened has a read or write password then a password will be required to complete this command. For more information see Open for Read (OR).

Open for Write (OW)

A table opened for write may be stored. If the table to be opened has a write password then a password will be required to complete this command. No other program operating in any region of any MVS image sharing the tableBASE library will be allowed to open this table for write, until the program that issued the open for write closes or releases the table. For more information see Open for Write (OW), Close Table (CL), and Release Table (RL).


A table which is opened will have assigned to it an OPEN STATUS in the DEFINITION-BLOCK (see DEFINITION-BLOCK (256 bytes)). Before executing a command, tableBASE checks the open status of the table. Some tableBASE commands require the table to be open, while others require it to be closed. Some commands will cause the table to be opened for read automatically if it is not already open, as in the following section, “Implicit table opens”.

Implicit table opens

Unlike most databases, tableBASE allows for implicit table opens. A table may be implicitly opened if a retrieval is issued for a table that is not already open and for which no read password is required. With an implicit open, tableBASE will attempt to automatically open the most recent generation of the table for read.

The attempt will be successful, only if:

  1. No read password is required
  2. The Implicit Open facility has not been disabled at installation time, by TBOPT Switch settings,  or through the use of a Change Status command.

Implicit opening of a table is performed, subject to the above restrictions, by the following commands: SK, FK, GF, GN, GP, GL, FC, FG, FN, CN and DU.

While an explicit open of a table zeroes the count field in the Command Area for all commands, an implicit open does not zero it for the FC, IC, RC, DC, and DU commands.

A closed table will be implicitly opened for read by any of the update commands (IC, DC, RC, IK, DK, RK, MT, CD) only if it is done by a single-tasked batch application not operating on a VTS-TSR. Tables that are opened for read, such as those opened implicitly, cannot be stored. To store the table, it must be opened for write.

Although the implicit table open facility is often useful, in general, it is good practice to explicitly open tables. By doing this, the code that processes error conditions for an open failure can be isolated and need not be repeated for subsequent retrieval or updating operations.

The implicit table open feature may be permanently disabled when tableBASE is installed, by use of the TBOPTGEN facility, or for a region by use of the TBOPT parameter, or temporarily disabled with the Change Status (CS) command.

In a multi-tasking environment, however, it is recommended that you do not disable this feature. In a multi-tasking or multi-user online environment, a table could be opened for read by one user and subsequently opened for read and closed by another user (who is not aware of the first). In such a situation, leaving the implicit open feature on will ensure that the table be automatically re-opened when the original user executes the next retrieval command.