KnowledgeBase 00041: UPDATE.RECORD

The UPDATE.RECORD command provides two alternative ways to modify data:

Batch mode to apply the same update to multiple records.

Visual mode to display and modify a specific record.

UPDATE.RECORD avoids the need to write special programs to make repetitive
changes to a database. Combined with the SELECT command, apparently complex
changes become extremely easy.

Batch Mode

Batch mode applies the same update to all records or a selection of records.

The update may change any number of fields in the record and the new
content may be a fixed value, the content of another field, the value of a
dictionary I-type or the value of an expression entered as part of the command.

UPDATE.RECORD makes full use of the dictionary definitions of data
conversion codes thus allowing users to enter data in its external format for
ease of use. For example, a date can be entered as "21 Sep 11" instead of
needing to calculate the internal day number (15970).

An optional report provides an audit trail of the changes made to the data
and enables recovery from errors.

Examples of use are shown below....

Set field 10 of every record in a file to be "ABC".

UPDATE.RECORD filename ALL F10, "ABC"

Use a select list to change all records with field DEPT.CODE set to 20 to
become 21.

SELECT STOCK WITH DEPT.CODE = "20"
UPDATE.RECORD STOCK DEPT.CODE, 21

Use an EVAL expression to apply a 10% price increase.

UPDATE.RECORD STOCK ALL PRICE, EVAL "PRICE * 1.1"

Accumulate sales totals and reset the counter. Note that this example
modifies two fields in each record as a single operation.

Visual Mode

Visual mode presents a full screen display of the external (converted) form
of fields from a data record. Changes are made by moving the cursor to the
desired position and entering or deleting characters. Modified lines are
converted back into their internal form within UPDATE.RECORD when the cursor
is moved to a new line or when the data is to be written back to the file.

The columns in the example below show the field number, its corresponding
dictionary name, the text of the display name from the dictionary and the
item content from the data record. There are command options to suppress some
of these columns.