How do I create an array and then put a result of a function into it?
I'm doing it like this:
array text[];
select regexp_split_to_array('whatever this is it splits into array with spaces', E'\\s+')
into array;
But obviously it doesn't work, when I try to
raise notice '%', array[1];
It's just not how it's done.
Best Answer
array
is a reserved word. You cannot use it as variable name in plpgsql. This works:SQL Fiddle
Also simplified
E'\\s+'
->'\s+'
.standard_conforming_strings = ON
is the default since Postgres 9.1 and should be the universal setting by now.