treasuredb/schema/triggers/x_spentChangedOutsideTrigger.sql
Florian "flowdy" Heß 5299966837 Changed FAIL -> ABORT trigger exceptions
With FAIL, triggers choke but leave the changes in despite. We need to have the current statement undone, however.
2017-02-22 21:58:47 +01:00

10 lines
389 B
SQL

-- Prevent modification of spent value outside triggers which must adjust it exclusively
-- when new transfer records are inserted
CREATE TRIGGER x_spentChangedOutsideTrigger
BEFORE UPDATE OF spent ON Credit
WHEN NOT EXISTS (SELECT * FROM __INTERNAL_TRIGGER_STACK)
BEGIN
SELECT RAISE(ABORT, "spent is set and adjusted automatically according to added Transfer records");
END;