create or replace package types
as
type p_cursor is ref cursor;---类型
end; create or replace procedure query(v_sql varchar2,records out types.p_cursor)
as
begin
open records for all_sql;
end;
--通过程序块调用存储过程进行展现,但报"rs不是过程或尚未定义"错误
declare
allr number;
rs types.p_cursor;
begin
query('select * from dept',rs);
--如果只执行下面的输出,是正确的
dbms_output.put_line(rs%rowcount);
----执行下面报"rs不是过程或尚未定义"错误,为什么
for i in rs
loop
dbms_output.put_line(i.deptid||'---'||i.deptname);
end loop;
end;
as
type p_cursor is ref cursor;---类型
end; create or replace procedure query(v_sql varchar2,records out types.p_cursor)
as
begin
open records for all_sql;
end;
--通过程序块调用存储过程进行展现,但报"rs不是过程或尚未定义"错误
declare
allr number;
rs types.p_cursor;
begin
query('select * from dept',rs);
--如果只执行下面的输出,是正确的
dbms_output.put_line(rs%rowcount);
----执行下面报"rs不是过程或尚未定义"错误,为什么
for i in rs
loop
dbms_output.put_line(i.deptid||'---'||i.deptname);
end loop;
end;
as
begin
open records for all_sql;
end; 看看就知道错在哪 了
create or replace package types
as
type p_cursor is ref cursor;---类型
end; create or replace procedure query(v_sql varchar2,records out types.p_cursor)
as
begin
open records for all_sql;
end;
--通过程序块调用存储过程进行展现,但报"rs不是过程或尚未定义"错误
declare
allr number;
rs types.p_cursor;
begin
query('select * from dept',rs);
--如果只执行下面的输出,是正确的
dbms_output.put_line(rs%rowcount);
----执行下面报"rs不是过程或尚未定义"错误,为什么
for i in rs
loop
dbms_output.put_line(i.deptid||'---'||i.deptname);
end loop;
end;
allr number;
rs types.p_cursor;
cid number;
cname varchar2(20);
begin
query('select custid,custname from cust',rs);
loop
fetch rs into cid,cname ;
exit when rs%notfound;
dbms_output.put_line(cid);
dbms_output.put_line(cname);
end loop;
close rs;
end;