Home » SQL & PL/SQL » SQL & PL/SQL » help me on CURSOR
help me on CURSOR [message #429612] Wed, 04 November 2009 14:19 Go to next message
nchaitu
Messages: 2
Registered: November 2009
Location: india
Junior Member
Can anyone help me in understanding how many times the select statement will be executed in below program?

What exactly the cursor c1 holds? data set returned by select statement or the parsed select statement?

If it holds the parsed select statement then the parsed statement is going to be executed each time we fetch from cursor c1?


declare
v_ename varchar2(30);
cursor c1 is select ename from emp;
begin
open c1;
  loop
    fetch c1 into v_ename;
    exit when c1%notfound;
    dbms_output.put_line(v_ename);
  end loop;
close c1;
end;

[Updated on: Wed, 04 November 2009 14:29]

Report message to a moderator

Re: help me on CURSOR [message #429622 is a reply to message #429612] Wed, 04 November 2009 15:03 Go to previous messageGo to next message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL is executed only once, cursor "contains" the execution and where in this execution plan the statement is.

Database Concepts
Chapter 24 SQL, PL/SQL, and Java
Section Overview of SQL
Paragraph SQL Processing/SQL Statement Execution

Regards
Michel
Re: help me on CURSOR [message #429627 is a reply to message #429612] Wed, 04 November 2009 15:25 Go to previous message
BlackSwan
Messages: 25041
Registered: January 2009
Location: SoCal
Senior Member
When all else fails, Read The Fine Manual

http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/sqlplsql.htm#sthref3436

Cursors

A cursor is a handle or name for a private SQL area--an area in memory in which a parsed statement and other information for processing the statement are kept.




Previous Topic: ORA-00904: : invalid identifier during merge
Next Topic: Remove primary key
Goto Forum:
  


Current Time: Tue Dec 06 12:29:25 CST 2016

Total time taken to generate the page: 0.20532 seconds