Re: [Plproxy-users] A complex plproxy query

From: Igor Katson <descentspb(at)gmail(dot)com>
To: Hannu Krosing <hannu(at)2ndQuadrant(dot)com>
Cc: Marko Kreen <markokr(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org, plproxy-users(at)pgfoundry(dot)org
Subject: Re: [Plproxy-users] A complex plproxy query
Date: 2009-01-22 14:16:46
Message-ID: 49787FCE.3040509@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hannu Krosing wrote:
> On Thu, 2009-01-22 at 15:10 +0300, Igor Katson wrote:
>
>
>> Ok, thank you, guys. What is the best way to make an array out of a
>> column? I didn't make up anything better then writing a function:
>>
>> CREATE OR REPLACE FUNCTION int_column_to_array(query text) RETURNS int[]
>> AS $$
>> DECLARE
>> arr int[];
>> rec int;
>> BEGIN
>> FOR rec IN EXECUTE query
>> LOOP
>> arr := array_append('{}',rec);
>> END LOOP;
>> RETURN arr;
>> END;
>> $$ language plpgsql;
>>
>
> hannu=# select ARRAY(select usename from pg_user);
> ?column?
> -------------------------------
> {postgres,hannu,m1,skyncuser}
> (1 row)
>
>
>
>
Lots of thanks! I tried the same one, but with ARRAY[], so i didn't get
anything.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Hannu Krosing 2009-01-22 14:22:48 Re: [Plproxy-users] A complex plproxy query
Previous Message Hannu Krosing 2009-01-22 14:13:45 Re: [Plproxy-users] A complex plproxy query