Hook Package
A hook package holds the hand-written code of one table. Invantive Studio generates the business layer of a table, and the hook package is where code is added that the repository cannot describe: defaults derived from other tables, checks that span several tables, cascading changes and recalculations.
The name of the hook package is the name of the table with the first underscore replaced by #, such as bubs#projecten for the table bubs_projecten. When a table has no hook package yet, the generation creates an empty one.
Hooks
A hook package answers nine questions, one per hook, with a function such as has_before_insert. For each hook that answers yes, the generated code calls the procedure of the same name:
before_insert,before_update,before_deleterun before the row is written, after the action rules of the same moment.after_insert,after_update,after_deleterun after the row is written.on_insert,on_update,on_deletereplace the write itself.
Each procedure receives the row as p_last, p_old and p_new, with the same meaning as :last, :old and :new in an attribute rule.
Installation
The hand-written hook packages are installed after the business layer has been generated, and replace the empty ones. A generation run leaves an existing hook package alone.