Data Model > Extending the UNICOM Intelligence Data Model > Creating a CDSC > Handling hierarchical data > VDATA and HDATA examples > Implementing UPDATE for VDATA
 
Implementing UPDATE for VDATA
When existing records are changed, the sequence is:
The Provider creates the Command object.
The Provider adds bindings for the variables for which it wants to change data, and any other variables it needs to inspect in order to know whether a particular records needs to be changed.
The Provider calls MoveFirst/MoveNext (and the CDSC fills in the Value objects as necessary) until it finds a record that it wants to change. Note that up to this point, the behavior is identical to that for SELECT, but from this point onwards, for the records that are to be changed, the behavior is the same as the writing of data in a new record by AddNew.
The Provider changes the values in the Value objects.
The Provider calls Update and the CDSC writes the data from the Value objects.
The Provider repeatedly calls MoveNext, and for any other records that need changing, it changes the Values and calls Update.
When writing data, the CDSC should not change the data for any variables that weren't bound. For efficiency, it may be worth avoiding writing data for any bound variables whose values weren't changed.
Note that the major differences between adding new records and changing existing records are:
How the Provider finds the record to be written: either creating a new record with AddNew or navigating to an existing record.
How many records can be affected: updating can change multiple records in a single pass through the data whereas new records must be added one at a time.
See also
VDATA and HDATA examples