游标的使用 Oracle 中Cursor 是非常有用的,用于遍历临时表中的查询结果。
将emp表中"ename"和"deptno"查询出,存放到cusor_01游标中。for循环迭代游标集合。每次迭代的结果存到‘c’中。
create or replace procedure test01 is cursor cusor_1 is select ename,deptno from emp ;--定义一个游标 begin for c in cusor_1 loop dbms_output.put_line('员工姓名:'||c.ename||' 部门编号:'||c.deptno); end loop; end test01;