Selecting from table into an array var

From: Postgres User <postgres(dot)developer(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Selecting from table into an array var
Date: 2009-12-19 01:14:00
Message-ID: b88c3460912181714v4917dd8ck8170f22e716cccc1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I'm trying to write a very simple function statement to select a
single integer field from a table and save it into an int array. For
some reason I can't seem to find the correct syntax:

CREATE TABLE sample (
id integer
);

and then within a function:

my_array int[];
my_array = SELECT ARRAY(id) FROM sample;

This syntax and variations of it don't work. Can anyone show me the
correct approach?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John DeSoi 2009-12-19 03:31:25 Re: Extended Query, flush or sync ?
Previous Message Alex - 2009-12-19 00:40:07 Re: PL/Perl Performance Problems