设计程序显示公司的组织机构图,即员工之间的领导和被领导关系
+KING
+JONES
+SCOTT
+ADAMS
+FORD
+SMITH
+BLAKE
+ALLEN
+WARD
+MARTIN
+TURNER
+JAMES
+CLARK
+MILLER
declare
cursor youbiao1 is select deptno from emp group by deptno order by deptno;
cursor youbiao2(no number) is select mgr from emp where deptno=no;
cursor youbiao3(i number) is select ename,mgr from emp where mgr=i;
name emp.ename%type;
id emp.mgr%type;
yb1 youbiao1%rowtype;
yb2 youbiao2%rowtype;
yb3 youbiao3%rowtype;
begin
select ename,mgr into name,id from emp where mgr is null;
dbms_output.put_line(name);
for yb1 in youbiao1 loop
for yb2 in youbiao2(yb1.deptno) loop
for yb3 in youbiao3(yb2.mgr) loop
if yb3.mgr=id then
dbms_output.put_line('++'||yb3.ename);
exit;
else
dbms_output.put_line(yb3.ename);
exit;
end if;
end loop;
end loop;
end loop;
end;
/
我希望把变量idd每次用完后就清空,小弟刚学,请各位高人指点