Data Model > Extending the UNICOM Intelligence Data Model > Creating a CDSC > Implementing the features of a CDSC > Implementing DDL hierarchical table
 
Implementing DDL hierarchical table
Append
When the Provider adds a hierarchical table to another table through the CDSC, it:
Uses the Source.Tables.Item property to get a reference to the CDSC's HDATA Table object.
If the new table is to be added to a table at a lower level, the Provider uses the Table.Children.Item property on HDATA and its children, repeatedly, to find the table at the correct level.
Creates a new instance of a Table object and sets its properties (at least Type and Name).
Calls Table.Children.Append to add the new table.
Use the Table object that is passed as a parameter to Children.Append as a template only. The CDSC should create a new Table object and copy its properties from the Table parameter.
In the C++ skeleton project, call CTables::InternalAdd to add the new Table object to the collection, and change the CTables::Append function to return S_OK instead of E_NOTIMPL if it succeeds.
Delete
When the Provider deletes a hierarchical table from another table through the CDSC, it:
Uses the Source.Tables.Item property to get a reference to the CDSC's HDATA Table object.
If the table is to be deleted from a table at a lower level, the Provider uses the Table.Children.Item property on HDATA and its children, repeatedly, to find the table at the correct level.
Calls Table.Children.Delete specifying the index of the table to be deleted.
The index parameter passed to Children.Delete is a Variant, which contains either the name (in any mixture of upper and lower case) of the table to delete or its numeric position (counting the tables from 0).
When the CDSC deletes a table, it should also delete the data for the table. If the CDSC does not do this, the data will remain in the database and there will be no way to access it.
In the C++ skeleton project, call CTables::InternalRemove to remove the new Table object from the collection and change the CTables::Delete function to return S_OK instead of E_NOTIMPL if it succeeds.
See also
Handling hierarchical data
Implementing the features of a CDSC