<< Click to Display Table of Contents >> Navigation: Apollo API Listing > sx_Rlock |
Declare Function sx_Rlock Lib "Apollo9.dll"
(ByVal lRecNum as Long)
As Integer
BOOL FAR PASCAL sx_Rlock(LONG lRecNum);
Locks the defined record. No more than 500 records can be locked simultaneously.
Multiple record locking is support. All locks set via sx_Rlock are added to a linked list of locks. The lock remains in effect until it is explicitly released with sx_Unlock(recno). All locks may be released with sx_Unlock(0). sx_Flock also releases the lock list and places a lock on the entire file.
Explicit and Implicit Locks
Multiple record locking is provided by sx_Rlock.
Record locking that is not called explicitly may also occur in the background. This is called implicit locking. Implicit locks are not added to the linked list of locks (accessible by sx_DBRLockList).
Implicit locks occur when:
•A record is added with sx_AppendBlank or sx_Append. If you wish to retain the implicit lock set on an append, you can explicitly call sx_Rlock. Otherwise the lock is removed after the record is written.
•A change occurs in one of the bound data controls. Apollo Data Control only.
Implicit locks are released by:
•Any record movement.
•Setting another implicit lock
•Calls to sx_Flock, sx_Rlock or sx_Unlock
•Closing the file
•Creating an index
•Encrypting or decrypting the database
Explicit locks set via sx_Rlock are always added to the lock list. The locks are released by:
•Calling sx_Unlock( recnum ) for each record in the list
•Calling sx_Flock
•Calling sx_Unlock( 0)
•Closing the table
•Creating an index
•Encrypting or decrypting the table
lRecNum: The physical record number of the record to be locked. If another record is locked by the same task, it is released before the new lock is placed.
Note: This parameter is not currently used to indicate the specific record to be locked, but the sx_RecNo value should be used to insure future compatibility, when this support may be added.
True if the lock is successful and False if not. Locks will be retrid according to the time-out value established by sx_SetLockTimeout.
If sx_Rlock(sx_RecNo()) Then
sx_Replace "name", R_CHAR, ByVal RTrim$((BoxName.Text))
sx_Commit
sx_Unlock sx_RecNo()
Else
MsgBox "Record lock failed"
End If
if (sx_Rlock(sx_RecNo())
{
sx_Replace("name", R_CHAR, (VOIDP) cpName);
sx_Replace("memo", R_MEMO, (VOIDP) cpMemoString);
sx_Commit();
sx_Unlock(sx_RecNo());
}
else
AfxMessageBox((LPCSTR) "Record lock failed");
sx_Flock, sx_Locked, sx_SetLockTimeout