0
votes

I'm trying to create an SQLite trigger that sets the field FlagPayment to 1 automatically every time a player reaches 10 points, however, apparently, I have a syntax error.

CREATE TRIGGER aft_update AFTER UPDATE ON Player
FOR EACH ROW WHEN (NEW.ParticipationPoints % 10 = 0) and (NEW.ParticipationPoints > 0)
BEGIN
    UPDATE Player SET FlagPayment = 1 WHERE ID = NEW.ID
END;

This is the outcome:

near "END": syntax error: CREATE TRIGGER aft_update AFTER UPDATE ON Player FOR EACH ROW WHEN (NEW.ParticipationPoints % 10 = 0) and (NEW.ParticipationPoints > 0) BEGIN UPDATE Player SET FlagPayment = 1 WHERE ID = NEW.ID END

1

1 Answers

0
votes

As shown in the documentation, all statements in the trigger body must be terminated with a semicolon:

BEGIN
    UPDATE Player SET FlagPayment = 1 WHERE ID = NEW.ID;
END;                                                   ^