AnyDAC
ContentsIndexHome
PreviousUpNext
TADCustomSchemaAdapter.ApplyUpdates Method

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

Group
Links
Parameters 
Description 
AMaxErrors: Integer = -1 
A maximum number of allowed errors. Default value is -1. 

The number of errors is encountered.

Use ApplyUpdates to apply changes for all records in the centralized change journal to the database. The centralized change journal collects changes from:

  • AnyDAC datasets with SchemaAdapter property set to this TADCustomSchemaAdapter instance;
  • table adapters with SchemaAdapter property set to this TADCustomSchemaAdapter instance.

The ApplyUpdates call performs the steps:

  1. Fires a BeforeApplyUpdate event.
  2. Calls the data adapters to generate / use SQL update commands for each row and post changes to the database.
  3. Fires an AfterApplyUpdate event.
  4. Calls the Reconcile method to reconcile any records that has 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 the AnyDAC 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 records 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 exception. Instead application should review erroneous records using Reconcile and OnReconcileRow event handler, or FilterChanges and RowError properties for each dataset. Read "Reviewing errors" at Caching Updates for more details.

function ApplyUpdates(AMaxErrors: Integer = -1): Integer;
What do you think about this topic? Send feedback!