Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: select in a loop
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 forsomething or add it to a vector with vect.extend(1); vect(vect.count) := p;>