Files
rdb/man/record.man
T

84 lines
1.6 KiB
Groff

.TH record "" "" "/rdb Command"
.PC "Find and output a record from a table"
\fBrecord \fInumber \fB< \fItable\fR
.PP
.II "row^find r. by number"
.II "find record by number"
The command
.B record
searches through
.I table
for the record with the serial number
.IR number .
If it finds the record, it prints it and the table's header on the
standard output.
.SH Example
To retrieve the third record from table
.BR inventory ,
type:
.DM
record 3 < inventory
.DE
.PP
You will see something like the following:
.DM
Item Amount Cost Value Description
---- ------ ---- ----- --------------
3 5 80 400 clamps
.DE
.PP
The following shell script uses
.B record
and
.B read
to find specific values in table
.BR inventory .
The command
.B read
uses the head line of
.B inventory
to assign values to each column name.
.DM
: describe - gives the description for an item in inventory
USAGE='usage: describe Item < table'
.sp \n(pDu
record $1 < inventory |
( read HEAD
read DASH
read $HEAD
echo "Item $Item is $Description"
)
.DE
.PP
When you type
.DM
describe 1 < inventory
.DE
.PP
you see output in the following format:
.DM
Item 1 is rubber gloves
.DE
.SH "Record Numbers"
.I "(Ruby re-creation only.)"
Records are counted from 1.
The numbers 0 and 1 both mean the first record.
A negative number counts from the end:
.B \-1
is the last record,
.B \-2
the one before it, and so on.
A number beyond either end gives a table without records.
Anything that is not a whole number is an error.
.SH "See Also"
.B
row,
search
.R
.br
COHERENT Lexicon:
.B
read
.R
.SO record