Answer the question
In order to leave comments, you need to log in
What is my mistake when creating SQlite trigger?
Hello!
There is an accounts table with columns Active (Bool), СheckLimit (Bool), MaxLimit (Numeric), CheckCount (Numeric), LimitReached(Bool). Task: set True in the LimitReached column of the row in which the field Active is True, CheckLimit is True, CheckCount == MaxLimit after the LimitCount column update event.
I give the lines below, according to the condition, two lines (3 and 4) are suitable, when the LimitCount field is updated to 5 and 6, respectively.
I tried to create a trigger like this, but it doesn't work:
CREATE TRIGGER SetCheckLimit
AFTER UPDATE OF LimitCount
ON accounts
FOR EACH ROW
WHEN ( ( (
SELECT Active
FROM accounts
)
IS 1) AND
( (
SELECT CheckLimit
FROM accounts
)
IS 1) AND
( (
SELECT CheckCount
FROM accounts
)
== (
SELECT MaxLimit
FROM accounts
)
) )
BEGIN
UPDATE accounts
SET LimitReached = 1;
END;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question