plsql嵌套循环怎么写
1个回答
展开全部
declare
i number :=1;
t_emp1 number;
t_emp2 number;
strsql varchar2(4000); --新增的
tes_t2 sys_refcursor;
cursor tes_t1 is select groupid from SYSTEMGROUPMEMBERSHIP
group by groupid having groupid not in (1,2);
begin
open tes_t1;
loop
fetch tes_t1 into t_emp1;
exit when tes_t1%notfound;
dbms_output.put_line(i||'aaaaaa'||t_emp1);
i:=i+1;
strsql := 'select userid from SYSTEMGROUPMEMBERSHIP where groupid='''||t_emp1||'''';
open tes_t2 for strsql;
loop
fetch tes_t2 into t_emp2;
exit when tes_t2%notfound;
dbms_output.put_line(t_emp1);
end loop;
close tes_t2;
commit;
end loop;
close tes_t1;
commit;
end;
i number :=1;
t_emp1 number;
t_emp2 number;
strsql varchar2(4000); --新增的
tes_t2 sys_refcursor;
cursor tes_t1 is select groupid from SYSTEMGROUPMEMBERSHIP
group by groupid having groupid not in (1,2);
begin
open tes_t1;
loop
fetch tes_t1 into t_emp1;
exit when tes_t1%notfound;
dbms_output.put_line(i||'aaaaaa'||t_emp1);
i:=i+1;
strsql := 'select userid from SYSTEMGROUPMEMBERSHIP where groupid='''||t_emp1||'''';
open tes_t2 for strsql;
loop
fetch tes_t2 into t_emp2;
exit when tes_t2%notfound;
dbms_output.put_line(t_emp1);
end loop;
close tes_t2;
commit;
end loop;
close tes_t1;
commit;
end;
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询