If the function returns a non-zero value or raises an error, it stops the entire delete process and rolls back all deleted records. If the record validates (returns 0), it is deleted before testing the next record.
Function Validate_Cascade_Delete Returns Boolean
As child records are deleted during a cascading delete, this message is sent to every single child record before it is deleted. It does this recursively for all children, children of children, etc.
If the function returns a non-zero value or it raises an error, it stops the entire delete process and rolls back all deleted records. This is all done in a single pass. If the record validates (returns 0), it is deleted before testing the next record. Therefore, there is no performance penalty for performing the cascade delete validation. If the validation fails, it will take whatever time is needed to restore the deleted records.
This is called after Validate_Delete and before the main record is actually deleted.
You would place this validation event inside the child DD class or object for which the validation is to occur.
Function Validate_Cascade_Delete Returns Boolean If (OrderDtl.Extended_Price > 100) Begin Error DFERR_OPERATOR "Cannot delete orders with details items over $100.00" End End_Function
Using CascadeDeleteAllowed in a child table DD (DataDictionary) allows any child table to determine if it will allow itself to be deleted as part of a cascade delete.