TMySQLMonitor loggin only Insert/Update/Delete

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

TMySQLMonitor loggin only Insert/Update/Delete

Post by eduardosic » Sat 24 Nov 2007 02:19

Hi Antaeus!

exists some form to make TMySQLMonitor log only Insert into/Update/Delete
Statments? dont log Select?

I want to register commands SQL and to create a replication mechanism.


thank's

Eduardo.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 26 Nov 2007 08:13

You can leave only the ftQExecute flag in TMySQLMonitor.Traceflags to avoid logging of events like connect, prepare, etc. In the TMySQLMonitor.OnSQL event you can parse the Text parameter to save in your log only necessary statements.

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

ok..

Post by eduardosic » Mon 26 Nov 2007 10:04

Antaeus wrote:You can leave only the ftQExecute flag in TMySQLMonitor.Traceflags to avoid logging of events like connect, prepare, etc. In the TMySQLMonitor.OnSQL event you can parse the Text parameter to save in your log only necessary statements.
Thank's Antaeus..

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

suggestion

Post by eduardosic » Mon 26 Nov 2007 21:32

Antaeus wrote:You can leave only the ftQExecute flag in TMySQLMonitor.Traceflags to avoid logging of events like connect, prepare, etc. In the TMySQLMonitor.OnSQL event you can parse the Text parameter to save in your log only necessary statements.
hi Antaeus!!


I implemented in the following way

Code: Select all

procedure TFrmMain.MySQLMonitorSQL(Sender: TObject; Text: string;Flag: TDATraceFlag);
begin
   //save the Statement in a table...
   if Flag = tfMisc then begin
    MySQLMonitor.Active                              := False;
    if Pos( 'SELECT', AnsiUpperCase( Copy(text,1,10) ) = 0 then begin //saved everything that is not select
     QryLOG_SQL.ParamByName( 'SQL' ).AsString        := Text + ';';
     QryLOG_SQL.ParamByName( 'Ds_Sistema' ).AsString := 'MySYSTEM_A';
     QryLOG_SQL.Execute;
    end;
    MySQLMonitor.Active                             := true;
   end;

end;

you have some better suggestion?

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Tue 27 Nov 2007 12:10

This is a good solution. The only suggestion I have is to change TraceFlags of MySQLMonitor at design time or at run time in this way:

Code: Select all

  MySQLMonitor.TraceFlags := [tfMisc];
You can do this if you want to avoid this condition in your event:

Code: Select all

  if Flag = tfMisc then begin 

Post Reply