declare
cursor c_s is select * from test1;
re test1%rowtype;
begin
open c_s;
loop
fetch c_s into re;
dbms_output.put_line(re.price);
exit when c_s%notfound;
end loop;
dbms_output.put_line(c_s%rowcount);
close c_s;
end;这样一段程序,结果:
37
45.6
45.6
2test1表中只有两条记录,对应的price字段的值是,37,45.6
但是游标去弄出了三个记录,但是rowcount显示的仍然是2,是咋回事啊?
cursor c_s is select * from test1;
re test1%rowtype;
begin
open c_s;
loop
fetch c_s into re;
dbms_output.put_line(re.price);
exit when c_s%notfound;
end loop;
dbms_output.put_line(c_s%rowcount);
close c_s;
end;这样一段程序,结果:
37
45.6
45.6
2test1表中只有两条记录,对应的price字段的值是,37,45.6
但是游标去弄出了三个记录,但是rowcount显示的仍然是2,是咋回事啊?
cursor c_s is select * from test1;
re test1%rowtype;
begin
open c_s;
loop
fetch c_s into re;
exit when c_s%notfound;
dbms_output.put_line(re.price);
end loop;
dbms_output.put_line(c_s%rowcount);
close c_s;
end;
按楼上的改下顺序就好