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

Home -> Community -> Usenet -> c.d.o.misc -> Re: select in a loop

Re: select in a loop

From: JMecc <jmecc_at_telus.net>
Date: Thu, 12 Jul 2007 10:07:14 -0700
Message-ID: <1184260034.339914.168000@22g2000hsm.googlegroups.com>


You need an 'EXIT WHEN' clause to end your loop (you have a 'while true' loop with no exit possible). You can just have a counter and say EXIT WHEN i > 10 or something.

For retrieving a bunch of results define a cursor:

before the BEGIN statement put
CURSOR crs IS

        SELECT myfield FROM mytable;

and in the program put the loop as
LOOP

        FETCH crs INTO p;
        EXIT WHEN crs%notfound;

        <code here to do something with this value, like check it for
something or add it to a vector with vect.extend(1); vect(vect.count) := p;>
END LOOP; Hope this helps,
Jo Received on Thu Jul 12 2007 - 12:07:14 CDT

Original text of this message

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