Occurs if an exception is generated when cached updates are applied to a database.
Write an OnUpdateError event handler to respond to exceptions generated while applying cached updates to a database.
Because there is a delay between the time a record is first cached and the time cached updates are applied, there is a possibility that another application may change one or more of the same records in the database before the cached changes can be applied. MySQL checks for this condition and raises an exception. TMySQLDataSet responds by calling the OnUpdateError event handler if it exists.
DataSet is the name of the dataset to which updates are applied.
E is a pointer to a EDatabaseError 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.
UpdateKind indicates whether the error occurred while inserting, deleting, or modifying a record.
UpdateAction indicates the action to take when the OnUpdateError handler exits. On entry into the handler, UpdateAction is always set to uaFail. If OnUpdateError can handle or correct the error, set UpdateAction to uaRetry before exiting the error handler.
The error handler can use the TField.OldValue and TField.NewValue properties to evaluate error conditions and set TField.NewValue to a new value to reapply. In this case, set UpdateAction to uaRetry before exiting.
If a call to ApplyUpdates raises an exception and ApplyUpdates is not called within the context of a try...except block, an error message is displayed. If an OnUpdateError handler cannot correct the error condition and leaves UpdateAction set to uaFail, the error message is displayed twice. To prevent redisplay, set UpdateAction to uaAbort in the error handler.
The code in an OnUpdateError handler must not call any methods that make a different record the current one.