Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> PLSQL: variable in FOR loop
The following code is a simple loop that works as advertised:
FOR cnty IN (SELECT DISTINCT country FROM cities ORDER BY 1)
LOOP
.. do some stuff ..
END LOOP;
I need to make the SQL a touch dynamic, so I tried the following:
vSQL VARCHAR2(100);
BEGIN
vSQL := 'SELECT DISTINCT country FROM cities ORDER BY 1';
FOR cnty IN (vSQL)
LOOP
.. do some stuff ..
END LOOP;
And I get the following:
PLS-00103: Encountered the symbol "LOOP" when expecting one of the
following: * & - + / mod rem .. an exponent (**) ||
Ouch! Is this possible?
Thanks very much
Mark
mark_aurit ATSIGN mail.northgrum.com
Received on Mon Aug 03 1998 - 13:50:09 CDT
![]() |
![]() |