Developer Documentation Library > Data Model > Extending the UNICOM Intelligence Data Model > Creating a CDSC > Handling hierarchical data > VDATA and HDATA examples > Implementing Add, Update, and Delete for HDATA
 
Implementing Add, Update, and Delete for HDATA
Add, Update, and Delete can be implemented for HDATA in a similar way to the VDATA table after the Command object has been created for the columns on the level of interest. However, these operations affect only the row and records on the selected Command level and its child levels. Thus, with the bindings described in Implementing SELECT for HDATA, if Add is called for the Person-level Command object, an extra row is inserted into the Person table, into which the Provider can set the value for the Age column, and the child Vehicle-level Command is set to access the set of records for the new Person, which will of course be empty, as the Person didn't exist in the data before. However, at this point the Provider can call Add on the Vehicle Command, to add new Vehicle records for the person, and set data for the Transport column. But none of these changes affect the root-level table.
To illustrate this, consider adding the details of the following person to HDATA:
ID
Area
HouseType
Gender
Age
Vote
Transport
UseItOften
1
North
Flat
Fem
27
Lib
Null
Null
The root Command would have bindings for ID, Area, HouseType and Person. The Person Command would have bindings for Gender, Age, Vote and Vehicle. The Vehicle Command would have bindings for Transport and UseItOften, unless in this example the Nulls in those columns indicates that this person has no vehicle, in which case there's no need to add the Vehicle table binding at all.
The new person is in household 1 and so the Provider would do a MoveFirst/MoveNext sequence, checking the ID value until it found the required household. Then, with the Person Command automatically positioned at the records for this household, the Provider would call Add on the Person Command, causing the CDSC to create a new record in the Person table, and set the Vehicle Command to point to an empty set of records. The Provider would then set the values for Gender, Age and Vote, and call Update on the Person Command. If there were Vehicle data to add for this person, the Provider would call Add on the Vehicle Command, to create a record in the previously-empty Vehicle table for the new person, set values for Transport and UseItOften, and call Update on the Vehicle Command.
See also
Handling hierarchical data
VDATA and HDATA examples