无详细内容 游标 mysql mysqlmysql delimiter $$mysql create procedure myproc() - begin - declare l_sale_id int; - declare l_last_sale int default 0; - - declare sale_csr cursor for - select id - from employee; - - declare continue handler for
游标 mysql mysql>mysql> delimiter $$mysql> create procedure myproc() -> begin -> declare l_sale_id int; -> declare l_last_sale int default 0; -> -> declare sale_csr cursor for -> select id -> from employee; -> -> declare continue handler for not found set l_last_sale=1; -> -> open sale_csr; -> sale_loop:loop -> fetch sale_csr into l_sale_id; -> if l_last_sale then -> leave sale_loop; -> end if; -> select l_sale_id; -> end loop sale_loop; -> close sale_csr; -> -> end$$query ok, 0 rows affected (0.00 sec)mysql>mysql> delimiter ;mysql> call myproc();