There are several ways to find a record: by moving up and down in the file, by record number, by matching a character string pattern and by fast access method searching. When the record is found, update.rdb writes a blank record back into the file in its place, to lock out other users who might be reading the table. When you finish editing, update.rdb attempts to replace the blanked record with the new updated version. This can happen only if the new record is the same size or smaller than the old record. If it's smaller, spaces are added to the end of the last column to pad it out. If it's larger, trailing and leading spaces are trimmed from the columns.
If no indexes are associated with the table or list, and the updated record is bigger than the original, it will be appended to the end of the file, and the blank record written in its original place will remain. This is also true for lists and tables which are indexed using the record method.
If the table or list has been indexed using binary, hash or inverted methods, and the indexing option is included on the update.rdb command line, then updated records which exceed their original length will not be written back into the table or list. In this case, when update.rdb cannot make the new record small enough to fit, it will give you the option of editing the updated record to make it fit. If the record is not trimmed, then update.rdb will put the original row back into the table or list. In addition, update.rdb will not allow the contents of key columns to be modified, as doing so may invalidate the information in their indexes.
The importance of updating in place is that it does not interfere with the fast access methods in which indexes or sorts assume that the records don't move. To allow for expansion of records during the update process, the table or list can be padded before being indexed and updated, to provide ``room to grow in.'' See the pad command.
The default editor called by update.rdb is the ve table editor, chosen because it maintains table integrity by keeping your TABs in order and it can protect key columns by disallowing modifications to them. In addition, a shell variable called $VEOPTS can be defined as the arguments with which ve should be called when updating records. For example:
$ export VEOPTS="-n -mn -d"
When ve is called to edit an update row, the command options above will display the row as the screen is drawn, disallow record deletion, and protect the (first) numeric column. ve does not work on lists. To change the editor used by update.rdb, define the shell variable $EDITOR:
$ export EDITOR=vi
Command Description \l'4i' q, CTRL-d exit update.rdb RETURN display next record or the next matching key number display the numberth row +[number] move forward number of records or matching keys (1 if not specified). -[number] move back number of records or matching keys (1 if not specified). Command Description \l'4i' \&. redisplay the current record /pattern find next record with pattern =key find records with matching key s key (same as =key) !command execute the UNIX command !enter file enter new records at end of the file m? column turn on the fast access method ? using column as the key column (the column index must exist) ?: b=binary; h=hash; i=index; r=record; s=sequential l lock update record by blanking (toggle, true) h help list displayed (this help list) u update: edit and replace current row v report internal actions (toggle, false)GETTING INTO UPDATE
$ update.rdb tableorlist > _SEARCHING
> <RETURN>
Another way to get the next record is with `+':
> + > +5
Moves forward 5 records.
> -16
Goes back 16 records. You can select a specific record number:
> 57
Gets and displays the 57th record. PATTERN SEARCHING
> /Buford
update.rdb searches forward starting with the next record, then wraps around and goes to the first record in the file and continues till it finds a match or returns to the current record. FAST ACCESS SEARCHING
$ update -mh inventory Item
or, once you're in update.rdb:
> mh Item
Both ways tell update.rdb which method to use and which column is the key column. Once invoked, you can search with either the `=' `s' commands:
> =keyvalue > s keyvalue
These commands are identical. Note that there is no space between the `=' and the keyvalue. When a record is retrieved using the `=' or `s' commands, it is labeled a key and the key position and number of total matches is also displayed:
> =4 Key 4: 1 of 3 Item Amount Cost Value Description ---- ------ ---- ----- ----------- 4 23 19 437 plates
The positional commands, `-', `+' and RETURN will now get the next or previous records with matching keys, rather than the adjacent records:
> +2 Key 4: 3 of 3 Item Amount Cost Value Description ---- ------ ---- ----- ----------- 4 100 .09 9 plastic forks
To switch back to record mode, enter a record number or use the pattern search method to get the next row. UPDATING
> u
update.rdb generates a blank record exactly the same size as the one you have chosen, and writes it back into the table, to keep others from getting it. Then, the editor defined by $EDITOR or the ve program will open the record for editing. Edit it. Keep in mind that if you're using an indexed table (other than a record index), you will not be allowed to replace your updated record in your table if you have changed a key column or made the record longer than the original. When you are finished editing, write the record and exit the editor. update.rdb will examine the record to determine if it's okay (does it still have headlines? the right number of column separators? is it too long or too short? ...) and, if so, update.rdb will replace the blank record with the updated one.
If, for any reason, update.rdb cannot replace the record, it will tell you the reason and give you the option of editing your update. Respond with `y' if you want to edit it: any other response will cause update.rdb to put the original record back into the file.
You can also validate a record before leaving the editor by typing:
:!validate file.v < file
See the validate command for details. OTHER USEFUL COMMANDS
> .
To execute UNIX shell commands, type the exclamation point and the command:
> !ls
You can even enter new records (append to the end):
> !enter thisfilename
When you leave the enter command, you will be back in update.rdb. You can also index the file, such as:
> !index -mi filename keycolumn > mi keycolumn
which will create a filename.i file for the fast access methods search command. SEE ALSO