本文整理自网络,侵删。
--sys_refcursor 和 cursor 优缺点比较
优点比较
优点一:
sys_refcursor,可以在存储过程中作为参数返回一个table格式的结构集(我把他认为是table类型,容易理解,其实是一个游标集), cursor 只能用在存储过程,函数,包等的实现体中,不能做参数使用。
优点二:
sys_refcursor 这东西可以使用在包中做参数,进行数据库面向对象开放。哈哈。我喜欢。cursor就不能。
create or replace procedure p_test(p_cur out sys_refcursor) as begin open p_cur for select * from emp; end p_test; declare p_cur sys_refcursor; i emp%rowtype; begin p_test(p_cur); loop fetch p_cur into i; exit when p_cur%notfound; DBMS_OUTPUT.PUT_LINE('---'||i.ename||'---'||i.empno); end loop; close p_cur; end;
补充:Oracle存储过程返回select * from table结果
相关阅读 >>
dba 在linux下安装oracle database11g数据库图文教程
更多相关阅读请进入《oracle》频道 >>

数据库系统概念 第6版
本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。