Received: from helium.em-systems.com (IDENT:lyonj@[208.31.215.250]) by hub.org (8.9.3/8.9.3) with ESMTP id NAA23442 for ; Mon, 26 Jul 1999 13:32:10 -0400 (EDT) (envelope-from lyonj@em-systems.com) Received: from localhost (lyonj@localhost) by helium.em-systems.com (8.8.7/8.8.5) with ESMTP id NAA24093; Mon, 26 Jul 1999 13:39:38 -0400 Date: Mon, 26 Jul 1999 13:39:38 -0400 (EDT) From: Jeffrey Lyon To: marc rassbach cc: pgsql-interfaces@postgreSQL.org Subject: Re: [INTERFACES] How can I work thru this key problem? In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII There's probably a better way, but I do a: SELECT NEXTVAL('thenextkey') AS n_thenextkey; INSERT INTO exampletable (keyiwant, otherinfo) VALUES (n_thenextkey, 'somestring'); ...and then use n_thenextkey to refer to the newly added tuple. Jeffrey On Mon, 26 Jul 1999, marc rassbach wrote: > I am using > 6.5 postgresql > DBD pg 0.91 > DBI 1.08 > > I have a table that looks like: > > create table exampletable ( > keyiwant int4 default nextval('thenextkey') not null, > otherinfo varchar(20) > ); > > > When I place, oh say the string "Whatsmyid" into exampletable, I'd like to > be able to know the value of keyiwant is, without going back and doing a > select keyiwant from exampletable where otherinfo = "Whatsmyid" > > Ideas on how I can get to where I want to go? > > >