当前位置: 代码迷 >> Ruby/Rails >> Mysql之存储过程异常:ERROR 1337 (42000): Variable or condition declaration after cursor
  详细解决方案

Mysql之存储过程异常:ERROR 1337 (42000): Variable or condition declaration after cursor

热度:599   发布时间:2016-04-29 02:06:45.0
Mysql之存储过程错误:ERROR 1337 (42000): Variable or condition declaration after cursor

错误信息:

ERROR 1337 (42000): Variable or condition declaration after cursor or handle

错误原因:

所有的声明变量应该放到游标后

解决:

    DECLARE name VARCHAR(64);     -- 遍历数据结束标志    DECLARE done INT DEFAULT FALSE;    DECLARE tables_cur CURSOR FOR select 。。。;    -- 将结束标志绑定到游标    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

里面有两个概念:

cursor和handler

  相关解决方案