这样就可以.SQL>SET SERVEROUTPUT ON SQL> CREATE OR REPLACE PROCEDURE prc_test IS nCount NUMBER(2); BEGIN dbms_output.put_line('Begin'); SELECT COUNT(*) INTO nCount FROM TAB; dbms_output.put_line(To_char(nCount)); dbms_output.put_line('End.'); END prc_test;
create package test_age as type mycursor is ref cursor; end; / create or replace procedure test(p_rc out test_age.mycursor) as s_emp varchar2(500); begin s_emp:='select * from scott.emp'; open p_rc for s_emp; end test; / declare v_rc test_age.mycursor; begin test(v_rc); loop fetch v_rc into 变量,...; exit when v_rc%notfound; dbms_output.put_line(变量,...); end loop; end; /
SQL>
CREATE OR REPLACE PROCEDURE prc_test
IS
nCount NUMBER(2);
BEGIN
dbms_output.put_line('Begin');
SELECT COUNT(*) INTO nCount FROM TAB;
dbms_output.put_line(To_char(nCount));
dbms_output.put_line('End.');
END prc_test;
不能这样执行,要向显示数据,直接使用select * from scott.emp===========================================================================
(上几楼已经说了。)
http://expert.csdn.net/Expert/topic/2280/2280870.xml?temp=.7991297但在 SQLPLUS 里调用过程来显示数据集就不行.(要直接用 select..from... 的语句才行)
as
type mycursor is ref cursor;
end;
/
create or replace procedure test(p_rc out test_age.mycursor)
as
s_emp varchar2(500);
begin
s_emp:='select * from scott.emp';
open p_rc for s_emp;
end test;
/
declare
v_rc test_age.mycursor;
begin
test(v_rc);
loop
fetch v_rc into 变量,...;
exit when v_rc%notfound;
dbms_output.put_line(变量,...);
end loop;
end;
/