这个mysql触发器的语法错误

时间:2015-04-21 04:20:06

标签: mysql triggers

我的MYSQL触发器出错了。我使用了某种形式的语法,但仍然出现语法错误。希望有人可以帮助我。

CREATE TRIGGER after_insert_table_a AFTER INSERT ON table_a
FOR EACH ROW BEGIN
  DECLARE colorL VARCHAR(7);
  SET linesT = (
    SELECT COUNT(id)       
      FROM lineas 
      WHERE fk_id = NEW.fk_id
  );
  IF (linesT = 0) THEN
    SET colorL = '#D3D3D3';         
  ELSE IF (linesT = 1) THEN
    SET colorL = ( 
      SELECT l.color 
        FROM sel_lineas AS tl  
          INNER JOIN lineas  AS l ON l.id = tl.line_id 
        WHERE tl.fk_id = NEW.fk_id 
    );          
  ELSE
    SET colorL = '#000000';
  END IF;
  UPDATE tabla_colors  SET colour_l = colorL WHERE id = NEW.fk_id;
END;

我会帮助您提供任何帮助。

以下是错误消息: MySQL说:#1064 - 你的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在#DEC; DECLARE colorL VARCHAR(7)附近使用正确的语法; SET linesT =(SELECT COUNT' at line 1

0 个答案:

没有答案