Page 1 of 1

Problem with TMySQLmonitor

Posted: Sun 24 Sep 2006 09:03
by krimson
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

Posted: Mon 25 Sep 2006 11:18
by Antaeus
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') 

Posted: Mon 25 Sep 2006 11:36
by krimson
Thanks you for your reply.

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

Thank you,

Krimson

Posted: Mon 25 Sep 2006 12:26
by Antaeus
Yes. You should run MySQL Server with following parameter: --log=log_file_name. Please see MySQL Reference Manual details.

Posted: Mon 25 Sep 2006 13:14
by Antaeus
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;

Posted: Mon 25 Sep 2006 18:25
by krimson
GREAT guys!!

This is what I was looking for.

Thansk,

Krimson