Show: Delphi C++
Display Preferences

Using Multiple Update Objects Index

From RAD Studio XE3
Jump to: navigation, search

Go Up to Using the Borland Database Engine Index

Note: The Borland Database Engine (BDE) has been deprecated, so it will not be enhanced. For instance, BDE will never have Unicode support. You should not undertake new development with BDE. Consider migrating your existing database applications from BDE to dbExpress. For information about migrating from BDE to dbExpress, see

When more than one base table referenced in the update dataset needs to be updated, you need to use multiple update objects: one for each base table updated. Because the dataset component's UpdateObject only allows one update object to be associated with the dataset, you must associate each update object with a dataset by setting its DataSet property to the name of the dataset.

Tip: When using multiple update objects, you can use TBDEClientDataSet instead of TClientDataSet with an external provider. This is because you do not need to set the source dataset's UpdateObject property.

The DataSet property for update objects is not available at design time in the Object Inspector. You can only set this property at run time.

UpdateSQL1.DataSet := Query1;
UpdateSQL1->DataSet = Query1;

The update object uses this dataset to obtain original and updated field values for parameter substitution and, if it is a BDE-enabled dataset, to identify the session and database to use when applying the updates. In order for the parameter substitution to work correctly, the update object's DataSet property must be the dataset that contains the updated field values. When using the BDE-enabled dataset to cache updates, this is the BDE-enabled dataset itself. When using a client dataset, this is a client dataset that is provided as a parameter to the BeforeUpdateRecord event handler.

When the update object has not been assigned to the dataset's UpdateObject property, its SQL statements are not automatically executed when you call ApplyUpdates. To update records, you must manually call the update object from a Bde.DBTables.TBDEDataSet.OnUpdateRecord event handler (when using the BDE to cache updates). In the event handler, the minimum actions you need to take are:

  • If you are using a client dataset to cache updates, you must be sure that the updates object's DatabaseName and SessionName properties are set to the DatabaseName and SessionName properties of the source dataset.
  • The event handler must call the update object's ExecSQL or Apply method. This invokes the update object for each record that requires updating. For more information about executing update statements, see Executing the SQL Statements.
  • Set the event handler's UpdateAction parameter to uaApplied (OnUpdateRecord) or the Applied parameter to True (BeforeUpdateRecord).

You may optionally perform data validation, data modification, or other operations that depend on each record's update.

Warning: If you call an update object's ExecSQL or Apply method in an OnUpdateRecord event handler, be sure that you do not set the dataset's UpdateObject property to that update object. Otherwise, this will result in a second attempt to apply each record's update.

See Also


Personal tools
Previous Versions
In other languages