FireDAC.Comp.Client.TFDAdaptedDataSet.OnExecuteError

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property OnExecuteError: TFDExecuteErrorEvent read FOnExecuteError  write FOnExecuteError;

C++

__property TFDExecuteErrorEvent OnExecuteError = {read=FOnExecuteError, write=FOnExecuteError};

Properties

Type Visibility Source Unit Parent
event public
FireDAC.Comp.Client.pas
FireDAC.Comp.Client.hpp
FireDAC.Comp.Client TFDAdaptedDataSet

Description

The event is triggered when an error is generated, while executing an Array DML query.

The OnExecuteError event is triggered, when the dataset failed to execute the Array DML using the Execute method and when ATimes > 1. Using this event handler you can:

  • skip the erroneous row of the parameters' array;
  • change the values in the erroneous row of the parameters' array;
  • stop the full Array DML execution.

Note: OnExecuteError will not be called for the syntax errors or when ATimes = 1.

Example

Parameter description:

  • ASender - The reference to the dataset.
  • ATimes - The current Array DML size. It may be different from the value of the Execute method's ATimes parameter, if the full operation is splitted into smaller operations (on Firebird, for example).
  • AOffset - The current Array DML offset. It may be different from the value of the Execute method's AOffset parameter, if there was skipped erroneous rows or full operation is splitted into few more small (on Firebird, for example).
  • AError - The original DBMS returned error. Check AError.Errors.RowIndex for the index of the erroneous row in the parameters' array.
procedure TForm1.ADQuery1ExecuteError(ASender: TObject; ATimes,
  AOffset: Integer; AError: EFDDBEngineException; var AAction: TFDErrorAction);
begin
  if AException.Errors[0].Kind = ekUKViolated then
    AAction := eaSkip
  else
    AAction := eaFail;
end;

See Also