Recent

Author Topic: [SOLVED] Finding Queryes associated with ZConnection  (Read 1806 times)

patyi

  • Full Member
  • ***
  • Posts: 169
[SOLVED] Finding Queryes associated with ZConnection
« on: July 28, 2017, 10:00:26 am »
Hi all !

How can I find the list of Queryes associated with ZConnection on level of entire application  ? Especially active ones ?

Thanks !
« Last Edit: July 30, 2017, 12:35:06 pm by patyi »

GetMem

  • Hero Member
  • *****
  • Posts: 3501
Re: Finding Queryes associated with ZConnection
« Reply #1 on: July 28, 2017, 11:38:19 am »
1. Open file ZAbstractConnection.pas(\src\component subfolder)
2. Go to line 312, add this:
Code: Pascal  [Select]
  1. property Datasets: TList read FDatasets;
3. Save the file for future use
4. Recompile all zeos packages(just to be sure)
5. In your application:
Code: Pascal  [Select]
  1. uses ZAbstractDataset;
  2.  
  3. procedure TForm1.Button1Click(Sender: TObject);
  4. var
  5.   I: Integer;
  6. begin
  7.   for i := 0 to ZConnection1.Datasets.Count -1 do
  8.     if Assigned(ZConnection1.Datasets[i]) then
  9.       if TObject(ZConnection1.Datasets[i]) is TZAbstractDataset then
  10.         if (TObject(ZConnection1.Datasets[i]) as TZAbstractDataset).Active then
  11.            ShowMessage((TObject(ZConnection1.Datasets[i]) as TZAbstractDataset).Name);
  12. end;  
                                                                                 

patyi

  • Full Member
  • ***
  • Posts: 169
Re: Finding Queryes associated with ZConnection
« Reply #2 on: July 29, 2017, 06:30:53 pm »
Thanks GetMem !

I will tray it today ... It would be nice to have this on standard Zeos version !
« Last Edit: July 29, 2017, 09:07:49 pm by patyi »

patyi

  • Full Member
  • ***
  • Posts: 169
Re: Finding Queryes associated with ZConnection
« Reply #3 on: July 29, 2017, 07:14:19 pm »
Yesssss ! Working perfectly !

I'm using it to check when I can close the connection,
because of Firebirds performance degradation on 24/7 application. Periodically have to close the connection. The reason is a way how Zeos handling transactions (COMMIT RETAINING/ROLLBACK RETAINING), too many record versions left on the database, and Firebirds garbage collection process can't do the job while the connection is active. Documentation says that the hard commit only takes place when the connection is closed ...
 

GetMem

  • Hero Member
  • *****
  • Posts: 3501
Re: Finding Queryes associated with ZConnection
« Reply #4 on: July 29, 2017, 07:56:19 pm »
Quote
Thanks GetMem !
Szívesen.  ;)