Different sessions should be able to get a unique number from a mutex
TableMutex with some filelds one field is called nr
Code: Select all
MyQ.SQL.Clear;
MyQ.SQL.Add('LOCK TABLES TableMutex WRITE');
MyQ.ExeCute;
MyQ.SQL.Clear;
MyQ.SQL.Add('SELECT key,nr FROM TableMutex ORDER BY key DESC');
MyQ.Active:= TRUE; MyQ.First;
i:= MyQ.FieldByName('key').asInteger;
nummer:= MyQ.fieldByName('nr').asInteger; Inc(nummer);
MyQ.SQL.Clear;
MyQ.SQL.Add('UPDATE TableMutex SET nr = ' + IntToStr(nummer));
MyQ.SQL.Add('WHERE key = ' + IntToStr(nummer));
MyQ.ExeCute;
MyQ.SQL.Clear;
MyQ.SQL.Add('UNLOCK TABLES');
MyQ.ExeCute
I still get about 30 double numbers on 600 transactions
Do I do something wrong or forget a special thing?
Please, let me know. My clients are starting to punish me