Re: [SQL] Programatically switching database

2003-11-15 Thread Peter Eisentraut
ow writes: > Is there a way to programatically switch conn1 to use db2 without doing > disconnect-from-db1-connect-to-db2? Something like what "\c" does but to > be used independently from psql? I need this to be able to reuse a pool > of connections to db1 for actions on db1, db2 ... dbn. Nothin

[SQL] Getting last insert value

2003-11-15 Thread Yasir Malik
Hello, I have a table with many fields, and one of the fields is of type serial. I will do many inserts, and there will be many repeats of the other fields in the table, but, obviously, the serial field will be unique for all the rows. How can I get the value of serial field of the last row I inse

Re: [SQL] Getting last insert value

2003-11-15 Thread Guillaume LELARGE
Le Samedi 15 Novembre 2003 15:18, vous avez écrit : > Hello, > I have a table with many fields, and one of the fields is of type serial. > I will do many inserts, and there will be many repeats of the other fields > in the table, but, obviously, the serial field will be unique for all the > rows.

Re: [SQL] Programatically switching database

2003-11-15 Thread ow
--- Peter Eisentraut wrote: > Nothing prevents you from keeping the connection to db1 open when you open > a connection to db2. By the way, psql's "\c" command does exactly > disconnect-from-db1-connect-to-db2. That's the whole point: I'm trying to avoid maintaining *separate* connection pools

Re: [SQL] Programatically switching database

2003-11-15 Thread Peter Eisentraut
ow writes: > That's the whole point: I'm trying to avoid maintaining *separate* connection > pools for each db. In other words, instead of having, say, 5 connection pools > to 5 dbs with total of 1000 connections, I could've used just one (1) pool with > 200 connections, if there was a way to "swi

Re: [SQL] Getting last insert value

2003-11-15 Thread Guillaume LELARGE
Le Samedi 15 Novembre 2003 16:40, vous avez écrit : > Doing a "select currval() from my_table" after your insert should work. > Actually, this is select currval('my_sequence') Sorry about this. > For more details, see > http://www.postgresql.org/docs/7.3/interactive/functions-sequence.html -

Re: [SQL] Getting last insert value

2003-11-15 Thread Greg Stark
Guillaume LELARGE <[EMAIL PROTECTED]> writes: > Doing a "select currval() from my_table" after your insert should work. That's "select currval('my_table_pkcol_seq')" actually. The above would have called the currval() function for every record of the table which isn't what you want and in any

Re: [SQL] Programatically switching database

2003-11-15 Thread ow
--- Peter Eisentraut <[EMAIL PROTECTED]> wrote: > I'm afraid that what you want to do is not possible. Perhaps you want to > organize your data into schemas, not databases. There's too much data to put it in one db. If anything happens to it, I'll never be able to restore (or dump) it in time. B

Re: [SQL] Programatically switching database

2003-11-15 Thread ow
--- Peter Eisentraut <[EMAIL PROTECTED]> wrote: > I'm afraid that what you want to do is not possible. Perhaps you want to > organize your data into schemas, not databases. There's too much data to put it in one db. If anything happens to it, I'll never be able to restore (or dump) it in time. B

Re: [SQL] Programatically switching database

2003-11-15 Thread Peter Eisentraut
ow writes: > There's too much data to put it in one db. There is never too much data to be put in one database. > If anything happens to it, I'll never be able to restore (or dump) it in > time. You could just dump individual schemas. > BTW, mySql has cross-db queries. PostgreSQL has schemas,

Re: [SQL] Programatically switching database

2003-11-15 Thread ow
--- Peter Eisentraut <[EMAIL PROTECTED]> wrote: > You could just dump individual schemas. How? The doc only mentions db: pg_dump [option...] [dbname] Then, how would I lock users out from the schema while it's being loaded? Thanks __ Do you Yahoo!? Protect y

Re: [SQL] Getting last insert value

2003-11-15 Thread Yasir Malik
Thank you all for your help. Yasir Malik On Sat, 15 Nov 2003, Greg Stark wrote: > Date: 15 Nov 2003 12:50:28 -0500 > From: Greg Stark <[EMAIL PROTECTED]> > To: Guillaume LELARGE <[EMAIL PROTECTED]> > Cc: Yasir Malik <[EMAIL PROTECTED]>, [EMAIL PROTECTED] > Subject: Re: [SQL] Getting last insert v

Re: [SQL] Getting last insert value

2003-11-15 Thread Theodore Petrosky
what does that mean the 'last row'? if client 1 inserts then client 2, the last row is client 2. do you want to know what row client 1 inserted? Personally I think your question is too broad. What are you trying to accomplish? Ted --- Yasir Malik <[EMAIL PROTECTED]> wrote: > Hello, > I have a ta

Re: [SQL] Programatically switching database

2003-11-15 Thread ow
--- ow <[EMAIL PROTECTED]> wrote: > How? The doc only mentions db: pg_dump [option...] [dbname] > > Then, how would I lock users out from the schema while it's being loaded? Never mind how, I see there's "-n namespace" option in 7.4. But still, how would I lock users out from the schema while it

Re: [SQL] Programatically switching database

2003-11-15 Thread Jan Wieck
ow wrote: --- ow <[EMAIL PROTECTED]> wrote: How? The doc only mentions db: pg_dump [option...] [dbname] Then, how would I lock users out from the schema while it's being loaded? Never mind how, I see there's "-n namespace" option in 7.4. But still, how would I lock users out from the schema while

Re: [SQL] Programatically switching database

2003-11-15 Thread Jan Wieck
Jan Wieck wrote: ow wrote: --- ow <[EMAIL PROTECTED]> wrote: How? The doc only mentions db: pg_dump [option...] [dbname] Then, how would I lock users out from the schema while it's being loaded? Never mind how, I see there's "-n namespace" option in 7.4. But still, how would I lock users out fro

Re: [SQL] Programatically switching database

2003-11-15 Thread ow
--- Jan Wieck <[EMAIL PROTECTED]> wrote: > #!/bin/sh > > ( > echo "start transaction;" > cat $2 > echo "commit transaction;" > ) psql $1 > > > > then call it as > > reload_in_transaction my_db my_namespace.dump > > Since the whole dump will be restored inside of one transaction