Code
CREATE OR REPLACE FUNCTION GetRoleUser
(
Proleid admin_list.roles_id %TYPE
)
RETURN varchar2 --函数返回类型
IS
Userlists varchar2(4000);
cursor mycur is
select admin_list.admin_name into Userlists from admin_list where admin_list.roles_id=Proleid;
ccrec mycur%rowtype;
begin
begin
--打开游标
open mycur;
--loop循环
loop
--提取一行数据到ccrec中
fetch mycur into ccrec;
--判断是否提取到值,没取到值就退出
--取到值cc%notfound 是false
--取不到值cc%notfound 是true
exit when mycur%notfound;
Userlists:=Userlists||ccrec.admin_name||',';
end loop;
--关闭游标
close mycur;
end;
return Userlists;
END GetRoleUser;
CREATE OR REPLACE FUNCTION GetRoleUser
(
Proleid admin_list.roles_id %TYPE
)
RETURN varchar2 --函数返回类型
IS
Userlists varchar2(4000);
cursor mycur is
select admin_list.admin_name into Userlists from admin_list where admin_list.roles_id=Proleid;
ccrec mycur%rowtype;
begin
begin
--打开游标
open mycur;
--loop循环
loop
--提取一行数据到ccrec中
fetch mycur into ccrec;
--判断是否提取到值,没取到值就退出
--取到值cc%notfound 是false
--取不到值cc%notfound 是true
exit when mycur%notfound;
Userlists:=Userlists||ccrec.admin_name||',';
end loop;
--关闭游标
close mycur;
end;
return Userlists;
END GetRoleUser;