I’m trying to create a trigger in SQL, but the scenario forms a Infinite loop.
CREATE TRIGGER UpdateTableB
AFTER UPDATE ON tableA
FOR EACH ROW
BEGIN
UPDATE tableB
SET info = NEW.data
WHERE id = NEW.id;
END;
CREATE TRIGGER UpdateTableA
AFTER UPDATE ON tableB
FOR EACH ROW
BEGIN
UPDATE tableA
SET data = NEW.info
WHERE id = NEW.id;
END;
What should I do to avoid the loop?
It results Infinite loop.
New contributor
Vincent Chan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.