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 v_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 v_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;
解决方案 »
- Diagnostic Files是不是就是我们通常说的日志文件?
- 求高效SQL
- 请问各位如何使processes可上到1000?(重..重..有赏)
- 请教分区索引问题,来者给分!!!!!!!!!!
- sql语句查询问题!感谢各位,非常着急。
- wm_concat invalid identifier
- Oracle8i和9i中PLSQL程序不同运行结果
- (谢谢给位高手)急!急!!如何在sqlplus中快速地向建立好的表中插数据?
- 关于ORACLE系统运行的操作系统选型问题(WINDOWS OR LINUX)
- Oracle中数据横向集成问题,行转列
- 两个select怎么合并?
- 3个以上的表这么拆分成2个表查询?
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;
allr number;
rs types.p_cursor;
v_deptid number;
v_deptname varchar2(100);
begin
query('select deptid,deptname from dept',rs);
loop
fetch deptid,deptname into v_deptid,v_deptname;
exit when rs%notfound;
dbms_output.put_line(deptid||'---'||deptname);
end loop;
end;
allr number;
rs types.p_cursor;
v_deptid number;
v_deptname varchar2(100);
begin
query('select deptid,deptname from dept',rs);
loop
fetch deptid,deptname into v_deptid,v_deptname;
exit when rs%notfound;
dbms_output.put_line(deptid||'---'||deptname);
end loop;
end;