Re: Multiple Inserts

From: <operationsengineer1(at)yahoo(dot)com>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Multiple Inserts
Date: 2005-07-22 21:22:58
Message-ID: 20050722212258.37605.qmail@web33309.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

--- Michael Fuhr <mike(at)fuhr(dot)org> wrote:

> On Fri, Jul 22, 2005 at 01:49:25PM -0700,
> operationsengineer1(at)yahoo(dot)com wrote:
> >
> > i need to insert multiple serial numbers at a time
> > (eg, 100). my current idea is to allow the user
> to
> > enter a beginning serial number, an ending serial
> > number and then use php to iterate through the
> numbers
> > and insert them (i'm thinking multiple inserts
> (get
> > value -> insert, get 2nd value -> insert, get 3rd
> > value, insert, etc...) unless someone can give me
> an
> > idea how to collect the data then do one big
> insert).
>
> In 8.0 you can use INSERT ... SELECT and
> generate_series():
>
>
http://www.postgresql.org/docs/8.0/static/sql-insert.html
>
http://www.postgresql.org/docs/8.0/static/functions-srf.html
>
> Example:
>
> INSERT INTO foo (serialnum) SELECT * FROM
> generate_series(1, 100);
>
> Although older versions of PostgreSQL don't have
> generate_series(),
> it's trivial to write with PL/pgSQL or other
> languages. Read up
> on set-returning functions or search the archives
> for examples.
>
> --
> Michael Fuhr
> http://www.fuhr.org/~mfuhr/
>

thanks. this is really nice! we should be moving our
production db onsite so i will be able to have pgsql
8.0 installed.

i will probably have to rethink my webhost if i ever
decide to put anything serious on the net. tom is
right, they (2wdh.com or cpanel, it doesn't really
matter) aren't taking pgsql users seriously - and you
just showed me one way they are hurting me (not to
mention security holes in older versions)!

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Fuhr 2005-07-22 23:26:46 Re: auditorship in PostgreSQL
Previous Message Michael Fuhr 2005-07-22 21:09:57 Re: Multiple Inserts