mysql双重循环示例
时间:2021-07-01 10:21:17
帮助过:27人阅读
DECLARE menu_id
VARCHAR(
36);
DECLARE done
INT DEFAULT FALSE;
DECLARE cursor_rule
CURSOR FOR SELECT s.id
FROM d_menu_type s
;
DECLARE CONTINUE HANDLER
FOR NOT FOUND
SET done
= TRUE;
OPEN cursor_rule;
l : LOOP
FETCH cursor_rule
INTO menu_id;
IF done
THEN
LEAVE l;
END IF;
BEGIN
DECLARE property_id
VARCHAR(
36);
DECLARE done2
INT DEFAULT FALSE;
DECLARE cursor_rule2
CURSOR FOR SELECT property_id
FROM d_menu_property l
WHERE l.menu_id
=menu_id;
DECLARE CONTINUE HANDLER
FOR NOT FOUND
SET done2
= TRUE;
OPEN cursor_rule2;
l2 : LOOP
FETCH cursor_rule2
INTO property_id;
IF done2
THEN
LEAVE l2;
END IF;
END LOOP;
CLOSE cursor_rule2;
END;
END LOOP;
CLOSE cursor_rule;
END
mysql双重循环示例
标签:efault sql arch false type continue div span class