QMReadu()

QMReadu()

Top  Previous  Next

 

The QMReadu() function reads a record with an exclusive update lock. It is analogous to the QMBasic READU statement.

 

The function arguments are:

 

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

 

Idis the id of the record to be read.

 

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

 

Erris an integer variable to receive status information. This argument is not present in all variants of the QMClient API.

 

 

The QMReadu() function requests the server to return the record with key Id from the file opened as FileNo. An exclusive update lock is applied to the record. Only one user may hold an exclusive update lock on any one record at one time. An exclusive update lock also cannot be obtained if another user holds a shareable read lock on the record or a file lock on the entire file.

 

If the action is blocked by a lock held by another user, the function returns a null string and the Err variable is set to SV_LOCKED. The QMStatus() function can be used to retrieve the user number of the process holding the lock.

 

If successful, the function returns the record as a dynamic array string and the Err variable is set to SV_OK. The record is locked by the server process.

 

If the record cannot be found, the function returns a null string and the Err variable is set to SV_ELSE. The QMStatus() function can be used to retrieve the error number. The record is locked by the server process to allow creation of the record. If the lock is not required, it should be released using the QMRelease() function.

 

Conditions that would normally cause a QMBasic program to abort or to take the ON ERROR clause of a READ statement return a null string and the Err variable is set to SV_ON_ERROR. The QMStatus() function can be used to retrieve the error number.

 

The example program fragments below read a record with an update lock, modify it and then writes it back to the file. A real program should test the error status from the read operations to determine if they were successful.

 

 

hmtoggle_plus1C

 

hmtoggle_plus1VB.Net

 

hmtoggle_plus1QMBasic Class Module

 

hmtoggle_plus1Java

 

hmtoggle_plus1Python