呼叫程序终止连接

时间:2018-07-17 05:13:18

标签: mysql procedure

我有一些用于mysql的代码,这段代码有什么问题?有人可以和我分享如何做吗?

CREATE PROCEDURE `KILL_PROCESS`(
IN `VBOOL` CHAR(1))
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
proc_label:BEGIN
DECLARE ID INTEGER;
DECLARE done INT DEFAULT 0;
DECLARE cur1 CURSOR FOR 
SELECT id FROM information_schema.PROCESSLIST WHERE command='sleep' ;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
IF VBOOL<>'1' THEN 
    LEAVE proc_label;
END IF;
OPEN cur1;
    REPEAT
        FETCH cur1 INTO ID;
        IF NOT done THEN 
            KILL id;
        END IF;
        UNTIL done
    END REPEAT;
CLOSE cur1;


END

我尝试调用此过程

 CALL KILL_PROCESS(1)

那个错误

enter image description here

英语很糟糕

0 个答案:

没有答案