我收到“ERROR 1415(0A000):更新包含以下触发器的表时,不允许从触发器返回结果集”,但不明白原因。
CREATE TRIGGER my_trigger AFTER UPDATE ON my_triggering_table
FOR EACH ROW CALL my_procedure();
我离开了触发器不能使用返回结果集的SELECT,但是被调用的过程(及其子进程)只使用CURSOR FOR SELECT和FETCH INTO,据我所知,这是允许的。他们读取但不修改触发表。
任何人都可以解释错误吗? (MySQL 5.5)下面的调用程序。
CREATE PROCEDURE my_procedure()
BEGIN
DECLARE v_mark VARCHAR(4);
DECLARE v_lat, v_lon DOUBLE;
DECLARE eof INT DEFAULT FALSE;
DECLARE my_cursor CURSOR FOR SELECT `mark`, `lat`, `lon` FROM my_triggering_table ORDER BY `order`;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET eof = TRUE;
DELETE FROM my_output_table;
OPEN my_cursor;
loop1: LOOP
FETCH my_cursor INTO v_mark, v_lat, v_lon;
IF eof THEN
LEAVE loop1;
END IF;
CALL my_procedure_2(v_mark, v_lat, v_lon);
END LOOP;
CLOSE my_cursor;
END//
CREATE PROCEDURE my_procedure_2(IN from_mark VARCHAR(4), IN from_lat DOUBLE, IN from_lon DOUBLE)
BEGIN
DECLARE v_mark VARCHAR(4);
DECLARE v_lat, v_lon DOUBLE;
DECLARE eof INT DEFAULT FALSE;
DECLARE my_cursor CURSOR FOR SELECT `mark`, `lat`, `lon` FROM my_triggering_table ORDER BY `order`;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET eof = TRUE;
OPEN my_cursor;
loop1: LOOP
FETCH my_cursor INTO v_mark, v_lat, v_lon;
IF eof THEN
LEAVE loop1;
END IF;
INSERT INTO my_output_table(`from`, `to`, `dist`, `brg`, `lat`, `lon`)
VALUES(from_mark
, v_mark
, IF(from_mark = v_mark, NULL, getDist(from_lat, from_lon, v_lat, v_lon))
, IF(from_mark = v_mark, NULL, getBearing(from_lat, from_lon, v_lat, v_lon))
, coord_dec2ms(from_lat, true)
, coord_dec2ms(from_lon, false)
);
END LOOP;
CLOSE my_cursor;
END//
调用的UDF不引用任何表。