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;