From RAD Studio API Documentation
Jump to: navigation, search


property OnUpdateError: TFDUpdateErrorEvent read FOnUpdateError  write FOnUpdateError;


__property TFDUpdateErrorEvent OnUpdateError = {read=FOnUpdateError, write=FOnUpdateError};


Type Visibility Source Unit Parent
event public
FireDAC.Comp.DataSet TFDDataSet


Fires if an exception is generated when updates are applied to a database.

Use the OnUpdateError event handler to respond to exceptions raised while applying immediate or cached updates to a database. 

ASender is the dataset to which updates are applied. 

AException is a pointer to a EFDException object from which an application can extract an error message and the actual cause of the error condition. The OnUpdateError handler can use this information to determine how to respond to the error condition. In most cases, the AException object is an instance of the EFDDBEngineException class or even one of its DBMS-specific subclasses.   ARow is a DatS row object, repesenting an erroneous record in the dataset. This record is also the current record in ASender

ARequest indicates whether the error occurred while inserting, deleting, or modifying a record. 

AAction indicates the action to take when the OnUpdateError event handler exits. On entry into the handler, AAction is always set to eaDefault, which leads to uaFail, if not changed. If OnUpdateError can handle or correct the error, set AAction to uaRetry before exiting the error handler, or cconsider other options. 

The error handler can use the OldValue and NewValue properties to evaluate error conditions and set NewValue to a apply a new value. In this case, set AAction to uaRetry before exiting. 

Warning: The code in a OnUpdateError handler must not call any methods that make a different record, the current one.


procedure TForm1.FDQuery1UpdateError(ASender: TDataSet; AException: EFDException;
    ARow: TFDDatSRow; ARequest: TFDUpdateRequest; var AAction: TFDErrorAction);
  if (E is EFDDBEngineException) and (EFDDBEngineException(E).Kind = ekUKViolated) then begin
    DataSet.FieldByName('ID').AsInteger := GetNextFreeID;
    Action := eaRetry;

See Also