mysql2redis icon indicating copy to clipboard operation
mysql2redis copied to clipboard

when i use redis_command_v2 in cursor, the data count is wrong

Open hezhiqiang opened this issue 5 years ago • 0 comments

BEGIN DECLARE done INT DEFAULT FALSE; DECLARE v_id INT; DECLARE v_ret INT; DECLARE cur CURSOR FOR SELECT u.user_id FROM kid_users u WHERE u.latest_login_time>=DATE(DATE_ADD(NOW(),INTERVAL -1 DAY)) AND EXISTS(SELECT * FROM kid_child_info WHERE user_id=u.user_id AND gender IN(0,1)) ORDER BY u.latest_login_time DESC; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

OPEN cur;
read_loop: LOOP
	FETCH cur INTO v_id;
	IF done THEN
		LEAVE read_loop;
	END IF;

	SET v_ret=redis_command_v2('LPUSH', 'calcReadingRecommendForYou', CONCAT(v_id));
END LOOP;
CLOSE cur;

END

hezhiqiang avatar Dec 26 '19 03:12 hezhiqiang