declare type emp_cursor_type is ref cursor; emp_cursor1 emp_cursor_type; emp_cursor2 emp_cursor_type; emp_sal emp.sal%type; emp_deptno emp.deptno%type; begin open emp_cursor1 for select distinct deptno from emp; LOOP fetch emp_cursor1 into emp_deptno; exit when emp_cursor1%notfound; open emp_cursor2 for select max(sal)-min(sal) sal from emp where deptno=emp_deptno group by deptno;
fetch emp_cursor2 into emp_sal; if emp_sal>=2000 then dbms_output.put_line('部门'||emp_deptno||':'||'H'); elsif 1000<=emp_sal and emp_sal<2000 then dbms_output.put_line('部门'||emp_deptno||':'||'M'); else dbms_output.put_line('部门'||emp_deptno||':'||'L'); end if;
end loop; end; 第2问没明白什么意思;标记又不在表里面,只是输出而已。而且上一个标记是部门的工资差,和个人工资又没必然联系。