gpt4 book ai didi

当前的 MYSQL 游标

转载 作者:行者123 更新时间:2023-11-29 05:35:58 28 4
gpt4 key购买 nike

*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 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'of interest; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; open cur_1;' at line 7

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OF cur_1; END LOOP; close cur_1; set l_out=l_sno; end' at line 16

最佳答案

在我看来,您好像来自不同类型的 SQL,例如 DB2 —— 那些有用的东西。

引自 http://dev.mysql.com/doc/refman/5.0/en/cursor-restrictions.html

Cursors are read only; you cannot use a cursor to update rows.

UPDATE WHERE CURRENT OF and DELETE WHERE CURRENT OF are not implemented, because updatable cursors are not supported.

所以我猜你不能那样做,你必须指定一个类似于 mysql 的 where 子句。

关于当前的 MYSQL 游标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10555219/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com