一个简单的oracle存储过程(嵌套游标)的例子

create or replace procedure proc(myDeptno in number)
 is
 myEname varchar2(10);
 mySal number(7,2);
 myHiredate date;
 myGrade number(2);
 cursor mycursor
 is
select ename,sal,hiredate,salgrade.grade into myEname,mySal,myHiredate,myGrade from emp join salgrade on sal between salgrade.losal and salgrade.hisal where emp.deptno=myDeptno;
begin
open mycursor;
 loop
 fetch mycursor into myEname,mySal,myHiredate,myGrade;
 exit when mycursor%notfound;
 dbms_output.put_line('员工姓名'||myEname||' '||'员工工资'||mySal||' '||'入职时间'||myHiredate||' '||'工资等级'||myGrade);
  end loop;
close mycursor;
 end;
/

你可能感兴趣的:(oracle)