DELIMITER $$
USE `airdb`$$
DROP TRIGGER /*!50032 IF EXISTS */ `updateprodaja`$$
CREATE
/*!50017 DEFINER = 'root'@'localhost' */
TRIGGER `updateprodaja` BEFORE UPDATE ON `prodaja`
FOR EACH ROW BEGIN
IF ( SELECT podmireno FROM prodaja WHERE id = NEW.id ) > 0 THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Error: you got an error'
END IF;
END;
$$
DELIMITER ;
得到错误
Error Code: 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 'END IF;
END' at line 7
答案 0 :(得分:0)
试试这个你忘了在结束前终止sql查询
DELIMITER $$
USE `airdb`$$
DROP TRIGGER /*!50032 IF EXISTS */ `updateprodaja`$$
CREATE
/*!50017 DEFINER = 'root'@'localhost' */
TRIGGER `updateprodaja` BEFORE UPDATE ON `prodaja`
FOR EACH ROW BEGIN
IF ( SELECT podmireno FROM prodaja WHERE id = NEW.id ) > 0 THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Error: you got an error';
END IF;
END;
$$
DELIMITER ;