<code>DELIMITER //
create procedure largest_order(out largest_id int)
BEGIN
declare this_id int;
declare this_amount float;
declare l_amount float default 0.0;
declare l_id int;
declare done int default 0;
declare c1 cursor for select orderid,amount from orders;
declare continue handler for SQLSTATE '02000' set done = 1;
open c1;
repeat
fetch c1 into this_id,this_amount;
if not done THEN
if this_amount > l_amount THEN
set l_amount=this_amount;
set l_id=this_id;
end IF;
end if;
until done end repeat;
close c1;
set largest_id = l_id;
END
//
DELIMITER ;</code>代码如上,在navicat报错
<code>DELIMITER //
create procedure largest_order(out largest_id int)
BEGIN
declare this_id int;
declare this_amount float;
declare l_amount float default 0.0;
declare l_id int;
declare done int default 0;
declare c1 cursor for select orderid,amount from orders;
declare continue handler for SQLSTATE '02000' set done = 1;
open c1;
repeat
fetch c1 into this_id,this_amount;
if not done THEN
if this_amount > l_amount THEN
set l_amount=this_amount;
set l_id=this_id;
end IF;
end if;
until done end repeat;
close c1;
set largest_id = l_id;
END
//
DELIMITER ;</code>代码如上,在navicat报错
已解决,是代码有遗漏,末尾缺少斜杠
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号