mysql的游标写法,mysql数据游标嵌套写法有关问题

如下代码来自  http://www.iteye.com/topic/1026084

1.drop procedure if exists `sp_nested_cursor`;

2.create procedure `sp_nested_cursor`()

3.begin

4.    declare v_uid bigint(22);

5.    declare v_code varchar(100);

6.    declare v_value varchar(100);

7.    declare _done TINYINT(1) default 0;

8.    declare cur_user cursor for select id from `tb_user`;

9.    declare continue handler for not found set _done = 1;

10.

11.    open cur_user;

12.    loop_xxx:loop

13.        fetch cur_user into v_uid;

14.        if _done=1 then

15.            leave loop_xxx;

16.        end if;

17.        begin

18.            declare _inner tinyint(1) default 0;

19.            declare cur_param cursor for select code, value

20.                                         from `tb_user_param`

21.                                         where user_id=v_uid;

22.            declare continue handler for not found set _inner = 1;

23.            open cur_param;

24.            loop_yyy:loop

25.                fetch cur_param into v_code, v_value;

26.                if _inner=1 then

27.                    leave loop_yyy;

28.                end if;

29.                insert into tb_key_value values (v_uid, v_code, v_value);

30.            end loop;

31.            commit;

32.        end;

33.    end loop;

34.end;

在sqlyog enterprise工具中执行

Error Code : 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 'loop_yyy:loop

fetch cur_param into v_code, v_value' at line 1

(0 ms taken)

mysql5.0 不支持这种写法?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值