RAD Studio
ContentsIndex
PreviousUpNext
Responding to Client Update Requests

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 edit the Delta packet before it is written to the dataset or 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 screen updates before they are applied. If an error occurs when updating a record, the provider receives an OnUpdateError event where it can 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's 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't 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 won't 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.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!