DBBaseContext :: doBeforeInsert - Before insert handler
The before insert handler is called before inserting a data instance in a collection (DBP_Insert event). When the handler is called the instance to be inserted in the collection is not yet positioned in the property handle, but selected. Hence, only attributes can be accessed in the instance in this phase. References and relationships are not accessible. The before insert handler can deny creating the data instance by returning an error ( any value >0 ).
When the handler is called while maintaining inverse references or extent hierarchies, the instance is not even selected and not accessible at all, i.e. no instance data is available. One may, however, refer to the parent property handle, which is positioned always..
The handler can be overloaded in specialized property context class implementations.
// maintaining inverse persons reference in cars after adding a car to Person::cars
... pCar_persons :: doAfterInsert () {
Property persons(property()); // not selected, but located
Property cars(persons.parent());
if ( persons.selected() ) { // handle event
// now do what is necessary
}
return(false);
}
The value is usually returned from context functions or actions in order to report the result of execution. The variable may contain following values:
- -1: function/action not executed
- 0: function executed normally
- 1-9: Function executed with errors. Error codes depend on the function/action called.