标签:
drop procedure if exists p_hello_world; create procedure p_hello_world() begin declare id integer; declare username varchar(256); declare result varchar(4000) default ‘‘; /* don‘t work */ /*declare cur_user cursor for select id from p_user where id is not null and name is not null order by id;*/ declare cur_user cursor for select t.id, t.name from p_user t where t.id is not null and t.name is not null order by t.id; declare continue handler for SQLSTATE ‘02000‘ set id = null; open cur_user; fetch cur_user into id, username; while (id is not null) do set result = concat(result, ‘id:‘, id, ‘username:‘, username, ‘;‘); fetch cur_user into id, username; end while; close cur_user; select result; end; call p_hello_world();
标签:
原文地址:http://www.cnblogs.com/nick-huang/p/4614282.html