SQLite Forum

How to write this trigger?
Login
If you have, for example, an insert trigger that contains an update statement for the same row, then the check constraints will be run after the insert and again after the update.

Note that you obviously cannot update the row you are inserting in a before insert trigger since the row has not yet been inserted.  

The purpose of a before trigger is to ensure that the database is in a state that will permit the operation to proceed or to be able to raise an appropriate error if the operation would violate business rules.

The purpose of an after trigger is to carry out concomitant changes to the database as a result of the successful completion (including having passed any constraints) of the operation firing the trigger.