cursor variable 实例

create or replace procedure proc_test01
as 
type emp_row is record(
empno emp.empno%type,
ename emp.ename%type,
job emp.job%type,
mgr emp.mgr%type,
hiberdate emp.hiredate%type,
sal emp.sal%type,
comm emp.comm%type,
deptno emp.deptno%type
);
tmp0 emp_row;
type cur_type is ref cursor;
cur0 cur_type;
BEGIN
     open cur0 for select * from emp where rownum < 10;
     loop 
     fetch cur0 into tmp0;
     dbms_output.put_line(tmp0.job||',姓名:'||tmp0.ename||',工资:'||tmp0.sal);
     exit when cur0%notfound;
     end loop;
     close cur0;
END;

在cmd命令窗口中执行:
SQL> set serveroutput on;
SQL> exec proc_test01;

你可能感兴趣的:(variable)