Was trying to migrate app to FireDAC usage on Delphi 10.2 and stuck only with this function: Source on github
procedure TMainForm.ExecuteScript(script: string; memo: TMemo);
var
Log: TStringList;
FN: string;
begin
ShowHourGlassCursor;
ZSQLProcessor.Script.Text := script;
try
ZSQLProcessor.Connection.StartTransaction;
ZSQLProcessor.Execute;
ZSQLProcessor.Connection.Commit;
except
on E:Exception do
begin
ZSQLProcessor.Connection.Rollback;
memo.Text := E.Message;
Exit;
end;
end;
Stuck with line and was not able to get along, any help would be good:
ZSQLProcessor.Script.Text := script;
reference: ZSqlProcessor.pas
Converted function without last part looks so:
procedure TMainForm.ExecuteScript(script: string; memo: TMemo);
var
Log: TStringList;
FN: string;
begin
ShowHourGlassCursor;
//ZSQLProcessor.Script.Text := script;
try
MyTrinityConnection.StartTransaction;
FDScript1.ValidateAll;
FDScript1.ExecuteAll;
MyTrinityConnection.Commit;
except
on E:Exception do
begin
MyTrinityConnection.Rollback;
memo.Text := E.Message;
Exit;
end;
end;
To assign single SQL script to the TFDScript object you can simply Add one TFDSQLScript item to the TFDSQLScripts collection and set its SQL string list collection text to the SQL command of your choice, for example:
FDScript1.SQLScripts.Add.SQL.Text := script; { ← this adds one TFDSQLScript item to the script collection and to this just added item assigns a SQL script }
Of course, this assumes the TFDSQLScripts collection is clear, if not call Clear before.