Next: , Up: Editing Fields

5.1 Adding Fields

As mentioned above, the command recins adds new records to a recfile, but it cannot add fields to an existing record. This task can be achieved automatically using recset with its -a flag.

Suppose that (after a stock inspection) you wanted to add an `Inspected' field to all the items in the recfile. The following command could be used.

     $ recset -t Item -f Inspected -a 'Yes' stock.rec

Here, because no record selection flag was provided, the command affected all the records of type `Item'. We could limit the effect of the command using the -e, -q, -n or -m flags. For example to add the `Inspected' field to only the first item the following command would work:

     $ recset -t Item -n 0 -f Inspected -a 'Yes' stock.rec

Similarly, a selection expression could have been used with the -e flag in order to add the field only to records which satisfy the expression.

If you use recset with the -a flag on a field that already exists, a new field (in addition to those already present) will be appended with the given value.