有人可以帮我解决这个问题,请找出我做错了什么。
有时我没有这个错误......CREATE DEFINER = CURRENT_USER TRIGGER `domitik_db`.`disp_hdw_BEFORE_INSERT` BEFORE INSERT ON `disp_hdw` FOR EACH ROW
BEGIN
declare boxId int UNSIGNED;
declare unitId VARCHAR;
SET unitId=(SELECT homeunit FROM t_cpl WHERE t_cpl.id=NEW.idhardware);
SET boxId=(SELECT dispositifs.idbox FROM dispositifs WHERE dispositifs.id = NEW.iddispositif);
IF (SELECT COUNT(*) FROM disp_hdw, dispositifs, t_cpl as tp WHERE disp_hdw.iddispositif = dispositifs.id AND disp_hdw.idhardware=tp.id AND dispositifs.idbox = boxId AND tp.homeunit=unitId > 0)
THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Cannot add or update row: only one same homeunit id for a single box';
END IF;
END;
第745行的错误1064(42000):您的SQL语法出错;检查与您的MariaDB服务器版本对应的手册,以便在'附近使用正确的语法;
SET unitId =(SELECT homeunit FROM t_cpl WHERE t_cpl.id = NEW.idhardware);