Home > database >  Oracle cursor loop
Oracle cursor loop

Time:09-27

Declare
Cursor c is the select * from the user; - define the cursor
V_var c % rowtype; - variable
The begin
The open c; - open the cursor
Loop, loop cycle
The fetch c into v_var; - automatic extraction of pointer in a line of data to the v_var moved to the next line
exit the when c % notfound; - line 8: whether the cursor pointer to extract data
dbms_output. Put_line (v_var. Name); - line 9: output
End loop; - the end of the cycle
The close c; - close the cursor
The end;
Q: line 8 and line 9 can write normal print out all the data
If the line 8 and line 9 and exchange why can't appear the last line of data printed???????

CodePudding user response:

Understand the % notfound

CodePudding user response:

Exit the when c % notfound; - line 8: whether the cursor pointer to extract data

If you cannot find data blocks and then exit the LOOP below

CodePudding user response:

Exit the when c % notfound, understanding
  • Related