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

Home -> Community -> Usenet -> c.d.o.server -> Re: 'SELECT nexval FROM sequence' in a PL/SQL loop: use a cursor ?

Re: 'SELECT nexval FROM sequence' in a PL/SQL loop: use a cursor ?

From: Noel <tbal_at_go2.pl>
Date: Thu, 23 Oct 2003 17:47:29 +0100
Message-ID: <bn8t3t$25n$1@inews.gazeta.pl>

Uzytkownik "Spendius" <spendius_at_muchomail.com> napisal w wiadomosci news:aba30b75.0310230603.50ef719a_at_posting.google.com...
> Hi,
> I found the following in the code of one of the developers
> here:
> > FOR r_get_tael IN c_get_tael LOOP
> > OPEN c_get_tael_seq;
> > FETCH c_get_tael_seq INTO r_get_tael_seq;
> > CLOSE c_get_tael_seq;
> > BEGIN
> > ...
> which loops 140 000 times. The c_get_tael_seq cursor
> only performs a simple
> > SELECT <seq.>NEXTVAL FROM DUAL;
> so I just would like to know whether the fact he uses
> a cursor (that gets opened and closed 140 000 times) will
> have a bad impact or not compared with the use of the mere
> SQL statement it refers to, i.e. instead of using:
> > FOR r_get_tael IN c_get_tael LOOP
> > SELECT <seq.>NEXTVAL into <variable> FROM DUAL;
> > BEGIN
Try find out how 'select <seq.>.nextval into <variable> from dual; is evaluated.
To do this simple select:

  1. a cursor must be opened.
  2. a value must be fetched.
  3. a cursor must be closed.

What cursor you ask ?? If you didn't declare one, oracle will do it for you without any notyfication :-)
Try to find out in oracle manuals
-
Noel Received on Thu Oct 23 2003 - 11:47:29 CDT

Original text of this message

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