treasuredb/schema/triggers/x_spentChangedOutsideTrigger.sql
Florian "flowdy" Heß df9c0b4065 Fixed trigger sequence
2017-02-21 22:24:27 +01:00

10 lines
388 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(FAIL, "spent is set and adjusted automatically according to added Transfer records");
END;