2
我試圖運行一個存儲過程,將數據插入到表中。在該表中,則添加將更新序列表後觸發器(有在MySQL數據庫沒有序列)在mysql中的存儲過程和觸發器
這是我的存儲過程:
DELIMITER $$
CREATE DEFINER=`dbName`@`%` PROCEDURE `insertGuide`(m_name varchar(45) ,m_last varchar(45) ,addres varchar(45) ,mphone int)
BEGIN
INSERT INTO `guides` (`id`, `name`, `lastName`, `address`, `phone`)
select max(id)+1, m_name, m_last, addres, mphone
from seq;
END
這是我的觸發器:
USE `dbName`;
DELIMITER $$
CREATE DEFINER=`dbName`@`%` TRIGGER
guidesUpdate
AFTER INSERT ON
guides
FOR EACH ROW
BEGIN
INSERT INTO seq VALUES();
END
當我運行
call insertGuide('a' ,'aa' ,'aaa' ,'12333')
它返回一個錯誤:
Error Code: 1442. Can't update table 'seq' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
我可以做些什麼嗎?