Skip site navigation (1) Skip section navigation (2)

Re: Generating table rows from arrays

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Florian Weimer" <fweimer(at)bfk(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Generating table rows from arrays
Date: 2008-07-17 10:38:41
Message-ID: 162867790807170338o69793a4xc8dddfb60201a09f@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-sql
Hello

se own unpack sql function

http://www.pgsql.cz/index.php/PostgreSQL_SQL_Tricks#Array_to_table

Regards
Pavel Stehule

2008/7/17 Florian Weimer <fweimer(at)bfk(dot)de>:
> Is there a convenient way to turn an array into table rows?  For
> example, I've got an array like {1, 2, 3} and would like to insert
> rows:
>
>  ('aaa', 1)
>  ('aaa', 2)
>  ('aaa', 3)
>
> The first row is constant.  I could write a loop with PL/pgsql, I
> guess, but I wonder if there are better options nowadays.
>
> --
> Florian Weimer                <fweimer(at)bfk(dot)de>
> BFK edv-consulting GmbH       http://www.bfk.de/
> Kriegsstra├če 100              tel: +49-721-96201-1
> D-76133 Karlsruhe             fax: +49-721-96201-99
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

pgsql-sql by date

Next:From: Oliveiros CristinaDate: 2008-07-17 11:18:18
Subject: Re: How to GROUP results BY month
Previous:From: Richard HuxtonDate: 2008-07-17 10:37:15
Subject: Re: Generating table rows from arrays

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group