mysql 存储过程游标学习

来源:互联网 发布:linux下的c ide 编辑:程序博客网 时间:2024/05/01 00:26
drop procedure if exists my_procedure;  create procedure my_procedure()BEGINDECLARE done INT DEFAULT 0;    DECLARE _list_name char;    DECLARE _list_id int;    DECLARE _cur CURSOR for select list_id,list_name from aa_list;    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1;    open _cur;    _f_loop:LOOP    FETCH _cur into _list_id,_list_name;    IF done then leave _f_loop;    END IF;    select _list_id as list_id,_list_name as list_name;    END LOOP _f_loop;    close _cur;END;

0 0
原创粉丝点击