2014-05-20 100 views
0

我的觸發看起來像這樣:如何觸發刪除記錄

CREATE TRIGGER addATicket AFTER INSERT ON ticket FOR EACH ROW BEGIN 

declare numTicket int(2) default 0; 
select count(*) into numTicket from ticket 
    where (ticket.ticket_id != new.ticket_id) 
    and (ticket.seat_code = new.seat_code); 

if (numTicket > 0) then 
    delete from ticket where ticket_id= new.ticket_id; 
end if;END 

但我的工作臺捕獲了一個錯誤:

Error Code: 1442. Can't update table 'ticket' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

我怎樣才能解決這個問題。請給我一個幫助。

回答