![]() ![]() ![]() ![]() ![]() ![]() ![]() |
||
|
Checks the lock status of the current record.
This example uses the following input: IsRecordLocked(Table1, True); NOTE: If ByAnyone is true, then the function also checks if any other session has the record locked. If ByAnyone is false, then only the current session is checked. The function returns False if not locked, and True if locked. function IsRecordLocked(Table: TTable; ByAnyone: boolean): boolean;
var
Locked: BOOL;
hCur: hDBICur;
rslt: DBIResult;
begin
Table.UpdateCursorPos;
// Is the record locked by the current session...
Check(DbiIsRecordLocked(Table.Handle, Locked));
Result := Locked;
// If the current session does not have a lock and the ByAnyone varable is
// set to check all sessions, continue check...
if (Result = False) and (ByAnyone = True) then
begin
// Get a new cursor to the same record...
Check(DbiCloneCursor(Table.Handle, False, False, hCur));
try
// Try and get the record with a write lock...
rslt := DbiGetRecord(hCur, dbiWRITELOCK, nil, nil);
if rslt <> DBIERR_NONE then
begin
// if an error occured and it is a lock error, return true...
if HiByte(rslt) = ERRCAT_LOCKCONFLICT then
Result := True
else
// If some other error happened, throw an exception...
Check(rslt);
end
else
// Release the lock in this session if the function was successful...
Check(DbiRelRecordLock(hCur, False));
finally
// Close the cloned cursor...
Check(DbiCloseCursor(hCur));
end;
end;
end;
Back to BDE API Reference Page | ||
|
DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that you received with the Borland product to which this information pertains. |
||
| Trademarks & Copyright © 1998 Borland International, Inc. | ||