Using MySQL 5.5, the following trigger is getting rejected with an error:
create trigger nodups
before insert on `category-category`
for each row
begin
if(catid >= relatedid) then
signal 'catid must be less than relatedid';
end if
end;
I'm getting the following error:
ERROR 1064 (42000): 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 '-category for each row begin if(catid >= relatedid) then signal 'catid must be l' at line 1
What is wrong with the syntax for this trigger?
For what it's worth, I'm just trying to prevent inserts with catid >= relatedid. I am open to other methods of achieving this goal.
Edit: The query above is being entered on a single line, semi-colons and all.
I tried it again using a delimiter. Here is the result:
mysql> delimiter ###
mysql> create trigger nodups
-> before insert on `category-category`
-> for each row
-> begin
-> if(catid >= relatedid) then
-> signal 'catid must be less than relatedid';
-> end if
-> end;
-> ###
ERROR 1064 (42000): 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 ''catid must be less than relatedid';
end if
end' at line 6