Change the lock type of all TUniQuery

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
gmartins
Posts: 4
Joined: Mon 22 Jun 2009 16:41

Change the lock type of all TUniQuery

Post by gmartins » Fri 18 Mar 2011 15:53

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 21 Mar 2011 08:54

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.

Post Reply