The Update commands allow a programmer to modify the contents of a table by utilizing the Insert, Delete, Replace and Empty commands. These commands may be used either by Key or by Count, where Key is a search key and Count is the subscript of a row in the table. The update command group consists of:
- Delete by Key (DK)
- Insert by Key (IK)
- Replace by Key (RK)
- Delete by Count (DC)
- Insert by Count (IC)
- Replace by Count (RC)
- Empty the Table (MT)
Following the execution of any update command, the FOUND code is set to Y if the requested row was found, otherwise it is set to N. Depending on the operation, either Y or N could indicate success. For example IK would be successful if a row with a matching key was not found (see 3. FOUND (1 byte)). In addition, all commands that use a keyed-search (DK, IK, RK) set the COUNT field in xxxx-COMMAND-AREA.
All commands that use a keyed-search will always target the first of a group of rows having the same key.
If the table has not been explicitly opened, and IMPLICIT_OPEN is set to Y, an update command in a single-tasking, single-user environment will cause tableBASE to attempt an automatic open of the table. If the open is successful, COUNT is not reset to zero for the DC, IC and RC update commands. It is the retained value of COUNT which would be used in the execution of these commands.
The number of bytes moved into the table by a successful insert or replace request is normally determined by the row size defined in the table definition. This can be overridden for the request by setting the ROW-OVERRIDE-LENGTH value in xxxx-COMMAND-AREA.
If ROW-OVERRIDE-LENGTH is set to zero, the request updates the table using the number of bytes specified in the table definition. Otherwise, ROW-OVERRIDE-LENGTH determines the number of bytes used for the update. If ROW-OVERRIDE-LENGTH is greater than zero and less than the defined row size for the table, then the table update uses the row area padded with low values. If ROW-OVERRIDE-LENGTH is greater than the defined row size, the row area will be truncated for the table update.
When ROW-OVERRIDE-LENGTH is not 0, it must be large enough to contain the table key.
On completion of the request, tableBASE sets the ACTUAL-ROW-LENGTH field of xxxx-COMMAND-AREA to indicate the row size.