Thread: Iterating over an varchar array?

Iterating over an varchar array?

From
"Marcos Iuato"
Date:
I am trying to iterate over an varchar array using plpgsql but i get the
this error:

Error: missing .. at the end of SQL expression

My Table:

TABLE1(
Cars VARCHAR[]
)

My Code

Declare
 mycars varchar[];
 car varchar;
Begin
 For car in SELECT cars from table1 LOOP
   RAISE Notice "CAR: %", car
 END Loop;
END;

Resume, i have a column with a list of varchar type and i would like to
iterate over this array, is this possible?

Thanks,

Re: Iterating over an varchar array?

From
Tom Lane
Date:
"Marcos Iuato" <iuato@samurai.com.br> writes:
> Declare
>  mycars varchar[];
>  car varchar;
> Begin
>  For car in SELECT cars from table1 LOOP

I think the iteration variable for a FOR ... IN SELECT has to be a
record or rowtype variable.

            regards, tom lane