Is it possible to trap the SQL text after parameter substitution?

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
NoComprende
Posts: 135
Joined: Tue 09 Jan 2007 13:44

Is it possible to trap the SQL text after parameter substitution?

Post by NoComprende » Fri 03 Aug 2007 09:25

While debugging in BCB, is there any way of finding the actual TMyQuery SQL->Text after the parameter substitution takes place? I'm trying to find why certain queries aren't returning results by running them directly in MySQL and it would save having to substitute the param values in the SQL->Text every time. I thought that was what FinalSQL was for but see now that isn't the case.

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

Post by Antaeus » Fri 03 Aug 2007 10:49

Put the TMySQLMonitor component at the form, turn all TraceFlags to False except the tfMisc flag, and add a handler to the TMySQLMonitor.OnSQL event.

Another way is to setup MySQL logs. For more information see the description of the log parameter in the MySQL Reference Manual.

NoComprende
Posts: 135
Joined: Tue 09 Jan 2007 13:44

Post by NoComprende » Fri 03 Aug 2007 12:29

Many thanks Antaeus, that worked fine. I had been trying for the past 4 hours to find out what I was doing wrong. It turned out I had been supplying the required single quote on either side of a string whereas TMyQuery does this automatically.

Post Reply