这是我的存储过程
CREATE DEFINER=`root`@`localhost` PROCEDURE `update_count`(IN `col_name` VARCHAR(15))
BEGIN
SET @col = CONCAT("pass_",SUBSTRING(col_name,5,3));
SET @row = SUBSTRING(col_name,1,4);
SET @query = CONCAT("UPDATE stk_center_temp SET ",@col," = ",@col,"-1 WHERE center = '",@row,"'");
PREPARE stmt FROM @query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END
这是我的触发器
CREATE TRIGGER `up_count` AFTER INSERT ON `admdamageid`
FOR EACH ROW CALL update_count("KATRSTD")
当我从触发器调用存储过程时,它显示错误
1336 - 存储函数或触发器
中不允许使用动态SQL
当我直接调用我的存储过程时,执行
我最近尝试过这个触发器
CREATE TRIGGER `up_count` AFTER INSERT ON `table1`
FOR EACH ROW BEGIN
DECLARE col_name VARCHAR(10);
DECLARE col VARCHAR(50);
DECLARE row_cl VARCHAR(50);
SET col_name = NEW.id_no;
SET col = CONCAT("pass_",SUBSTRING(col_name,5,3));
SET row_cl = SUBSTRING(col_name,1,4);
UPDATE table2
SET col = col-1 WHERE center = row_cl;
END
但是当我在table1中插入行时出现错误