Class: TMMScript
Declared in: EDBMMClient (extends TMMClientBase)
Executes a SQL script on the MySQL/MariaDB server and materialises
the result set, if any, into a local EDB temporary table.
All result information is exposed as properties after
Execute returns.
Re-calling Execute drops the previous result and replaces
it.
The caller owns the instance and frees it; the destructor drops the EDB
temp table automatically.
The SQL property
may contain any number of statements separated by semicolons. All
statements are executed in sequence; only the result set of the
last statement is returned. Statements that do not
produce rows (INSERT, UPDATE, DELETE, DDL) are counted in StatementsExec
but do not affect HasResultSet.
† Inherited from TMMClientBase.
Named parameters of the form :name can be used anywhere
in the SQL
text.
Before execution, each token is replaced with a safe SQL literal derived
from the corresponding entry in the Params
collection. Tokens inside quoted strings or identifiers are never
substituted.
var Script: TMMScript;
begin
Script := TMMScript.Create(Connection);
try
Script.SQL.Text := 'SELECT * FROM orders WHERE status = :status AND total > :min';
Script.Params.Clear;
Script.Params.CreateParam(ftString, 'status', ptInput).AsString := 'open';
Script.Params.CreateParam(ftFloat, 'min', ptInput).AsFloat := 100.0;
Script.Execute;
if Script.Success then
// use Script result set ...
finally
Script.Free;
end;
end;
Params is not cleared automatically between calls — the
same values are reused if SQL does not change.
Call Params.Clear explicitly when switching to a different
query or parameter set.
See Params
for the full list of supported field types and substitution rules.
TMMScript is a TComponent descendant and
can be placed on a form or data module from the component palette
(EasyGate tab, Delphi 13).
All configuration properties (Connection, SQL,
UseTransaction, BlobMaxSizeBytes,
InlineBlobMaxBytes, Table,
DefaultTransferFolder, MaxRows,
KeepTempTable, Params, OnLog,
OnProgress) are published and editable in the
Object Inspector.
SQL shows a memo editor button for multi-line SQL entry at
design time.
See EDBApiClient Library for the full design-time setup instructions.