FireDAC.Comp.DataSet.TFDDataSet.OnReconcileError
Delphi
property OnReconcileError: TFDReconcileErrorEvent read FOnReconcileError write FOnReconcileError;
C++
__property TFDReconcileErrorEvent OnReconcileError = {read=FOnReconcileError, write=FOnReconcileError};
Contents
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 |
---|---|
|
Skips the current record. |
|
Quits the Reconcile call. |
|
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. |
|
Clears the current record error state. In other words, it marks the record as correctly applied. |
|
Cancels the current record changes. |
|
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;