我正在构建以下存储过程:
DELIMITER $$
DROP PROCEDURE IF EXISTS update_alert_system$$
CREATE PROCEDURE update_alert_system()
BEGIN
DECLARE done INT;
DECLARE link_id_var INT;
DECLARE curl CURSOR FOR SELECT link_id FROM alert_system;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1;
OPEN curl;
my_loop:LOOP
FETCH curl INTO link_id_var;
call ignore_check(link_id_var);
call snooze_check(link_id_var);
IF done=1 THEN
LEAVE my_loop;
END IF;
END LOOP my_loop
END$$
DELIMITER ;
问题在于我获取数据的方式并将put作为参数放到两个函数中:
call ignore_check(link_id_var);
call snooze_check(link_id_var);
两个函数都应该给我一个数字。这种功能的例子。
DELIMITER $$
DROP FUNCTION IF EXISTS snooze_check $$
CREATE FUNCTION snooze_check(link_id_in INT)
RETURNS INT READS SQL DATA
RETURN (SELECT count(*) as SUCCESSES FROM link_results WHERE link_id=link_id_in AND
Length(anchor_match)>1);
DELIMITER ;
问题是如何从贪睡检查功能返回值并将其设置为存储过程中的变量
答案 0 :(得分:0)
DECLARE Result_ignore_check INT;
SET Result_ignore_check=ignore_check(link_id_var);