17,086
社区成员
发帖
与我相关
我的任务
分享
create or replace procedure pro_test (ResultSet out sys_refcursor) is
begin
open po for 'select 1 id,''Tom'' nm from dual union all select 2 id,''Jack'' from dual';
end ;
create or replace procedure pro_test (ResultSet out sys_refcursor) is
begin
open ResultSet for 'select 1 id,''Tom'' nm from dual union all select 2 id,''Jack'' from dual';
end ;
必须执行一遍才能获取结果集吗?能不能获取结果集中包含的字段名称以及字段类型?实际情况中存储过程参数可能比较多并且逻辑复杂,模拟不出合法的参数值declare
v_rent_rows1 SYS_REFCURSOR;
v_rent_row table%rowType;
begin
pro_test(v_rent_rows1);
loop
fetch v_rent_rows1 into v_rent_row;
exit when v_rent_rows1%NOTFOUND;
Dbms_output.put_line(v_rent_row.col1||' '||v_rent_row.col2);
end loop;
close v_rent_rows1;
end;