From: Jim C. Nasby <jnasby@pervasive.com>
To: PFC <lists@peufeu.com>
Cc: Don Maier <dMaier@genome.stanford.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: Expressing a result set as an array (and vice versa)?
Date: Mon, 27 Mar 2006 07:48:31 -0600
Message-ID: <20060327134831.GJ80726@pervasive.com> (raw)
In-Reply-To: <op.s6xxmukycigqcu@apollo13>
References: <F3E0C44C-6118-41C6-AC71-2B19258F4F07@genome.stanford.edu>
<op.s6xxmukycigqcu@apollo13>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: jnasby@pervasive.com, lists@peufeu.com, dMaier@genome.stanford.edu
Subject: Re: Expressing a result set as an array (and vice versa)?
In-Reply-To: <20060327134831.GJ80726@pervasive.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox