API:FireDAC.Comp.Client.TFDMemTable.OnUpdateError
Delphi
property OnUpdateError: TFDUpdateErrorEvent read FOnUpdateError write FOnUpdateError;
C++
__property OnUpdateError;
Contents
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
event | published | FireDAC.Comp.Client.pas FireDAC.Comp.Client.hpp |
FireDAC.Comp.Client | TFDMemTable |
Description
Fires if an exception is generated when updates are applied to a database.
FireDAC.Comp.Client.TFDMemTable.OnUpdateError inherits from FireDAC.Comp.DataSet.TFDDataSet.OnUpdateError. All content below this line refers to FireDAC.Comp.DataSet.TFDDataSet.OnUpdateError.
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.
Example
procedure TForm1.FDQuery1UpdateError(ASender: TDataSet; AException: EFDException;
ARow: TFDDatSRow; ARequest: TFDUpdateRequest; var AAction: TFDErrorAction);
begin
if (E is EFDDBEngineException) and (EFDDBEngineException(E).Kind = ekUKViolated) then begin
DataSet.FieldByName('ID').AsInteger := GetNextFreeID;
Action := eaRetry;
end;
end;