QMRecordlock

Top  Previous  Next

 

The QMRecordlock function locks a record. It is analogous to the QMBasic RECORDLOCKL and RECRODLOCKU statements.

 

 

Format

 

VBQMRecordlock ByVal FileNo as Integer, ByVal Id as String, ByVal Update as Integer,

       ByVal Wait as Integer

 

Cvoid QMRecordlock(int FileNo, char * Id, int Update, int Wait)

 

ObjSession->Recordlock(FileNo, Id, Update, Wait)

 

where

 

FileNois the file number returned by a previous QMOpen() call.

 

Idis the id of the record to be locked.

 

Updateis a boolean value specifying the type of lock to be obtained:
TrueUpdate lock
FalseShareable read lock

 

Waitis a boolean value indicating the action to be taken if the record is currently locked by another user:
Truewait for the record to become available
Falsereturn an error code of SV_LOCKED

 

 

The QMRecordlock function can be used to obtain a lock on a record without reading the record.

 

 

Examples

 

VB

QMRecordllock(fClients, ClientNo, True, True)

QMWrite fClients, ClientNo, Rec

C

QMRecordlock(fClients, ClientNo, TRUE, TRUE);

QMWrite(fClients, ClientNo, Rec2);

QMBasic

session->Recordlock(fClients, ClientNo, @true, @true)

session->Write(fClients, Id, Rec)

 

The above program fragment writes a new record into the file opened as fClients. To comply with recommended locking rules, a record should never be written unless the program holds an update lock on it. Use of QMRecordlock() gets this lock before the write.