Problem with TMySQLmonitor

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
krimson
Posts: 13
Joined: Sun 24 Sep 2006 08:56

Problem with TMySQLmonitor

Post by krimson » Sun 24 Sep 2006 09:03

I have a problem with TMySQLmonitor:

First I log a transaction (with TMySQLMonitor) that is generated by adding and posting a new record to tbl_orders (see example SQL) through a normal dbgrid and dbedits.

Then I would like to execute this logged SQL statement again by calling it to the database through a TMyCommand.

This generates an error. Why does MySQL accept the initial logged SQL statement, and not the same SQL statement run again through TMyCommand???

Here is the logged SQL statement:

INSERT INTO tbl_orders
(ordr_ID, ordr_DateTime, ordr_LocationID, ordr_EmployeeID)
VALUES
(:1, :2, :3, :4)
:1(Integer,IN)=119
:2(DateTime,IN)=24-9-2006
:3(Integer,IN)=1
:4(Integer,IN)=1

Should I make change to any components or to MySQL to get it to work??

Any help is very much appreciated!!

Krimson

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

Post by Antaeus » Mon 25 Sep 2006 11:18

This SQL command is not valid for MySQL Server. We use such format to give more information about executed query to user. If you want to make this query working in TMyCommand, you should change parameter names in the query to actual values. For example:

Code: Select all

INSERT INTO tbl_orders 
(ordr_ID, ordr_DateTime, ordr_LocationID, ordr_EmployeeID) 
VALUES 
('119', '24-9-2006', '1', '1') 

krimson
Posts: 13
Joined: Sun 24 Sep 2006 08:56

Post by krimson » Mon 25 Sep 2006 11:36

Thanks you for your reply.

Is there another way to log the actual SQL statement sent to the database?

Thank you,

Krimson

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

Post by Antaeus » Mon 25 Sep 2006 12:26

Yes. You should run MySQL Server with following parameter: --log=log_file_name. Please see MySQL Reference Manual details.

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

Post by Antaeus » Mon 25 Sep 2006 13:14

One more way to show SQL statements that are sent to the server is setting MySQLMonitor.TraceFlags.tfMisc to True and checking this flag in the handler of OnSQL event. This may look like this:

Code: Select all

procedure TForm1.MySQLMonitor1SQL(Sender: TObject; Text: String;
  Flag: TDATraceFlag);
begin
  if Flag = tfMisc then
    ShowMessage(Text);
end;

krimson
Posts: 13
Joined: Sun 24 Sep 2006 08:56

Post by krimson » Mon 25 Sep 2006 18:25

GREAT guys!!

This is what I was looking for.

Thansk,

Krimson

Post Reply