Re: Multiple Inserts
От | |
---|---|
Тема | Re: Multiple Inserts |
Дата | |
Msg-id | 20050722212258.37605.qmail@web33309.mail.mud.yahoo.com обсуждение исходный текст |
Ответ на | Re: Multiple Inserts (Michael Fuhr <mike@fuhr.org>) |
Список | pgsql-novice |
--- Michael Fuhr <mike@fuhr.org> wrote: > On Fri, Jul 22, 2005 at 01:49:25PM -0700, > operationsengineer1@yahoo.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
В списке pgsql-novice по дате отправления: