I have the next trigger:
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;
But, i got the next error:
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 7
How can I fix it?
Greetings.
Aucun commentaire:
Enregistrer un commentaire