当前位置:首页 > 开发 > 数据库 > 正文

cursor variable 实例

发表于: 2013-12-20   作者:ctrain   来源:转载   浏览:
摘要: 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%t
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;

cursor variable 实例

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号