SQL> begin
2 for i in 'some string', 'another string' loop
3 dbms_output.put_line(i);
4 end loop;
5 end;
6 /
for i in 'some string', 'another string' loop
*
ERROR at line 2:
ORA-06550: line 2, column 24:
PLS-00103: Encountered the symbol "," when expecting one of the following:
. ( * @ % & - + / loop mod range rem .. an exponent (**) ||
The symbol ". was inserted before "," to continue.
If the for loop index only works as a number, I believe the only way to loop
through an array of string is to put those strings in a PL/SQL table first.
Any advice is appreciated.
Yong Huang
yhu...@indigopool.com
The for loop has always an integer index (and the incrment is always
one). If you want to loop through a string list you need in fact a
PL/SQL-Table:
declare
type string_list is table of varchar2(50);
my_list string_list := string_list('some string', 'another string');
begin
for i in my_list.first .. my_list.last loop
dbms_output.put_line( my_list(i) );
end loop;
end;
/