Command descriptions

Search (S)

The Search (S) command will cause the tag table to be searched for a match on the key.

Insert (I)

The Insert (I) will cause the row in ROW-WA to be inserted into the first empty primary table location—normally this is at the end. The Index to that primary table entry is placed in the tag table at the location pointed to by TAG-SUBSCRIPT.

If multiple tag tables are being used to access a table (reflecting multiple Indexes), each tag table must reflect the fact that a row has been inserted into the primary table. In this case a call to TBINDX is required using the same primary table and ROW-WA, but with each different tag table. To achieve this, subtract 1 from the NO-OF-ROWS before each of the subsequent calls to TBINDX using a different tag table. Since the inserted row is always placed at the end of the Data Table (primary table), the subsequent calls will not cause duplicate entries.

An insert into a sequential or hash table requires TAG-SUBSCRIPT to be set by the programmer or by a preceding search. When inserting into a random table the Index to the primary table entry is added to the end of the tag table, so TAG-SUBSCRIPT is ignored.

After an insert, check to determine if the insert was successful by checking OVERFLOW-CODE. If the code is set to Y, the insert was not successful because the primary or tag table was full.

A successful insert will cause NO-OF-ROWS to be incremented.

Delete (D)

The Delete (D) command will delete the row in the primary table pointed to by PRIMARY-SUBSCRIPT. PRIMARY-SUBSCRIPT must be set by the programmer or by a preceding search. The Index in the tag table (which points to this entry) will also be deleted. If the row is a hash table empty slot, the FOUND-CODE will be set to ‘N’ and the delete will not be done.

Delete will reduce NO-OF-ROWS by one.

Delete Indirect (E)

The Delete Indirect (E) command will delete the row in the primary table pointed to by the Tag Table entry pointed to by TAG-SUBSCRIPT. TAG-SUBSCRIPT must be set by the programmer or by a preceding search. The Index in the tag table pointed to by TAG-SUBSCRIPT will also be deleted.

Delete Indirect will reduce NO-OF-ROWS by one.

Update (U)

The Update (U) command (if not found) is a combination of search and insert. After an update, two tests must be done:

  • Determine whether or not the row was found by testing the FOUND-CODE;
  • If the row was not found, determine whether the attempt to insert failed due to an overflow in the size of the primary or tag table by testing the OVERFLOW-CODE.
Remove (R)

The Remove (R) command is a combination of search and delete.

The action was successful if the FOUND-CODE is set to Y. If that code is set to N, the row was not found and could not be deleted.

Put Direct (P)

The Put Direct (P) command will cause the row in ROW-WA to be moved to the primary table entry pointed to by PRIMARY-SUBSCRIPT. PRIMARY-SUBSCRIPT must be set by the programmer or by a preceding search.

Put Indirect (Q)

The Put Indirect (Q) command will cause the row in ROW-WA to be moved to the primary table entry pointed to by the Tag Table entry pointed to by TAG-SUBSCRIPT. TAG-SUBSCRIPT must be set by the programmer or by a preceding search. The TAG-SUBSCRIPT must not point to an empty hash row or the FOUND-CODE will be set to N and the Put will not be done.

Take Direct (T)

The Take Direct (T) command will cause the primary table entry pointed to by PRIMARY- SUBSCRIPT to be moved to ROW-WA. PRIMARY-SUBSCRIPT must be set by the programmer or by a preceding search.

Take Indirect (V)

The Take Indirect (V) command will cause the primary table entry pointed to by the Tag Table entry pointed to by TAG-SUBSCRIPT to be moved to ROW-WA. TAG-SUBSCRIPT must be set by the programmer or by a preceding search.

Fetch (F)

The Fetch (F) command is a combination of Search and Take. The FOUND-CODE will be set to Y if the Fetch was successful and to N if the row could not be found.

Generate Tag Table (G)

The Generate Tag Table (G) command will initialize a tag table appropriate to the organization of the table.

Unless the primary table is empty, the tag table must be initialized before any searching or inserting is done. Normally this tag table generation need only be done once for each tag table, at the beginning of the program.

Regenerate the tag table if any of the following fields change in value during the course of the program execution:

  • ROW-SIZE
  • KEY-SIZE
  • KEY-LOCATION
  • TABLE-ORG
  • TAG-TBL-MAX (if ORG = H).

For a sequential table, a G command will result in a table in which the first entry in the tag table “points to” (by means of the address and subscript described above) the lowest entry in the primary table; the second entry in the tag table points to the second lowest entry in the primary table; the last entry in the tag table points to the highest entry in the primary table.

For a non-sequential table, no reliance should be placed on the order of rows. All subscripts of zero should be ignored.

Hash In Place (H)

The Hash In Place (H) command will convert a sequential or random table into a hash table. An organization and method of H must be specified. A work area equal in size to one row is required. The area used for the insert row, ROW-WA, will suffice.

Hash in Place is only valid for Data Tables (primary tables), not for tag tables.

Arrange (A)

The Arrange (A) command will physically sort a primary table into ascending or descending sequence. Specify organization = S for ascending sequence and organization = D for descending sequence.