FireDAC.Comp.Client.TFDCustomSchemaAdapter.ApplyUpdates

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function ApplyUpdates(AMaxErrors: Integer = -1): Integer;

C++

int __fastcall ApplyUpdates(int AMaxErrors = 0xffffffff);

Properties

Type Visibility Source Unit Parent
function public
FireDAC.Comp.Client.pas
FireDAC.Comp.Client.hpp
FireDAC.Comp.Client TFDCustomSchemaAdapter

Description

Applies changes for all records in the centralized change journal to the database.

Use ApplyUpdates to apply changes for all records in the centralized change journal to the database. Returns the number of encountered errors. The centralized change journal collects changes from:

The ApplyUpdates call performs the following steps:

  • Fires a BeforeApplyUpdate event.
  • Calls the data adapters to generate / use SQL update commands for each row and post changes to the database.
  • Fires an AfterApplyUpdate event.

Calls the Reconcile method to reconcile any records that had errors in step 2.

Note: There is no CommitUpdates method and it must be called in code for each associated dataset.

AMaxErrors indicates the maximum number of errors that FireDAC should allow before prematurely stopping the update operation. Set AMaxErrors to –1 to indicate that there is no limit to the number of errors or to 0 to indicate that no error is allowed. 

ApplyUpdates returns the number of errors it encountered. Based on this return value and the setting of AMaxErrors successfully, applied updates are removed from the centralized change log. If the update process is aborted before all updates are applied, any unapplied updates remain in the change log. 

ApplyUpdates does not raise an exception. Instead, the application should review erroneous records using Reconcile and the OnReconcileRow event handler or the FilterChanges and RowError properties for each dataset. For more details, read "Reviewing errors" at Caching Updates.

See Also

Samples