Reputation: 5451
I get an issue when creating a trigger with MySQL.
delimiter //
CREATE TRIGGER trigversion AFTER INSERT ON offers
FOR EACH ROW
BEGIN
update versions set value = @value + 1 limit 1;
END;//
Issue :
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '//' at line 5
Upvotes: 1
Views: 1074
Reputation: 2184
as per @eggyal's comments. It matters what platform you are running the SQL query from.
I dont think DELIMITER
is valid SQL syntax, I believe its provided by PHPMyadmin.
If you are running from an environment like PHP, try the query without setting a new delimiter, e.g.
CREATE TRIGGER trigversion AFTER INSERT ON offers
FOR EACH ROW
BEGIN
update versions set value = @value + 1 limit 1;
END;
per the OP's comment that the command was being run against PHPMyadmin, I think its probably worth noting, that in that case, I think it was simply a syntax error in the query, where the delimiter wasn't being reset properly after the trigger. I believe this query should fix the error and run on Phpmydmin - but importantly won't run through PHP (PDO)
DELIMITER |
CREATE TRIGGER trigversion AFTER INSERT ON offers
FOR EACH ROW
BEGIN
update versions set value = @value + 1 limit 1;
END |
DELIMITER ;
Upvotes: 1