treasuredb/schema/triggers/enforceFixedCredit.sql

9 lines
296 B
MySQL
Raw Normal View History

CREATE TRIGGER enforceFixedCredit
BEFORE UPDATE OF account, value ON Credit
WHEN EXISTS (SELECT * FROM Transfer WHERE credId=NEW.credId)
2017-01-22 21:20:17 +01:00
AND NOT EXISTS (SELECT * FROM __INTERNAL_TRIGGER_STACK)
BEGIN
SELECT RAISE(FAIL, "Credit involved in transactions to revoke at first");
END;