Re: Generating table rows from arrays - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Generating table rows from arrays
Date
Msg-id 487F20DB.6030106@archonet.com
Whole thread Raw
In response to Generating table rows from arrays  (Florian Weimer <fweimer@bfk.de>)
Responses Re: Generating table rows from arrays  (Florian Weimer <fweimer@bfk.de>)
List 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


pgsql-sql by date:

Previous
From: Florian Weimer
Date:
Subject: Generating table rows from arrays
Next
From: "Pavel Stehule"
Date:
Subject: Re: Generating table rows from arrays