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

From: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
To: Igor Katson <descentspb(at)gmail(dot)com>
Cc: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Accessing array elements in a FOR PL/pgsql loop
Date: 2009-02-19 12:04:01
Message-ID: Pine.LNX.4.64.0902191503290.31919@sn.sai.msu.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 19 Feb 2009, Igor Katson wrote:

> 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.
>

there is, but in CVS HEAD
psql (8.4devel)
Type "help" for help.

postgres=# select unnest('{1,2,3}'::int[]);
unnest
--------
1
2
3
(3 rows)

Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru),
Sternberg Astronomical Institute, Moscow University, Russia
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(495)939-16-83, +007(495)939-23-83

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jasen Betts 2009-02-19 12:18:15 Re: createdb.exe and psql.exe without Promting Password
Previous Message Jasen Betts 2009-02-19 11:30:31 Re: Appending \o output instead of overwriting the output file