Re: Can PL/SQL FOR IN used with strings?

From: doganay_n <doganaynnecati_at_gmail.com>
Date: Fri, 21 Feb 2014 00:47:21 -0800 (PST)
Message-ID: <3ffffe84-b7ef-4d41-b73f-55e4438c8d85_at_googlegroups.com>


17 Kasım 2000 Cuma 10:00:00 UTC+2 tarihinde Daniel Blonski yazdı:
> Yong Huang wrote:
> >
> > Can I use PL/SQL For Loop on an array of strings instead of numbers?
> >
> > 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:
> > . ( * _at_ % & - + / 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
> > yhuang_at_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;
> /

Thanks Daniel :=) Received on Fri Feb 21 2014 - 09:47:21 CET

Original text of this message