我尝试创建一个触发器但是在执行SQL之后我得到了这个错误;
这是我的触发器:
CREATE TRIGGER hesap
AFTER INSERT ON uber
DECLARE temp INT;
BEGIN IF uber.il='ANKARA' THEN
temp=5+(uber.mesafe*0.5);
ELSEIF uber.il='ISTANBUL' THEN
temp=10+(uber.mesafe*0.5);
ELSEIF uber.il='IZMIR' THEN
temp=3+(uber.mesafe*0.5);
END IF;
INSERT INTO fatura VALUES(uber.uid,temp)
END;
答案 0 :(得分:0)
我确定了一些语法错误,请查看以下代码:
delimiter $$
CREATE TRIGGER hesap
AFTER INSERT ON uber FOR EACH ROW
BEGIN
DECLARE temp integer;
IF new.il = 'ANKARA' THEN
temp= 5+(uber.mesafe*0.5);
ELSEIF new.il='ISTANBUL' THEN
temp=10+(uber.mesafe*0.5);
ELSEIF new.il='IZMIR' THEN
temp=3+(uber.mesafe*0.5);
END IF;
INSERT INTO fatura VALUES(new.uid,temp);
END
delimiter ;