CREATE TRIGGER changeinsert BEFORE INSERT ON cdr
FOR EACH ROW
BEGIN
  IF NEW.dstchannel != '' THEN
  IF ((not exists(select id from asterisk.devices where concat(id)=NEW.dst)) and (not exists(select id from asterisk.users where extension=NEW.dst))) THEN
  SET NEW.servicenum = 'out';
  ELSE
  SET NEW.servicenum = 'in';
  END IF;   
  END IF;
END
执行之后:
MySQL 返回:  #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 '' at line 6  有谁知道我哪出语法错误了?servicenum字段 是varchar(30)类型