将 ZSQLProcessor.Script.Text 从 ZeosLib 迁移到 FireDAC MySQL

Migrating ZSQLProcessor.Script.Text from ZeosLib to FireDAC for MySQL

正在尝试将应用程序迁移到 Delphi 10.2 上的 FireDAC 使用,但仅使用此功能: 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;

卡在线路 无法相处,任何帮助都会很好:

ZSQLProcessor.Script.Text := script;

参考: ZSqlProcessor.pas

没有最后一部分的转换函数看起来是这样的:

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;

将单个 SQL 脚本分配给 TFDScript object you can simply Add one TFDSQLScript item to the TFDSQLScripts collection and set its SQL 字符串列表集合文本到您选择的 SQL 命令,例如:

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 }

当然,这是假设TFDSQLScripts collection is clear, if not call Clear之前。