How to get the last Sql statement?

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
starhu
Posts: 34
Joined: Thu 13 Aug 2009 12:13

How to get the last Sql statement?

Post by starhu » Sun 10 Oct 2021 12:48

Hello,

For bug reporting purposes, when an error occurs (using MadExcept) I want to log the last Sql event.
How can I do this? I haven't found anything under TMyConnection or TMySqlMonitor.

Thank you!

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to get the last Sql statement?

Post by ViktorV » Fri 22 Oct 2021 16:02

Hi there!

Thank you for contacting Devart and for your question!

Please note that MyDAC does not contain a similar property or method.

But you can try to implement this functionality yourself using the following tips:

- You can organize independent logging of all requests you perform in any way convenient for you.

- Or take advantage of MySQL's ability to log:

1. Execute SET GLOBAL log_output = 'TABLE';
2. Execute SET GLOBAL general_log = 'ON';
3. Take a look at the table mysql.general_log. Например:

Code: Select all

SELECT * FROM mysql.general_log WHERE command_type ='Query' ORDER BY event_time DESC 
Note, estarting the server leaves you where you started (log is by default still off).
For more information, see http://dev.mysql.com/doc/refman/5.1/en/ ... eneral_log

Please, let us know if you have any questions!

Post Reply