Re: Expressing a result set as an array (and vice versa)?

Поиск
Список
Период
Сортировка
От Jim C. Nasby
Тема Re: Expressing a result set as an array (and vice versa)?
Дата
Msg-id 20060327134831.GJ80726@pervasive.com
обсуждение исходный текст
Ответ на Re: Expressing a result set as an array (and vice versa)?  (PFC <lists@peufeu.com>)
Ответы Re: Expressing a result set as an array (and vice versa)?  (PFC <lists@peufeu.com>)
Список pgsql-sql
On Sat, Mar 25, 2006 at 12:17:08AM +0100, PFC wrote:
> 
> 
> CREATE OR REPLACE FUNCTION foreach( liste INTEGER[] ) RETURNS SETOF  
> INTEGER AS $$
> DECLARE
>   i INTEGER;
> BEGIN
>   FOR i IN 1..icount(liste) LOOP
>     RETURN NEXT liste[i];
>   END LOOP;
> END;
> $$ LANGUAGE plpgsql;

Seems like this should really exist in the backend...

> CREATE AGGREGATE array_accum (
>     sfunc = array_append,
>     basetype = anyelement,
>     stype = anyarray,
>     initcond = '{}'
> );
> 
> SELECT array_accum( DISTINCT list_id ) FROM bookmarks;
>   array_accum
> ---------------
>  {1,2,3,4,5,7}

Couldn't you just use array()?
-- 
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461


В списке pgsql-sql по дате отправления:

Предыдущее
От: John DeSoi
Дата:
Сообщение: Re: Problem using set-returning functions
Следующее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: SQL Query Newbie Help