pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>
To: pgsql-sql@postgresql.org
Subject: Re: returning an array as a list fo single-column rows?
Date: Sun, 23 Dec 2007 22:22:05 +0100
Message-ID: <20071223212205.GA15367@apartia.fr> (raw)
In-Reply-To: <162867790712231319i35fb31el8d4c367bc313979b@mail.gmail.com>
References: <20071223205557.GA14403@apartia.fr>
	<162867790712231319i35fb31el8d4c367bc313979b@mail.gmail.com>

On Sun, Dec 23, 2007 at 10:19:26PM +0100, Pavel Stehule wrote:
> Hello
> 
> try
> 
> create or replace function unpack(anyarray)
> returns setof anyelement as $$
>   select $1[i]
>      from generate_series(array_lower($1,1), array_upper($1,1)) g(i);
> $$ language sql;
> 
> postgres=# select * from unpack(array[1,2,3,4]);
>  unpack
> --------
>       1
>       2
>       3
>       4
> (4 rows)

Beautiful. Thank you.



view thread (6+ messages)  latest in thread

Message-ID: <20071223212205.GA15367@apartia.fr>
Permalink:  ../20071223212205.GA15367@apartia.fr/
Also on:    postgresql.org/message-id/20071223212205.GA15367@apartia.fr

 · 

reply

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: vindex+lists-pgsql-sql@apartia.org
  Subject: Re: returning an array as a list fo single-column rows?
  In-Reply-To: <20071223212205.GA15367@apartia.fr>

* 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