Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: copy cursor ???

Re: copy cursor ???

From: <Jared.Still_at_radisys.com>
Date: Mon, 01 Oct 2001 16:48:26 -0700
Message-ID: <F001.0039E2D6.20011001170017@fatcity.com>

Use a read only transaction.

Here's an example.

Jared


drop table datetab;
create table datetab ( cdate date );

begin

   for i in 1..10
   loop

      insert into datetab values(sysdate);    end loop;
end;
/

commit;

exec dbms_lock.sleep(1)

declare

   cursor cDate
   is
   select cdate
   from datetab;

   i pls_integer;

   procedure addrow
   is

      pragma autonomous_transaction;
   begin

      insert into datetab values(sysdate);
      commit;

   end;

begin

   commit;
   set transaction read only;

   i := 0;
   for rec in cDate
   loop

      dbms_output.put_line(rec.cdate);
      i := i + 1;

   end loop;
   dbms_output.put_line('counter: ' || i );

   addrow;

   i := 0;
   for rec in cDate
   loop

      dbms_output.put_line(rec.cdate);
      i := i + 1;

   end loop;
   dbms_output.put_line('counter: ' || i );

   commit;

end;
/

select * from datetab;

                                                                                       
                             
                    Andrea Oracle                                                      
                             
                    <andreaoracle@       To:     Multiple recipients of list ORACLE-L 
<ORACLE-L_at_fatcity.com>        
                    yahoo.com>           cc:                                           
                             
                    Sent by:             Subject:     copy cursor ???                  
                             
                    root_at_fatcity.c                                                     
                             
                    om                                                                 
                             
                                                                                       
                             
                                                                                       
                             
                    10/01/01 03:55                                                     
                             
                    PM                                                                 
                             
                    Please respond                                                     
                             
                    to ORACLE-L                                                        
                             
                                                                                       
                             
                                                                                       
                             




Hi, all

Is there a way to clone/copy a cursor? I have a cursor, after looping throught it, I would like to go to the beginning and loop again. If I open the cursor again, my impression is that the cursor does a new select, which might not return the exact same rows as before, since the data got changed all the time. If I open the cursor twice in delcare section, the two cursor might not be the same, since it took about 3 minutes to do the select. So how can I work on two EXACTLY same copies of the cursor? Thank you!

Andrea



Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone. http://phone.yahoo.com
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Andrea Oracle
  INET: andreaoracle_at_yahoo.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).




-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: Jared.Still_at_radisys.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Mon Oct 01 2001 - 18:48:26 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US