标签:
FD 提供了批量执行功能, 称为 Array DML。 可以这么做:
FDQuery1.SQL.Text := ‘insert into MyTab values (:p1, :p2, :p3)‘;
// here FDQuery1.Params collection is filled by 3 parameters
FDQuery1.Params.ArraySize := 100;
for i := 0 to 100-1 do begin
FDQuery1.Params[0].AsIntegers[i] := i;
FDQuery1.Params[1].AsStrings[i] := ‘qwe‘;
FDQuery1.Params[2].Clear(i);
end;
FDQuery1.Execute(100, 0); //从0开始,执行100个批量执行
ShowMessage(IntToStr(FDQuery1.RowsAffected)); //显示执行成功的条数
OnExecuteError 事件可处理执行错误
procedure TForm1.FDQuery1ExecuteError(ASender: TObject; ATimes,
AOffset: Integer; AError: EFDDBEngineException; var AAction: TFDErrorAction);
begin
if AError.Errors[0].Kind = ekUKViolated then
AAction := eaSkip
else
AAction := eaFail;
end;
标签:
原文地址:http://www.cnblogs.com/zhenfei/p/4643984.html