Generating table rows from arrays

From: Florian Weimer <fweimer(at)bfk(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Generating table rows from arrays
Date: 2008-07-17 10:23:28
Message-ID: 82d4lcdd27.fsf@mid.bfk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2008-07-17 10:37:15 Re: Generating table rows from arrays
Previous Message Richard Huxton 2008-07-17 08:30:45 Re: PERSISTANT PREPARE (another point of view)