*DELIMITER //
create procedure test(OUT l_out INT)
begin
DECLARE done INT DEFAULT FALSE;
declare l_sno INT default 0;
declare a INT default 0;
declare b INT default 0;
declare cur_1 cursor for select sno,interest from temp t where x_coord between 55 and 60 for update of interest;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
open cur_1;
read_loop: LOOP
fetch cur_1 into a,b;
if done then
Leave read_loop;
end if;
set l_sno=l_sno+1;
update temp set interest =1 where CURRENT OF cur_1;
END LOOP;
close cur_1;
set l_out=l_sno;
end //
;*错误:
1064 -您的SQL语法有一个错误;检查与您的MySQL服务器版本对应的手册,以获得在感兴趣的地方使用的正确语法;在第7行中声明“NOT = TRUE;open cur_1;”的继续处理程序
1064 -您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以获得在第16行()附近使用的正确语法;结束循环;关闭cur_1;设置l_out=l_sno;end‘。
发布于 2012-05-11 16:37:40
在我看来,你来自一种不同类型的SQL,比如DB2 --就是这些工作。
来自http://dev.mysql.com/doc/refman/5.0/en/cursor-restrictions.html的报价
游标是只读的;不能使用游标更新行。
因为不支持可更新的游标,所以在未实现当前OF的地方更新和删除。
因此,我想您不能这样做,您必须指定一个类似mysql的where子句。
https://stackoverflow.com/questions/10555219
复制相似问题