Cursor concept



Hi !
I tried to show a friend that pl/sql cursors are in fact pointers and
do not retrive all rows when you open them. So I made this very simple
test case, but I don't understand the output. I think the answer comes
from the multiversioning side, but I 'd like to understand clearly this
case with a cursor. May be it is not just a memory position isn't it ?

Thanks.

C:\>sqlplus scott/tiger

SQL*Plus: Release 9.2.0.1.0 - Production on Wed Dec 7 22:40:55 2005

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production

SQL> create table t as select rownum a from user_objects where rownum <
10;

Table created.

SQL> declare
1 cursor cur_test is
2 select a
3 from t
4 order by a;
5 v_test t.a%type;
6 cont boolean := TRUE;
7 begin
8 open cur_test;
9 loop
10 fetch cur_test into v_test;
11 exit when cur_test%notfound;
12 if cont then
13 begin
14 delete from t where a = 9;
15 cont := FALSE;
16 commit;
17 end;
18 end if;
19 dbms_output.put_line(v_test);
20 end loop;
21 close cur_test;
22 end;
23 /
1
2
3
4
5
6
7
8
9

PL/SQL procedure successfully completed.

SQL>

.



Relevant Pages

  • Re: Help: Error Invalid Number at line 22
    ... CURSOR CUR_LOC IS ... 19 END LOOP; ... What bothers me is that this is an inappropriate use of a cursor ... Inappropriate use of native dynamic SQL ...
    (comp.databases.oracle.server)
  • Re: Help: Error Invalid Number at line 22
    ... CURSOR CUR_LOC IS ... 19 END LOOP; ... What bothers me is that this is an inappropriate use of a cursor ... Inappropriate use of native dynamic SQL ...
    (comp.databases.oracle.server)
  • Re: dynamic sql with a cursor ?
    ... Maybe if you explain what you need to do in the loop, we can show you how to ... do it without the cursor. ... Aaron Bertrand ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Cursor concept
    ... | case with a cursor. ... | 20 end loop; ... Moreover, as you have an "order by" clause in your clause, the result is ...
    (comp.databases.oracle.misc)
  • Re: Cursor performance
    ... open Cursor for sql; ... Fetch Cursor into lvfield; ... end loop ... - Never use an explicit cursor for what you can just do in a SQL ...
    (comp.databases.oracle.server)