The most basic property that can be specified for a set of records is
their type. The special field name
%rec is used for that
%rec: Entry Id: 1 Name: Entry 1 Id: 2 Name: Entry 2
The records following the descriptors are then identified as having its type. So in the example above we would say there are two records of type “Entry”. Or in a more colloquial way we would say there are two “Entries” in the database.
The effect of a record descriptor ends when another descriptor is found in the stream of records. This allows you to store different kinds of records in the same database. For example, suppose you are maintaining a depot. You will need to keep track of both what items are available and when they are sold or restocked.
The following example shows the usage of two record descriptors to store both kind of records: articles and stock.
%rec: Article Id: 1 Title: Article 1 Id: 2 Title: Article 2 %rec: Stock Id: 1 Type: sell Date: 20 April 2011 Id: 2 Type: stock Date: 21 April 2011
The collection of records having same types in recfiles are known as record sets in recutils jargon. In the example above two record sets are defined: one containing articles and the other containing stock movements.
Nothing prevents having empty record sets in databases. This is in fact usually the case when a new recfile is written but no data exists yet. In our depot example we could write a first version of the database containing just the record descriptors:
%rec: Article %rec: Stock
Special records are not required, and many recfiles do not have them.
This is because
all the records contained in the file are of the same type, and their
nature can usually be inferred from both the file name and their
contents. For example, contacts.rec could simply contain
records representing contacts without an explicit
record descriptor. In this case we say that the type of the anonymous
records stored in the file is the default record type.
Another possible situation, although not usual, is to have a recfile containing both non-typed (default) and typed record types:
Id: 1 Title: Blah Id: 2 Title: Bleh %rec: Movement Date: 13-Aug-2012 Concept: 20 Date: 24-Sept-2012 Concept: 12
In this case the records preceding the movements are of the
“default” type, whereas the records following the record descriptor
are of type
Movement. Even though it is supported by the format
and the utilities, it is generally not recommended to mix non-typed
and typed records in a recfile.