据用户输入的部门编号实现在PL/SQL中逐行显示emp表中该部门员工的工资级别。工资级别是:当工资为空时,为

空,工资在1000元以下的为‘低’,在1000和3000之间的为‘中’,高于3000元的为‘高’。要求使用参数化游标。

存储过程:
create or replace procedure emp_select(v_no in int,ref_cur out sys_refcursor) AS
BEGIN
open ref_cur for SELECT ename,sal FROM emp where deptno=v_no;
end emp_select;
调用程序:

declare
s_cur SYS_REFCURSOR;
v_no int;
v_name varchar2(10);
v_sal number;
s_sal varchar2(2);
begin
v_no:=&vno;
emp_select(v_no,s_cur);
loop
fetch s_cur into v_name,v_sal;
exit when s_cur%notfound;
case when nvl(v_sal,0)=0 then s_sal:='';
when nvl(v_sal,0)<1000 then s_sal:='低';
when nvl(v_sal,0)<3000 then s_sal:='中';
else s_sal:='高';
end case;
dbms_output.put_line(substr(v_name||' ',1,10)||s_sal);
end loop;
end;
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答