我有一個名爲daire的表,它具有名爲Kiraci,D_ID,Sahip的列。 D_ID是PK列。我想要的是當我改變Kiraci值時,我想觸發刪除一行或插入一個新行到另一個表。我試圖創建一個像書面底部的觸發器:創建觸發器語法錯誤
CREATE TRIGGER daireBosalt AFTER UPDATE ON daire
FOR EACH ROW
BEGIN
IF NEW.Kiraci IS NULL THEN
DELETE FROM kontrat WHERE kontrat.D_ID = NEW.D_id;
ELSEIF NEW.Kiraci IS NOT NULL THEN
INSERT INTO kontrat (D_ID, BAy, BGun, BYil, Tutar, Sahip, Sure, Depo, Komisyon) VALUES (NEW.D_id, '01', '01','2014','100', NEW.Sahip,'1','100','100')
END IF;
END;
當我嘗試創建此腳本,它不斷給我語法錯誤。
你改變分隔符?即'DELIMITER \\'在語句前面,用'\\'結束創建,並用'DELIMITER'重置分隔符;' – VMai
您在INSERT後缺少分號。 – VMai
omg yes right thnx :) – user3809204