mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-06 09:26:52 +01:00
18 lines
577 B
AL
18 lines
577 B
AL
codeunit 51204 "Perf Sample LockTable Good"
|
|
{
|
|
procedure GetOrCreate(var AgentStatus: Record "Integer"): Boolean
|
|
begin
|
|
// Read path: consistent read on this record instance only.
|
|
AgentStatus.ReadIsolation := IsolationLevel::ReadCommitted;
|
|
if AgentStatus.Get(1) then
|
|
exit(true);
|
|
|
|
// Write path: lock only when we are about to insert.
|
|
AgentStatus.LockTable();
|
|
if not AgentStatus.Get(1) then begin
|
|
AgentStatus.Number := 1;
|
|
AgentStatus.Insert();
|
|
end;
|
|
exit(true);
|
|
end;
|
|
}
|