Re: Generating table rows from arrays

From: Richard Huxton <dev(at)archonet(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:37:15
Message-ID: 487F20DB.6030106@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Florian Weimer wrote:
> 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.

The smallest function I've seen is Merlin Moncure's here:

http://people.planetpostgresql.org/merlin/index.php?/archives/4-fun-with-arrays.html

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Pavel Stehule 2008-07-17 10:38:41 Re: Generating table rows from arrays
Previous Message Florian Weimer 2008-07-17 10:23:28 Generating table rows from arrays