mysql触发和更新出错

时间:2015-03-30 23:15:28

标签: mysql variables if-statement triggers

我有下一个触发器:

CREATE
    TRIGGER t_call_status 
    AFTER INSERT 
    ON tblcdr FOR EACH ROW 
BEGIN

    DECLARE lastid integer;
    DECLARE nseg integer;

    SET lastid = LAST_INSERT_ID();
    SET nseg = 120;

    IF ((origen = 'ANSWERED' && destino = 'ANSWERED') && (billsec_origen >= nseg && disposition_destino >= nseg)) THEN
        update tblcdr set call_status = 3 where id = lastid;
    ELSE IF (origen = 'ANSWERED' && destino = 'ANSWERED') THEN
        update tblcdr set call_status = 2 where id = lastid;
    ELSE IF (origen = 'ANSWERED' && destino <> 'ANSWERED') THEN
        update tblcdr set call_status = 1 where id = lastid;
    ELSE IF (origen <> 'ANSWERED' && destino <> 'ANSWERED') THEN
        update tblcdr set call_status = 0 where id = lastid;
    ELSE
        update tblcdr set call_status = 0 where id = lastid;
    END IF;

END;

但是,我收到了下一个错误:

  

1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以获得正确的语法

     

near&#39;&#39;在第7行

我该如何解决?

问候。

0 个答案:

没有答案