2016-02-18 43 views
0

我有兩個表股票的細節和購買。在創建觸發器時在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 3 " 

聽到的是我的代碼

create TRIGGER afterinsert after insert on purchase for each row 
BEGIN 
set @qnty=(select quantity from stock_detail where brand_name = new.brand); 
if(@qnty>=1) then 
update stock_detail set [email protected]+new.quanty; 
end if; 
END; 
+0

我沒有看到觸發器的任何分隔符。如果你在mysql CLI上編寫觸發器,那麼你需要設置除''以外的分隔符,所以你需要''在頂部分隔符//',最後'END; //分隔符;' –

+0

你是否正在設置創建觸發器之前的分隔符? http://dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html – Sandy

+0

http://stackoverflow.com/a/23160180/767881 –

回答