1

我正在构建以下存储过程:

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 ;

问题是如何从贪睡检查函数返回值并将其设置为存储过程中的变量

4

1 回答 1

0
DECLARE Result_ignore_check INT;
SET Result_ignore_check=ignore_check(link_id_var);
于 2012-09-20T08:35:48.977 回答