create or replace
PROCEDURE IFTEST AS
type cursortest is ref cursor;
testcur cursortest;
number2 number(7,2);
BEGIN
open testcur for select sal from emp;
if testcur%rowcount=0 then 为什么长度为零 呢
dbms_output.put_line('not data foun');
else
loop
fetch testcur into number2;
exit when testcur%notfound;
dbms_output.put_line(number2);
end loop;
end if;
close testcur;
END IFTEST;
PROCEDURE IFTEST AS
type cursortest is ref cursor;
testcur cursortest;
number2 number(7,2);
BEGIN
open testcur for select sal from emp;
if testcur%rowcount=0 then 为什么长度为零 呢
dbms_output.put_line('not data foun');
else
loop
fetch testcur into number2;
exit when testcur%notfound;
dbms_output.put_line(number2);
end loop;
end if;
close testcur;
END IFTEST;
testcur%rowcount=0 说明select sal from emp没有取到值
if testcur%rowcount=0 then 为什么长度为零 呢
你还没有提取游标肯定是0咯你这样可以用exception来出来嘛
exception when no_data_found then
dbms_output.put_line('not data foun');
--------你这样修改就行了,前面的if是多余的
create or replace PROCEDURE IFTEST AS
type cursortest is ref cursor;
testcur cursortest;
number2 number(7, 2);
BEGIN
open testcur for
select sal from emp;
loop
fetch testcur
into number2;
exit when testcur%notfound;
dbms_output.put_line(number2);
end loop;
close testcur;
END IFTEST;