-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIsRecordLocked.pas
More file actions
39 lines (39 loc) · 955 Bytes
/
IsRecordLocked.pas
File metadata and controls
39 lines (39 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function IsRecordLocked(Table: TTable; ByAnyone: Boolean): Boolean;
//
// Testa se o registro da tabela está travado ou não
//
// Requer a DBIprocs declarada na clausula uses da unit
//
var
Locked: BOOL;
hCur: hDBICur;
rslt: DBIResult;
begin
Table.UpdateCursorPos;
Check(DbiIsRecordLocked(Table.Handle, Locked));
Result := Locked;
if (not Result) and (ByAnyone) then
begin
Check(DbiCloneCursor(Table.Handle, False, False, hCur));
try
rslt := DbiGetRecord(hCur, dbiWRITELOCK, nil, nil);
if (rslt <> DBIERR_NONE) then
begin
if (HiByte(rslt) = ERRCAT_LOCKCONFLICT) then
begin
Result := True;
end
else
begin
Check(rslt);
end;
end
else
begin
Check(DbiRelRecordLock(hCur, False));
end;
finally
Check(DbiCloseCursor(hCur));
end;
end;
end;