少年阿宾

那些青春的岁月

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks

1、建立存储过程
create procedure pabin4()
BEGIN
declare status,id int;
declare az,ax varchar(100) default '';
declare mycur cursor for select * from abin5;
declare continue handler for not found set status=1;
open mycur;
 set status=0;
 loopLabel:LOOP

  fetch mycur into id,az;

  if status = 0 then
   if az is not null then
    set ax=CONCAT(az,'mycur');
   else
    set ax=CONCAT('mysql','mycur');
   end if;
   insert into abin5 values (id,ax);
  end if;

  if status = 1 then
   leave loopLabel;
  end if;

  end loop;
close mycur;
END

 

 

 2、测试语句

call pabin4()
 

posted on 2012-09-16 03:16 abin 阅读(464) 评论(0)  编辑  收藏 所属分类: mysql

只有注册用户登录后才能发表评论。


网站导航: