AnyDAC
ContentsIndexHome
PreviousUpNext
TADStoredProc.OnReconcileError Event

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

Group
Links

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

As part of Reconcile call the dataset will loop through all records with associated exception objects. And for each such record will call the OnReconcileError event handler. The event handler gets:

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

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

Action 
Description 
raSkip 
Just skip current record. 
raAbort 
Just quit from Reconcile call. 
raMerge 
Clear the current record error state, make current record changes the new initial state of this record. IOW, merge changes into dataset records cache. 
raCorrect 
Clear current record error state. IOW, mark the record as correctly applied. 
raCancel 
Cancel current record changes. 
raRefresh 
Cancel current record changes and reread the record values from the database. 

 

The event handler may analyze the original and current field values, by reading TField.OldValue and NewValue properties. Application may also update the current field value, set Action to raCorrect, and later call ApplyUdpates again.

property OnReconcileError: TADReconcileErrorEvent;

Caching Updates, Reconcile, ApplyUpdates, OnUpdateError

procedure TForm1.ADMemTable1ReconcileError(DataSet: TADDataSet; E: EADException;
  UpdateKind: TADDatSRowState; var Action: TADDAptReconcileAction);
begin
  if (UpdateKind = rsInserted) and (E is EADDBEngineException) and (EADDBEngineException(E).Kind = ekUKViolated) then begin
    DataSet.FieldByName('ID').AsInteger := GetNextFreeID;
    Action := raCorrect;
  end;
end;
What do you think about this topic? Send feedback!