我使用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

 

相关文章:

  • 2021-11-14
  • 2021-11-01
  • 2022-12-23
  • 2021-08-09
  • 2021-10-11
  • 2022-01-13
  • 2021-08-20
  • 2021-06-26
猜你喜欢
  • 2022-12-23
  • 2021-11-28
  • 2022-01-10
  • 2022-12-23
  • 2022-01-15
  • 2021-07-21
  • 2021-12-26
相关资源
相似解决方案