Next: , Up: Auto-Generated Fields   [Contents][Index]

12.1 Counters

If an auto field is of type integer or range then any newly generated field will use the “next biggest” unused number in the record set.

Consider the toy inventory database introduced above. We could declare the Id field to be generated automatically:

%rec: Item
%key: Id
%type: Id int
%mandatory: Description
%auto: Id

Id: 0
Description: 2cm metal soldier WWII
Amount: 2111

When the next new item is introduced in the database, recins will note the %auto, and create a new Id field for the new record with the next-biggest unused integer, since Id is declared to be of type int. In this example, the new record would have an Id of 1. The database can still provide an explicit Id for the new record. In that case the field is not generated automatically.

Note that if no explicit type is defined for an auto generated field then it is assumed to be an integer.