我面临在MySQL中触发器中传递动态表名的问题。
这是我的
DELIMITER $$
DROP TRIGGER `demo_database`.`my_trigger`$$
create trigger `demo_database`.`my_trigger` AFTER INSERT on `demo_database`.`tablename`
for each row BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE a varchar(255);
DECLARE cur1 CURSOR FOR SELECT TABLE_NAME FROM information_schema.tables WHERE table_name LIKE '%_pbxware_minilcr' limit 1,10000000000;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN cur1;
read_loop: LOOP
FETCH cur1 INTO a;
IF done THEN
LEAVE read_loop;
END IF;
INSERT INTO a (`server`,`tbd`,`lcr`,`route`,`destination`,`trunk`,`ext`) values (3,NULL,'primary','11','1','78',NULL);
END LOOP;
CLOSE cur1;
END;
$$
DELIMITER ;
在上面的cur1 Cursor中,我正在获取表名,我想在那个(获取的)表中插入值..