源代码如下:
declare
type myrefcursor is ref cursor;
var_refcursor myrefcursor;
sqlstr varchar2(100);
begin
sqlstr:='select * from s_emp where id>:b0';
open var_refcursor for sqlstr using 2;
for var_emp in var_refcursor loop
dbms_output.put_line(var_emp.id||':'||var_emp.name);
end loop;
close var_refcursor;
end;
为什么编译老是不通过,提示如下---
错误报告:
ORA-06550: 第 8 行, 第 16 列:
PLS-00221: 'VAR_REFCURSOR' 不是过程或尚未定义
ORA-06550: 第 8 行, 第 1 列:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
眼睛看花了,都没看出错在哪,难道for循环中不能使用参考游标变量???本人小白,求大神指点。。。
------解决思路----------------------
open 过后不能再for loop了,你可以用loop ...exit when ...的方式来执行