oracle sys_refcursor用法和ref cursor區別


--創建過程,參數為sys_refcursor,為out型
create or replace procedure aabbsys_refcursor(o out sys_refcursor) is
begin
  open o for select * from basplumain;
end;
---
--測試過程,使用aabbsys_refcursor傳出的值
create or replace procedure aabb_test_sys_refcursor(return out int)is
type t_basplumain is table of basplumain%rowtype;
t_plu t_basplumain;
v sys_refcursor;
begin
  aabbsys_refcursor(v);
  fetch v bulk collect into t_plu;
  for i in 1..t_plu.count loop
    dbms_output.put_line(t_plu(i).pluname);
  end loop;
end;
---
--sqlplus測試腳本
--set serveroutput on
declare
v_return int default 0;
begin
  aabb_test_sys_refcursor(v_return);
end;

區別https://blog.csdn.net/gyflyx/article/details/6889028

https://blog.csdn.net/wulex/article/details/79977195

type type_refcur is ref cursor;
cur_refcur type_refcur; ---自定義的ref cursor
cur_sysref   sys_refcursor; --- 使用系統預定義的sys_refcursor

v_sql varchar(4000) :動態拼接一個查詢sql: ;
開啟游標: open cur_xxx  for v_sql 時, cur_sysref 即 sys_refcursor可以, 而cur_refcur  即 ref cursor 不可以;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM