MYSQL- 游标

  我使用Navicate for MySql 直接找一坨代码,然后改改,然后运行,最后是运行不了的。

  要将游标写在存储过程里面,调用存储过程运行,不然老是报错

  代码示例:

CREATE PROCEDURE h_useCursor()
BEGIN

  declare e_name char(50);
-- 遍历数据结束标志
declare done int default false; declare cure CURSOR FOR SELECT id from shangdian;
--将结束标志绑定到游标
declare continue handler for not found set done=true; open cure; read_loop:LOOP FETCH cure into e_name; IF done=true THEN LEAVE read_loop; END IF; --测试输出 select e_name;end loop; close cure; END
原文地址:https://www.cnblogs.com/cxeye/p/4380292.html