我有名称为'autoad'的db表,2列为'allads'和'finished',我想要在update查询执行chek之前,如果value(finished)> value(allads)然后抛出异常,我使用了触发器为此,但是当拍拍进入phpmyadmin给错误: mysql说#1303-无法从另一个存储的例程中创建触发器
CREATE TRIGGER before_insert_finished BEFORE INSERT ON autoad
FOR EACH ROW
BEGIN
SET @CountOfCar = (SELECT allads FROM autoad)
SET @CountOfCar2 = (SELECT finished FROM autoad
IF @CountOfCar2>@CountOfCar THEN
ON UPDATE NO ACTION
END
编辑:
在phpmyadmin gui中,只需要代码主体,begin....end
之间,我现在尝试:
BEGIN
SET @CountOfCar = (SELECT allads FROM autoad)
SET @CountOfCar2 = (SELECT finished FROM autoad
IF @CountOfCar2>@CountOfCar THEN
ON UPDATE NO ACTION
END
错误: MySQL说:#1064-您的SQL语法有误;检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在'SET @ CountOfCar2 =(在第3行的SELECT @ autoad IF @ CountOfCar2> @CountOfCar'中完成选择