treasuredb/schema/triggers/enforceFixedDebit.sql

9 lines
315 B
MySQL
Raw Normal View History

CREATE TRIGGER enforceFixedDebit
BEFORE UPDATE OF debtor, transferCredit, value ON Debit
WHEN EXISTS (SELECT * FROM Transfer WHERE billId=NEW.billId)
2017-01-22 21:20:17 +01:00
AND NOT EXISTS (SELECT * FROM __INTERNAL_TRIGGER_STACK LIMIT 1)
BEGIN
SELECT RAISE(FAIL, "Debt is involved in transfers to revoke at first");
END;