知乎專欄 | 多維度架構 |
觸發器中不允許返回結果集,解決方法是頂一個變數,然後將返回值返回給變數。
DROP TRIGGER IF EXISTS `test`.`demo_AFTER_INSERT`; DELIMITER $$ USE `test`$$ CREATE DEFINER=`root`@`%` TRIGGER `test`.`demo_AFTER_INSERT` AFTER INSERT ON `demo` FOR EACH ROW BEGIN set @rev = ""; SELECT OUT2FILE('/tmp/demo.log', CONCAT_WS(',', NEW.id, NEW.name, NEW.sex, NEW.address)) INTO @rev; END$$ DELIMITER ;