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