Home > Database > Oracle > How to close oracle cursor

How to close oracle cursor

藏色散人
Release: 2021-12-16 14:37:01
Original
4844 people have browsed it

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;
Copy after login

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;
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template