FireDAC.Comp.DataSet.TFDDataSet.OnReconcileError

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property OnReconcileError: TFDReconcileErrorEvent read FOnReconcileError

C++

__property TFDReconcileErrorEvent OnReconcileError = {read=FOnReconcileError, write=FOnReconcileError};

Properties

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

Description

Fires when a dataset needs to reconcile an update to a record that cannot not be applied.

Use the OnReconcileError event handler to respond to error conditions that occur when the ApplyUpdates method is applying changes to the database records. The OnReconcileError event handler is called by the Reconcile method. 

When invoking Reconcile, the dataset loops through all records with associated exception objects.Ffor each such record, it calls the OnReconcileError event handler. The event handler gets:

  • E--reference to the exception object. See the Handling Errors topic for how to work with exception objects.
  • UpdateKind--the update kind of the current record. It can be one of the following values: rsInserted, rsDeleted, rsModified, rsUnchanged.

After handling the error, the event handler should set the Action argument. The default value is raMerge. The possible values are:

Action 

Description 

raSkip

Skips the current record. 

raAbort

Quits the Reconcile call. 

raMerge 

Clears the current record error state, so the changes to the record become the initial state of this record. In other words, it merges changes to the dataset records cache. 

raCorrect 

Clears the current record error state. In other words, it marks the record as correctly applied. 

raCancel 

Cancels the current record changes. 

raRefresh 

Cancels the current record changes and rereads the record values from the database. 

  The event handler can analyze the original and the current field values, by reading the OldValue and NewValue properties. The application can also update the current field value, set Action to raCorrect, and later call ApplyUpdates again.

Example

procedure TForm1.FDMemTable1ReconcileError(DataSet: TFDDataSet; E: EFDException;
  UpdateKind: TFDDatSRowState; var Action: TFDDAptReconcileAction);
begin
  if (UpdateKind = rsInserted) and (E is EFDDBEngineException) and (EFDDBEngineException(E).Kind = ekUKViolated) then begin
    DataSet.FieldByName('ID').AsInteger := GetNextFreeID;
    Action := raCorrect;
  end;
end;

See Also