I'm having a trigger error its not executing the syntax seems fine to me
I'm trying to preserve the functional dependency dtype->skill
delimiter |
CREATE TRIGGER htmlid
BEFORE INSERT ON Droid
FOR EACH ROW
BEGIN
IF EXISTS(
Select dtype t, mainskill m from Droid where t=NEW.dtype AND m!=NEW.m;
)
END IF;
END
|
delimiter ;
Any help?
EDIT: I've tried this and it still doesn't work gives a syntax error says check ur manual
create trigger foo before insert on Droid
for each row
begin
IF EXISTS(
Select dtype t, mainskill m from Droid where t=NEW.dtype AND m!=NEW.m;
) THEN signal sqlstate '45000';
end if;
end;$$
heres the error I'm getting for the answer by anonymous
stack trace: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds to your MySQL server version for the right syntax to use near '' atline 5
mysql>
mysql> SET @recCount = (Select count(*) from Droid where dtype=NEW.dtype AND minskill = NEW.mainskill);
ERROR 1054 (42S22): Unknown column 'NEW.dtype' in 'where clause'
mysql> If @recCount > 0 THEN
-> set raise_err_msg = concat('Error: <put error msg here> ', cast(dtye as char));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds to your MySQL server version for the right syntax to use near 'If @ecCount > 0 THEN
set raise_err_msg = concat('Error: <put error msg her' at line 1
mysql> signal sqlstate '45000' set message_text = raise_err_msg;
ERROR 1054 (42S22): Unknown column 'raise_err_msg' in 'field list'
mysql> END IF;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds to your MySQL server version for the right syntax to use near 'END F' at line 1