SUMMARY d_reclock(REC,type[,dbn]) int REC; char *type; int dbn;
ARGUMENTS REC The record type for which the files are to be locked
type Pointer to a string containing the type of lock to be applied.
dbn (optional) The number of the database containing the record.
DESCRIPTION This function places a lock on the data and keys files associated with REC. The type of lock to be applied is specified by type as follows: Type Description "r" Read lock. "w" Write lock. "x" Exclusive lock. "k" Keep lock. Read lock allow other programs to read but not update the locked files. Write locks prevent all other programs from accessing the locked files and can only be issued from within a transaction. Exclusive locks also prevent all other programs from accessing the locked files but can be issued independent of transactions. Keep locks can only be issued from within a transaction and will keep read- and write-locked files read-locked after a transaction ends (d_trend normally frees all read- and write-locked files). The record type must be locked in order to apply a keep lock; otherwise, status S_NOTLOCKED is returned.
Within a transaction, a read-locked file can be upgraded to a write or exculsive lock by calling d_reclock with a write or exclusive lock where a read lock already exists. If the upgrade lock request is denied, the read lock will remain in effect.
This function is present in the single-user version of db-VISTA, but performs no action. This allows multi-user applications to link with the single-user version for operation on stand-alone computers.
CURRENCY CHANGES None;
RETURN CODES
5 S_UNAVAIL One of the requested files is not available (i.e. you were on the quere waiting for a file longer than your current time out value).
-3 S_INVREC Invalid record type specified. Perhaps you passed a set or field type instead.
-11 S_BADTYPE An invalid lock type was specified. You may have passed a character (e.g.'r') instead of a string (e.g. "r").
-23 S_NOTFREE Record type already locked by your application.
-31 S_NOTRANS Required a write lock outside of a transaction. EXAMPLE
int count,stat=S_OKAY; ... /*list info record in id_code order*/ while (stat==S_OKAY) { while (d_reclock(INFO,"r")==S_UMAVAIL) ; for (count=0; count<20 && (stat=d_keynext(ID_CODE)) == S_OKAY; count++) { /*hold lock for only 20 records at a time*/ d_recread(&irec); pr_info(); } d_recfree(INFO); }