URL: http://www.firstbasesoftware.com/man/man3/putrec.htm
Last modified: 12 September 1995
Copyright © by FirstBase Software.
[
Index of Contents] [
FirstBase RDBMS Overview]
fb_putrec(rec, db)
long rec;
fb_database *db;
Getrec(3) or getxrec(3) are used to retrieve an existing database record from the database into the array of field descriptors. Then, these field structures may be updated by using the store(3) routine. Once a record has been modified, fb_putrec is called to physically write the fields of data as a single record to the database.
Fb_putrec stores logical record rec into the database pointed to by db. The map file descriptor stored in db->mfd is used to determine the old location and length of the record within the database file described by the file descriptor stored in db->fd.
Getrec(3) will place the current record number in a field inside of the database structure called db->rec when a record is read. Most times this will be the same number used as a parameter to fb_putrec.
The records in any FirstBase database are indexed starting at physical record number one (1). When using fb_putrec, it is important that the record number rec represents a record already in the database, or one more than the database holds. I.E., the range that rec can take on is between 1 and the database record count + 1. (1 <= rec <= db->reccnt + 1). In other words, new records must be assigned the next sequential record number in the database.
If the record did not exist before, or if the record will not fit in the place it did exist, a new storage area is located and the old area is linked into a free storage list. New storage areas come from the free list or are allocated at the end of the database.
Fb_putrec uses the database field descriptors to gather and write the fields to the database. These field descriptors will point into one of the buffers in the database structure, db->orec or db->arec depending on whether the field has been altered or not.
Normally, fb_putrec(3) will store records in a variable length format. However, some applications that modify the same records over and over might get better performance with fixed width records. By setting the external short integer variable cdb_fixedwidth to one (1) before calling fb_opendb, or by setting the short integer fixedwidth in the database structure after the call to fb_opendb, fb_putrec will pad the end of each record to create fixed width entries. Alternately, system wide fixed width FirstBase record storage can be defined via setup(5).