I would like to set a trigger where upon inserting a new record
with permalink set to "myfilename" would become "myfilename-id"
where id represents the auto-incremented value of the id field.
So I tried:
drop trigger article_filename;
CREATE TRIGGER article_filename BEFORE INSERT ON adoppt.articles2
FOR EACH ROW SET NEW.permalink = CONCAT(NEW.permalink, "-" ,
NEW.id );
However this creates a permalink of myfilename-0 as the id value
was obviously not available.
So I tried changing the above to AFTER INSERT:
CREATE TRIGGER article_filename AFTER INSERT ON adoppt.articles2 FOR EACH ROW SET NEW.permalink = CONCAT(NEW.permalink, "-" , NEW.id );
and got:
#1362 - Updating of NEW row is not allowed in after trigger
So I tried
CREATE TRIGGER article_filename …
[Read more]