TMyQuery Execute vs ExecSQL

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
lastminute
Posts: 2
Joined: Thu 15 Mar 2012 10:57

TMyQuery Execute vs ExecSQL

Post by lastminute » Thu 15 Mar 2012 11:27

Hi

Would someone help me to understand the main differences between using something like:

TMyQuery *Q = new TMyQuery(Application);
Q->Connection = conn;
Q->SQL->Add(query);
Q->Execute();
Q->Free();

OR
...
Q->ExecSQL();
...

Assuming "query" will be always an Update, or Delete or Insert statement.

I know Execute does an implicit call to Prepare, is that the only difference between ExecSQL and Execute?

Thanks
Javier

AndreyZ

Post by AndreyZ » Thu 15 Mar 2012 12:56

Hello,

There is no difference between the TMyQuery->Execute() and TMyQuery->ExecSQL() methods, the TMyQuery->ExecSQL() method internally calls the TMyQuery->Execute() method. The TMyQuery->ExecSQL() method is added for compatibility with the TQuery component.

Justmade
Posts: 108
Joined: Sat 16 Aug 2008 03:51

Post by Justmade » Thu 15 Mar 2012 13:39

Or it is more simple to directly execute the statement with no result dataset using :

conn->ExecSQL('Your statement');

lastminute
Posts: 2
Joined: Thu 15 Mar 2012 10:57

Post by lastminute » Thu 15 Mar 2012 14:04

Thanks a lot for your prompt response

Post Reply