3
我執行Firedac TFDScript錯誤試圖刪除一個不存在的表時,有一個討厭的錯誤:FireDAC TFDScript錯誤試圖刪除一個不存在的表
- 德爾福柏林10.1 UPD 2
- 數據庫火鳥2.5
主叫FDScript.ExecuteAll當它給出一個錯誤(它通過FDScript.ValidateAll沒有任何問題)
我執行的代碼是作爲FOLL行:
FDScript: TFDScript;
{...}
begin
FDScript.ScriptOptions.Reset;
FDScript.SQLScripts.Clear;
FDScript.SQLScriptFileName := '';
FDScript.ScriptOptions.CommandSeparator := ';';
FDScript.ScriptOptions.CommitEachNCommands := 1;
FDScript.ScriptOptions.DropNonexistObj := True; // seems to ignore this directive
FDConnection.StartTransaction;
try
FDScript.SQLScripts.Add.SQL.Add('drop table countries;');
FDScript.ValidateAll; // no errors here
ScriptStatus := GetEnumName(TypeInfo(TFDScriptStatus), Ord(FDScript.Status));
if FDScript.Status = ssFinishSuccess then begin
FDScript.ExecuteAll; // ERROR HERE! TABLE COUNTRIES DOES NOT EXIXTS
if FDScript.TotalErrors = 0 then begin
FDConnection.Commit;
end
else begin
FDConnection.Rollback;
end;
end
else begin
FDConnection.Rollback;
end;
except
FDConnection.Rollback;
raise;
end;
end;
正在引發什麼異常?它看起來像FireDac允許爲ObjNotExists引發內部異常,然後檢查是否應該忽略或重新提出。如果(E.Kind = ekObjNotExists)和Engine.ScriptOptions.DropNonexistObj和 ((eCmdKind = skUnknown)和(oCmd.CommandKind in [skDrop,skAlter])在E上的FireDac.Comp.ScriptCommands中查看此代碼:EFDDBEngineException開始 )或(eCmdKind in [skDrop,skAlter]))然後開始 –