我不太明白你这里的解析是什么意思,以下是使用存储过程返回结果集以及在通过匿名程序调用的例子,供你参考: create or replace procedure sql_test (pi1 number,po out sys_refcursor) is begin if pi1=1 then open po for 'select 1 id,''Tom'' nm from dual union all select 2 id,''Jack'' from dual'; else open po for 'select 3 id,''Lucy'' nm from dual union all select 4 id,''Lily'' from dual'; end if; end ; /set serveroutput on; declare cur1 SYS_REFCURSOR; id number; nm varchar2(100); begin sql_test(1,cur1); loop fetch cur1 into id,nm; exit when cur1%notfound; dbms_output.put_line(id||':'||nm); end loop; close cur1; end; /
create or replace procedure sql_test (pi1 number,po out sys_refcursor) is
begin
if pi1=1 then
open po for 'select 1 id,''Tom'' nm from dual union all select 2 id,''Jack'' from dual';
else
open po for 'select 3 id,''Lucy'' nm from dual union all select 4 id,''Lily'' from dual';
end if;
end ;
/set serveroutput on;
declare
cur1 SYS_REFCURSOR;
id number;
nm varchar2(100);
begin
sql_test(1,cur1);
loop
fetch cur1 into id,nm;
exit when cur1%notfound;
dbms_output.put_line(id||':'||nm);
end loop;
close cur1;
end;
/