Re: array to rows of it's elements?
От
Celia McInnis
Тема
Re: array to rows of it's elements?
Дата
Msg-id
20050706164049.M36117@drmath.ca
Ответ на
array to rows of it's elements? (Celia McInnis)
Список
Дерево обсуждения
array to rows of it's elements? "Celia McInnis" <celia@drmath.ca>
Re: array to rows of it's elements? "Celia McInnis" <celia@drmath.ca>
This is the best that I can do with what I currenty know, so if you have a
better/faster solution, please send it my way:
CREATE OR REPLACE FUNCTION array_to_rows(myarray ANYARRAY) RETURNS SETOF
ANYELEMENT AS $$
BEGIN
FOR j IN 1..ARRAY_UPPER(myarray,1) LOOP
RETURN NEXT myarray[j];
END LOOP;
RETURN;
END;
$$ LANGUAGE 'plpgsql';
which I may then call like:
SELECT * FROM arrayto_rows(somearray);
Thanks
Celia McInnis
On Wed, 6 Jul 2005 09:37:10 -0500, Celia McInnis wrote
> Is there a function which will return the elements of an array as
> rows of entries? What I'd like in the 1 dimensional array case is
> something like:
>
> select array-to-rows(ARRAY[1,2,3]);
>
> giving
>
> 1
> 2
> 3
> (3 rows)
>
> Thanks,
> Celia McInnis
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
--
Open WebMail Project (http://openwebmail.org)
В списке pgsql-novice по дате отправления