Home  >  Article  >  Database  >  How to close oracle cursor

How to close oracle cursor

藏色散人
藏色散人Original
2021-12-16 14:37:014677browse

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.

How to close oracle cursor

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:what is oracle systemNext article:what is oracle system