How to close the cursor in oracle: 1. Use close to close, with syntax such as "close mycursor;"; 2. Use a for loop and wait for it to close by itself.
The operating environment of this article: Windows 7 system, Dell G3 computer, Oracle 11g version.
How to close oracle cursor?
1. Use open to open, use close to close
declare cursor mycursor is select * from emp for update; myrecord emp%rowtype; begin open mycursor; loop fetch mycursor into myrecord; exit when mycursor%notfound; if (myrecord.sal=2000) then update emp set sal=2001 where current of mycursor; end if; end loop; close mycursor; commit; end;
2. Use for loop, close it after the loop is over
declare cursor mycursor is select * from emp; begin for i in mycursor loop dbms_output.put_line(i.job); end loop; end;
Related recommendations:oracle database learning tutorial
The above is the detailed content of How to close oracle cursor. For more information, please follow other related articles on the PHP Chinese website!