А ежели так?
X++:
try
{
do
{
ttsbegin;
select pessimisticLock firstonly trans
where trans.open == true;
if (trans.recId != 0)
{
// ...
trans.open = false;
trans.update()
}
ttscommit;
}
while (trans.recId != 0)
}
catch (Exception::Deadlock)
{
retry;
}
catch (Exception::UpdateConflict)
{
retry;
}