cainiaodebuguilu
cainiaodebuguilu
采纳率12.5%
2017-05-08 08:39 阅读 744

mysq 游标哪里错了?感觉没错

delimiter $
create function youbiao()
begin

declare a varchar(20);
declare flag int default false;
declare d int;
# 声明一个游标

declare mycursor cursor for select age,dogname from dog;# 游标一定要在变量后申明

声明一个游标的终止条件

declare continue handler for not found set flag=true; # set flag是一个变量用作判断
open mycursor; #打开mycursor这个游标
while !flag do
fetch mycursor into d,a ;
select d,a;
end while;
close mycursor;
end $
delimiter ;

     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 'begin 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • cainiaodebuguilu cainiaodebuguilu 2017-05-08 08:41

    delimiter $
    create function youbiao()
    begin
    declare a varchar(20);
    declare flag int default false;
    declare d int;
    # 声明一个游标
    declare mycursor cursor for select age,dogname from dog;# 游标一定要在变量后申明

    声明一个游标的终止条件

    declare continue handler for not found set flag=true; # set flag是一个变量用作判断
    open mycursor; #打开mycursor这个游标
    while !flag do
    fetch mycursor into d,a ;
    select d,a;
    end while;
    close mycursor;
    end $
    delimiter ;

    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 'begin

    点赞 评论 复制链接分享
  • cainiaodebuguilu cainiaodebuguilu 2017-05-08 09:05

    delimiter $
    create procedure youbiao()
    begin
    declare a varchar(20);
    declare flag int default false;
    declare d int;
    # 声明一个游标
    declare mycursor cursor for select age,dogname from dog;# 游标一定要在变量后申明

    声明一个游标的终止条件

    declare continue handler for not found set flag = true; # set flag是一个变量用作判断
    open mycursor; #打开mycursor这个游标
    while flag do
    fetch mycursor into d,a ;
    select d,a;
    end while;
    close mycursor;
    end $
    delimiter ;

    还是不行
    
    点赞 评论 复制链接分享

相关推荐