SQL Monitor Logging

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
sidekick
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 24.11.2005, 19:41

SQL Monitor Logging

Post by sidekick »

Hello,

Im trying to log sql statements, using TZSQLMonitor, that are generated after an Edit statement on the query.

See the code below please:

Code: Select all

  ehConnectIbSqlServer;
  with qIbGetOccupiedCompartments do begin
    Open;
    First;
    while not Eof do begin
      Edit;
      FieldByName('OrderId').AsString := '123';
      dbIbSql.StartTransaction;
      ApplyUpdates;
      dbIbSql.Commit;
      Next;
    end;
  end;
  ehDisConnectIbSqlServer;
This is the code that writes to the listbox control

Code: Select all

procedure TfrmMain.monIbSqlLogTrace(Sender: TObject; Event: TZLoggingEvent);
begin
  ehLogSqlEvent(lbIbSqlMon, Event);
end;

procedure TfrmMain.ehLogSqlEvent(lbListBox : TlistBox; Event : TZLoggingEvent);
begin

  with lbListBox.Items do begin
    Add('Protocol...: ' + Event.Protocol);
    Add('Message....: ' + event.Message);
    Add('Error Code.: ' + IntToStr(Event.ErrorCode));
    Add('Error Msg..: ' + Event.Error);
    Add('TimeStamp..: ' + DateToStr(Event.Timestamp));
    Add('');
  end;

end;

Part of the log looks like this:

Protocol...: interbase-6
Message....: CONNECT TO "W:\SQLDB\OrderProcessingEX\DB\nlstore.GDB" AS USER "sysdba"
Error Code.: 0
Error Msg..:
TimeStamp..: 17-3-2006

Protocol...: interbase-6
Message....: TRANSACTION STARTED.
Error Code.: 0
Error Msg..:
TimeStamp..: 17-3-2006

Protocol...: interbase-6
Message....: SELECT * FROM COMPARTMENTS WHERE ORDERID<>'0' ORDER BY COMP_NO
Error Code.: 0
Error Msg..:
TimeStamp..: 17-3-2006

Protocol...: interbase-6
Message....: TRANSACTION COMMIT
Error Code.: 0
Error Msg..:
TimeStamp..: 17-3-2006

Only the transaction commit is logged but not the actual update-sql-statement. The code works fine as all records are updated.

Any help would be appreciated.

Regards, Erik
Last edited by sidekick on 18.03.2006, 23:06, edited 2 times in total.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

To log the statements sent by ZEOS you should ude the TZSqlMonitor component of ZEOS . Just drop it on the form and set the connection property to the connection object you used for the SQL.

Mark
Image
sidekick
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 24.11.2005, 19:41

Post by sidekick »

Hello Mark,

Sorry for not mentioning that i am already using the monitor component, i have updated the topic with more information.

Regards, Erik
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Sorry Erik,

But I did not really onderstand that you were trying to catch the messages sent to the logfile of the SqlMonitor. Is the logfile correct or are the messages absent there as well?
I don't know much about those stuff, but I've read the documentation about the dbExpress sqlMonitor and it appears to me it would be better to use the on Trace event instead of onLogTrace, because the first one filters the messages actually sent to the log and afterwards to the second event. Did you check whether the onTrace event actually fires in case an update query is sent to the monitor?

Mark

BTW, if my english is too bad, you can always send me a private message in dutch to explain in a more understandable language. Tot horens...
Image
sidekick
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 24.11.2005, 19:41

Post by sidekick »

Hello Mark,

Your english is fine to me.

Both events fire.
I tried both methods and the output is exactly the same.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

That means, both events fire, except for the queries generated to update the database rows?
Is the data in the log file also missing these lines? If not it's just the triggering part that does not work.
I would say it's a real bug in your ZEOS version for (at least) the protocol you use.

Yesterday i downloaded the most recent SVN version and compiled my own project. My updates are being monitored very well in the logfile. I did not use the event triggers. Using Mysql5.

Mark
Image
sidekick
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 24.11.2005, 19:41

Post by sidekick »

Ok Mark,

I tried a couple of things.

I moved the "dbIbSql.Commit;" statement outside of the loop.
Used only the LogTrace event.

On interbase:
When i look at the logfile then i tels me that actually there ar no update statement logged at all.

I tried the same test on mysql 4.1 and the logfile show the update query statements. So you are right that this probably is a bug in the interbase driver component.

Could you please explain how i can download the latest release from the SVN ? Is this release stable in any form ?

Regards, Erik
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Erik,

I use the tortoiseSVN software. ( http://tortoisesvn.tigris.org/
I think it's similar to CVS but newer.

After installing (Windows) you will see a new option in windows explorer (right click menu) SVN Checkout... After clicking you get a small dialog asking for the repository. For Zeos you should use 'svn://firmos.at/zeos'. Other options are quite evident.

The stability of this download is completely unknown to me. It's a developpers tool, so that version is still being worked on. I just upgraded the version I was using (2004) and after some changes (replaced 'requestlive:=true') it works as expected in D7. The latest official CVS release on sourceforge did NOT work for me (locate function was a little broke).

So I would say : take the risk. All other versions are alpha or beta and therefore 'unstable' anyway. If you have a zeos backup of your current version it can only cost you the time of the download and eventually putting back the backup version. Your app does not need modifications. (or maybe just the tiny one mentioned above if you use a very old versionas I did)

You should do it anyway if you want somebody to look at the bug. It wouldn't be fair to file a bug report without checking if the problem still exists in the dev version.

I think the original question was 'solved' by saying 'BUG'. Hope it's already fixed in the newest version. I can't help you any further but I'm curious how it ends. Please drop a little end note in this thread when you know more.

See you,
Mark
Image
sidekick
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 24.11.2005, 19:41

Post by sidekick »

Mark,

I downloaded the source and im going to give it a try and see if the this build works.

I will post a message as soon as know more about how this build works.

And of course thanks for helping me troubleshoot the problem.

CU, Erik
sidekick
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 24.11.2005, 19:41

Post by sidekick »

Hello Mark,

I went a bit further in testing. As i found out in both the latest-source release and the 6.5.1 version following is the matter:

The Event.Message string logged to the trace file is different than in the OnTrace and OnLogTrace event. Live query updates are logged to the file, the information in the events is different eg. do not reveal the same information or less information as the log does.

Interbase queries do not display the values supplied in the query they rather show a question mark. MySql and MsSql qeuries are logged correctly. I dont use other SQL-versions.

Doesnt really look like a bug to me its rather a feature request or might be some unfinished work. I looked for a bug and a feature request that covers this thread but cant find any information.

Also the monitors used in the old versions were connected to a specific database connection which i found more convenient.

If you have any suggentions please let me know.

Regards,

Erik
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Erik,

I hope there's some developper responsible for the Monitor, that watches this thread.
In my opinion it's a bug (that I can live with, but anyway...) as the behaviour is not consistent. If there's an event OnTrace/OnLogTrace, it should fire for every statement logged, no matter what happens.
It would also be nice if the message was exactly the same. At least in the OnLogTrace the message can be exactly the same. Unfortunately I don't have neither time nor experience to go deeper into it at this very moment.
An other nice feature would be that file output can be linked to a TStream object. That way it's possible to have the output immediately in your application.

Developers, how do we file a Bug report/Feature request/ToDo Item?

Mark
Image
btrewern
Expert Boarder
Expert Boarder
Posts: 193
Joined: 06.10.2005, 18:51

Post by btrewern »

See the Sourceforge site: http://sourceforge.net/projects/zeoslib there is a link there to report bugs.

Ben
anse123
Junior Boarder
Junior Boarder
Posts: 26
Joined: 23.02.2006, 22:28

Post by anse123 »

How can I only log queries which are assigned to one of more ZConnection's ?

The latest CVS-version of ZSQLMonitor is 2 years old and no earlier version also has a "Connection"-property for this purpose. So if I have 2 connections and 2 ZSQLMonitor objects, the OnLogTrace of both Monitor-objects always listens to both connections. Is this a bug?

A workaround could be to set the ZSQLMonitor.Active to false in a form.OnDeactivate-event (assuming we have a MDI-application). But this would also make other events from the inactive window invisible.

Anse
Post Reply