Home » SQL & PL/SQL » SQL & PL/SQL » open / close cursor (10g)
open / close cursor [message #415217] Sun, 26 July 2009 07:59 Go to next message
ajitpal.s
Messages: 204
Registered: November 2006
Senior Member
Hi,
I wish to understand the purpose of opening / closing cursor.

I wrote a simple plsql procedure which processes data correctly, it works fine without open/close cursor.

SQL> set serveroutput on
SQL>  create or replace procedure dede is
  2   cursor t is select * from departments;
  3   begin
  4  if t%isopen then
  5        dbms_output.put_line('cursor is open');
  6      else
  7        dbms_output.put_line('cursor is not open');
  8      end if;
  9    for j in t 
 10   loop
 11     if j.manager_id is null 
 12       then
 13    update departments set flag = 'Y' where department_id = j.department_id;
 14   ELSE
 15   update departments set flag = 'N' where department_id = j.department_id;
 16   end if; end loop;
 17  commit;
 18  end;
 19  /

Procedure created.

SQL> exec dede;
cursor is not open

PL/SQL procedure successfully completed.
Re: open / close cursor [message #415218 is a reply to message #415217] Sun, 26 July 2009 08:25 Go to previous messageGo to next message
ajitpal.s
Messages: 204
Registered: November 2006
Senior Member
Oh yeah, the article below explains it open/closes cursor automatically
http://www.exforsys.com/tutorials/oracle-9i/oracle-cursors.html

[Updated on: Sun, 26 July 2009 08:36]

Report message to a moderator

Re: open / close cursor [message #415220 is a reply to message #415218] Sun, 26 July 2009 09:07 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I recommend you to read:
PL/SQL User's Guide and Reference
Application Developer's Guide - Fundamentals

Regards
Michel

[Updated on: Sun, 26 July 2009 09:07]

Report message to a moderator

Re: open / close cursor [message #415257 is a reply to message #415220] Sun, 26 July 2009 21:03 Go to previous message
ajitpal.s
Messages: 204
Registered: November 2006
Senior Member
cool michel, i will start reading it
Previous Topic: query using ref cursor
Next Topic: Can You Explain This SQL Query - Inline View Included
Goto Forum:
  


Current Time: Mon Dec 05 21:25:23 CST 2016

Total time taken to generate the page: 0.26616 seconds