An Example: Open, Store, and Close a Table

Before issuing a call to access a row, a table and its desired action needs to be specified to tableBASE. For example, to open a fictitious table called PAYROLL, code something like:

MOVE 'OR'          TO    PAYROLL-COMMAND.
CALL 'TBLBASE'     USING TB-PARM
                         PAYROLL-COMMAND-AREA.

It is assumed that the table has been identified in PAYROLL-COMMAND-AREA. If not, precede the above code with:

MOVE 'PAYROLL'     TO PAYROLL-TABLE.

Above, OR means that the table will be opened for read-only access. The OW command opens a table for read and write access. Once the table is read from the library into memory, all operations take place in memory. If changes to the table need to be saved, the table must be stored into the library using the Store command, like in the following example:

MOVE 'ST'          TO    PAYROLL-COMMAND.
CALL 'TBLBASE'     USING TB-PARM
                         PAYROLL-COMMAND-AREA.

When a table is opened, tableBASE allocates space in memory to accommodate the table. The table is loaded into the TSR. For a retrieval request, tableBASE searches the table according to its organization and search strategy, and returns the requested row to the application program.

All table accesses are performed in memory. Organization and search methods can be modified dynamically in memory. The table remains in memory until the table is closed or the TSR holding the table terminates.

An example of code that closes a table is:

MOVE 'CL'          TO    PAYROLL-COMMAND.
CALL 'TBLBASE'     USING TB-PARM
                         PAYROLL-COMMAND-AREA.
Note:
Closing a table does not store it.