Page 1 of 1

Change the lock type of all TUniQuery

Posted: Fri 18 Mar 2011 15:53
by gmartins
Hello.
I'm using Unidac 3.50 with Delphi 7.
I'm having some problems with this error: "Lock request time out period exceeded" in some querys.
I'm trying to change the lock type of all my querys to pessimistic but I have literally hundreds of querys (some created dinamically and some at design time).
So, my question is: is there any way to tell my application that all TuniQuerys have pessimistic lock? Or is there a way to make the lock pessimistic by default?

Thanks in advance.

Regards

Goncalo Martins

Posted: Mon 21 Mar 2011 08:54
by AlexP
Hello,

There are several ways to set the LockMode property to lmPessimistic by default :
1. Create a successor of the TUniConnection class and override the RegisterClient method like:

Code: Select all

procedure TMyUniConnection.RegisterClient(Client: TObject;
  Event: TConnectChangeEvent);
begin
  inherited;
  if Client is TCustomUniDataSet then;
    TCustomUniDataSet(Client).LockMode := lmPessimistic;
end;
in this case the LockMode property in all TCustomUniDataSet objects, which are associated with the TMyUniConnection object, will be set to lmPessimistic.

2. Create a successor of the TUniTable class and set the LockMode property to lmPessimistic in the constructor, and use this class instead of the standard TUniTable one.