Using the Bitemporal Triggers

We have pushed a new version to test, in which the triggers on bitemporal attributes can be tested. If you generate the SQL code for our example model with Temporalization set to “Bitemporal” and no metadata, then you can use the script below to test the triggers.

The script tests the insert, update, and delete trigger on the latest view for ST_Stage. Insert and delete are quite straightforward in that they do what you expect, insert rows and logically delete rows. Update is slightly more complex with its behavior depending on what is updated. If only ST_NAM_Stage_Name is updated, then a new version is created. If both ST_NAM_Stage_Name and ST_NAM_ErasedAt are updated, then a correction is made by first logically deleting the old row then inserting a new one. If only ST_NAM_ErasedAt is updated, then only a logical delete is performed. These views and their functions should cover all possible use cases.

Published by

Lars Rönnbäck

Co-developer of the Anchor Modeling technique. Programmer of the online modeling tool. Site maintainer. Presenter and trainer.

Leave a Reply

Your email address will not be published. Required fields are marked *