当前位置:Gxlcms > 数据库问题 > MySQL PLSQL Demo - 003.静态游标

MySQL PLSQL Demo - 003.静态游标

时间:2021-07-01 10:21:17 帮助过:3人阅读

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();

 

MySQL PLSQL Demo - 003.静态游标

标签:

人气教程排行