URL: http://www.firstbasesoftware.com/man/man3/putrec.htm
Last modified: 12 September 1995
Copyright © by FirstBase Software.
[ Index of Contents] [ FirstBase RDBMS Overview]


NAME

putrec - write current record to database

SYNOPSIS

#include <firstbase/fb.h>

fb_putrec(rec, db)
long rec;
fb_database *db;

DESCRIPTION

As explained in the database(4) manual page, a database structure contains all of the elements needed for an entire database, including an array of field structures, all file names and descriptors, and index information. Altogether, the array of field structures can hold one complete record.

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).

CLIENT/SERVER

The fb_putrec routine will transparently call the fb_putrec_clnt mechanism when the global FirstBase variable cdb_use_rpc is set to one. See fb_clnt_create(3) for more details.

SEE ALSO

addrec(3), getrec(3), getxrec(3), opendb(3), store(3), database(4), setup(5).

DIAGNOSTICS

Fb_putrec will return the error code FB_ERROR if any of its reads, writes, or seeks fail, or if rec <= 0 or rec > db->reccnt + 1. An FB_AOK signal is returned on correct completion.


URL: http://www.firstbasesoftware.com/man/man3/putrec.htm
Last modified: 12 September 1995
Copyright © by FirstBase Software.
[ Index of Contents] [ FirstBase RDBMS Overview]