创建以下触发器
后DELIMITER $$
CREATE TRIGGER NUMERO_OS AFTER INSERT ON custom_values
FOR EACH ROW
BEGIN
IF NEW.custom_field_id = 4 AND NEW.customized_type = 'Issue' THEN
SET @os = (SELECT MAX(SUBSTRING(value FROM 1 FOR 3)) + 1 FROM custom_values WHERE customized_type = 'Issue' AND custom_field_id = 4 AND SUBSTRING(value FROM 5 FOR 8) = YEAR(CURDATE()));
IF @os = NULL THEN
@os = '001';
END IF;
END IF;
END$$
DELIMITER ;
我在@os ='001'附近出现“语法错误”;“。
我应该怎么做才能运行MySQL Trigger?
答案 0 :(得分:0)
尝试重复set
:
IF @os IS NULL THEN
SET @os = '001';
END IF;