Fixed trigger sequence
This commit is contained in:
parent
7faa3a9515
commit
df9c0b4065
@ -1,4 +1,4 @@
|
||||
CREATE TRIGGER enforceFixedCredit
|
||||
CREATE TRIGGER x_changedCredit
|
||||
BEFORE UPDATE OF account, value ON Credit
|
||||
WHEN EXISTS (SELECT * FROM Transfer WHERE credId=NEW.credId)
|
||||
AND NOT EXISTS (SELECT * FROM __INTERNAL_TRIGGER_STACK)
|
@ -1,4 +1,4 @@
|
||||
CREATE TRIGGER enforceFixedDebit
|
||||
CREATE TRIGGER x_changedDebit
|
||||
BEFORE UPDATE OF debtor, transferCredit, value ON Debit
|
||||
WHEN EXISTS (SELECT * FROM Transfer WHERE billId=NEW.billId)
|
||||
AND NOT EXISTS (SELECT * FROM __INTERNAL_TRIGGER_STACK LIMIT 1)
|
@ -1,4 +1,4 @@
|
||||
CREATE TRIGGER enforceImmutableTransfer
|
||||
CREATE TRIGGER x_changedTransfer
|
||||
BEFORE UPDATE OF timestamp, credId, billId, amount ON Transfer -- Allow update of note
|
||||
WHEN OLD.amount IS NOT NULL
|
||||
AND NOT EXISTS (SELECT * FROM __INTERNAL_TRIGGER_STACK)
|
@ -1,6 +1,6 @@
|
||||
-- Prevent modification of paid value outside triggers which must adjust it exclusively
|
||||
-- when new transfer records are inserted
|
||||
CREATE TRIGGER enforceDebtImmutableOutsideTrigger
|
||||
CREATE TRIGGER x_paidChangedOutsideTrigger
|
||||
BEFORE UPDATE OF paid ON Debit
|
||||
WHEN NOT EXISTS (SELECT * FROM __INTERNAL_TRIGGER_STACK LIMIT 1)
|
||||
BEGIN
|
@ -1,4 +1,4 @@
|
||||
CREATE TRIGGER enforceZeroPaidAtStart
|
||||
CREATE TRIGGER x_paidFromBeginning
|
||||
BEFORE INSERT ON Debit
|
||||
BEGIN
|
||||
SELECT RAISE(FAIL, "Debt must be initially unpaid")
|
@ -1,6 +1,6 @@
|
||||
-- Prevent modification of spent value outside triggers which must adjust it exclusively
|
||||
-- when new transfer records are inserted
|
||||
CREATE TRIGGER enforceSpentImmutableOutsideTrigger
|
||||
CREATE TRIGGER x_spentChangedOutsideTrigger
|
||||
BEFORE UPDATE OF spent ON Credit
|
||||
WHEN NOT EXISTS (SELECT * FROM __INTERNAL_TRIGGER_STACK)
|
||||
BEGIN
|
@ -1,4 +1,4 @@
|
||||
CREATE TRIGGER enforceZeroSpentAtStart
|
||||
CREATE TRIGGER x_spentFromBeginning
|
||||
BEFORE INSERT ON Credit
|
||||
BEGIN
|
||||
SELECT RAISE(FAIL, "credit must be initially unused")
|
Loading…
Reference in New Issue
Block a user