我在Mysql中有一个Session表。我试图使用mysql存储过程游标从该表中获取结果,但每次它返回null。这是我试图获取结果集的代码。
CREATE PROCEDURE `getSession`()
BEGIN
DECLARE done INTEGER DEFAULT 0;
DECLARE site_id INTEGER(20);
DECLARE sess CURSOR FOR
SELECT siteid FROM Sessions WHERE cstate=1;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN sess;
get_session: LOOP
FETCH sess INTO site_id;
IF done = 1 THEN
LEAVE get_session;
END IF;
SELECT site_id;
END LOOP get_session;
CLOSE sess;
END