In this postgressql function i created a array by spliting a string. Now i want loop on this array and do some processing on it.
Function:
CREATE OR REPLACE FUNCTION getAllFoo() RETURNS character varying as
$BODY$
DECLARE
arr_split_data text[];
counter character varying;
begin
counter := ''; -- Init value
-- split data. Add in array
select into arr_split_data regexp_split_to_array('a,b,c,d,e,f',',');
FOR r IN arr_split_data -- error
LOOP
counter := arr_split_data[r] || '_' || counter; -- do some processing
END LOOP;
return counter;
END
$BODY$
LANGUAGE 'plpgsql';
But I am getting this error
when I execute this function. Is my syntax for loop is wrong?