pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pavel Stehule <pavel.stehule@gmail.com>
To: Andreas <maps.on@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: insert into table from list or array ?
Date: Mon, 18 Oct 2010 20:14:28 +0200
Message-ID: <AANLkTimxaYzBmm9PyLXgf9okbLmM0eYTMQmgU1kpTZNr@mail.gmail.com> (raw)
In-Reply-To: <4CBC8B3B.7060708@gmx.net>
References: <4CBC8B3B.7060708@gmx.net>

Hello

2010/10/18 Andreas <maps.on@gmx.net>:
>  Hi,
>
> is it possible to insert into a table from list or an array ?
>

yes, it's possible

INSERT INTO tmptab
   SELECT v
     FROM unnest(string_to_array('1,2,4,2,1',',')) g(v)

Regards

Pavel Stehule

> Suppose there is a set of numbers that might be IDs of tables within the DB.
> To work with them I'd need a temporary table that just holds a single column
> with those numbers.
> Something like
>
> create temporary table tmptable as select id from
> ( 2, 3, 5, 7, 11, 13, 17, 19, 23, 31,
>  37, ... );
>
> would be great.
>
> I get those numbers as textfile with 10 numbers per line and devided by
> comma+space as in the sample above, though the comma+space is negotiable if
> this were an issue.
>
> :)
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>



view thread (4+ messages)  latest in thread

Message-ID: <AANLkTimxaYzBmm9PyLXgf9okbLmM0eYTMQmgU1kpTZNr@mail.gmail.com>
Permalink:  ../AANLkTimxaYzBmm9PyLXgf9okbLmM0eYTMQmgU1kpTZNr@mail.gmail.com/
Also on:    postgresql.org/message-id/AANLkTimxaYzBmm9PyLXgf9okbLmM0eYTMQmgU1kpTZNr@mail.gmail.com

 · 

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: pavel.stehule@gmail.com, maps.on@gmx.net
  Subject: Re: insert into table from list or array ?
  In-Reply-To: <AANLkTimxaYzBmm9PyLXgf9okbLmM0eYTMQmgU1kpTZNr@mail.gmail.com>

* 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