I was reading the documentation of the class TFDCustomQuery
and I'm curious about the meaning of the parameter AExecDirect
in function ExecSQL(AExecDirect: Boolean): LongInt; overload;
.
The documentation (http://docwiki.embarcadero.com/Libraries/Tokyo/en/FireDAC.Comp.Client.TFDCustomQuery.ExecSQL) does not explains what this parameter does.
If you pass True to the AExecDirect parameter, FireDAC will omit command preparation before its execution (and a few things related to the used DBMS). Its purpose therefore is just for commands executed only once without explicit command preparation.
There's an important thing to note about this ExecSQL method overload. Calling this one modifies the DirectExecute option (by the AExecDirect parameter value) of the object, which might not be expected.
A problem can arise in situations, when one calls this method overload with the True value passed to the AExecDirect parameter, expecting that later calls of the other ExecSQL overloads calls will implicitly prepare the command. They won't, as the DirectExecute option will be enabled.
So, the DirectExecute option reference actually describes this parameter (so as this parameter of this method overload sets this option):
Controls the preparation of SQL statements.
Use the DirectExecute property to specify whether FireDAC should prepare an SQL statement before its execution (False) or execute it directly (True). The default value is False.
This property was introduced at first for MS SQL Server support. The prepared and the direct execution may have different effects, and even the prepared execution may fail. If you will get peculiar errors, then try to set DirectExecute to True.