日期:2014-05-16  浏览次数:20431 次

一个简单的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存储过程,http://www.aiyiweb.com/oracle-develop/177537.html