3248
MariaDBERRORNotableTriggersHIGH confidence
Invalid use of OLD/NEW in trigger context
Production Risk
Medium — trigger creation fails, preventing the intended automation.
How to reproduce
trigger — this will error
trigger — this will error
CREATE TRIGGER trg BEFORE INSERT ON t1 FOR EACH ROW SET @x = OLD.id;
expected output
ERROR 3248 (HY000): There is no OLD row in on INSERT trigger.
Fix
Remove invalid OLD reference
Remove invalid OLD reference
CREATE TRIGGER trg BEFORE INSERT ON t1 FOR EACH ROW SET @x = NEW.id;
Why this works
BEFORE INSERT triggers only have access to NEW; remove the OLD reference.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3248 ER_INVALID_USE_OF_OLD_AND_NEW_FUNCTIONS
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev