Re: Accessing array elements in a FOR PL/pgsql loop

From: Igor Katson <descentspb(at)gmail(dot)com>
To: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Accessing array elements in a FOR PL/pgsql loop
Date: 2009-02-19 11:26:56
Message-ID: 499D4200.2080709@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

A. Kretschmer wrote:
> In response to Igor Katson :
>
>> I think I need a built-in function to make a column from an array, like
>> in the backwards operation SELECT ARRAY(column)
>>
>
> By David Fetter:
>
> CREATE OR REPLACE FUNCTION unnest(ANYARRAY) RETURNS SETOF ANYELEMENT
> LANGUAGE SQL AS $$SELECT $1[i] FROM
> generate_series(array_lower($1,1),array_upper($1,1)) i;$$;
>
> HTH, Andreas
>
Thanks. I thought, there is a built-in one for that.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jasen Betts 2009-02-19 11:30:31 Re: Appending \o output instead of overwriting the output file
Previous Message Howard Cole 2009-02-19 11:10:55 Re: Pet Peeves?