Quote:
|
Originally Posted by johnwcv
I am executing the statement before fetching the cursor
|
Which one?
Just a suggestion: why don't you use cursor FOR loop? It is easier to maintain as you don't have to declare cursor variable, open a cursor, worry when to exit a loop and close a cursor.
Here's an example of code you currently use:
Code:
declare
cursor c1 is
select dname from dept;
c1_r c1%rowtype;
begin
open c1;
loop
fetch c1 into c1_r;
exit when c1%notfound;
dbms_output.put_line(c1_r.dname);
end loop;
close c1;
end;
Here's the same code, but slightly rewritten:
Code:
begin
for c1_r in (select dname from dept) loop
dbms_output.put_line(c1_r.dname);
end loop;
end;
Which one do you prefer?