Responding to Client Update Requests

From RAD Studio
Jump to: navigation, search

Go Up to Using Provider Components Index

A provider applies updates to database records based on a Delta data packet received from a client dataset or XML broker. The client requests updates by calling the ApplyUpdates method (indirectly, through the IAppServer interface).

As with all method calls made through the IAppServer interface, the provider can communicate persistent state information with a client dataset before and after the call to ApplyUpdates. This communication takes place using the BeforeApplyUpdates and AfterApplyUpdates event handlers.

If you are using a dataset provider, a number of additional events allow you more control:

When a dataset provider receives an update request, it generates an OnUpdateData event, where you can influence how updates are applied. After the OnUpdateData event, the provider writes the changes to the database or source dataset.

The provider performs the update on a record-by-record basis. Before the dataset provider applies each record, it generates a BeforeUpdateRecord event, which you can use to resolve the error. Usually errors occur because the change violates a server constraint or a database record was changed by a different application subsequent to its retrieval by the provider, but prior to the client dataset request to apply updates.

Update errors can be processed by either the dataset provider or the client dataset. When the provider is part of a multi-tiered application, it should handle all update errors that do not require user interaction to resolve. When the provider can not resolve an error condition, it temporarily stores a copy of the offending record. When record processing is complete, the provider returns a count of the errors it encountered to the client dataset, and copies the unresolved records into a results data packet that it returns to the client dataset for further reconciliation.

The event handlers for all provider events are passed the set of updates as a client dataset. If your event handler is only dealing with certain types of updates, you can filter the dataset based on the update status of records. By filtering the records, your event handler does not need to sort through records it will not be using. To filter the client dataset on the update status of its records, set its StatusFilter property.

Note: Applications must supply extra support when the updates are directed at a dataset that does not represent a single table.


See Also