Received: from candle.pha.pa.us (root@s5-03.ppp.op.net [209.152.195.67]) by hub.org (8.9.3/8.9.3) with ESMTP id TAA81155 for ; Tue, 7 Dec 1999 19:25:51 -0500 (EST) (envelope-from pgman@candle.pha.pa.us) Received: (from pgman@localhost) by candle.pha.pa.us (8.9.0/8.9.0) id TAA15142; Tue, 7 Dec 1999 19:19:23 -0500 (EST) From: Bruce Momjian Message-Id: <199912080019.TAA15142@candle.pha.pa.us> Subject: Re: [SQL] Getting last used oid In-Reply-To: <19991207.113118.-748361.0.jcc2@juno.com> from John C Cusick at "Dec 7, 1999 11:31:16 am" To: John C Cusick Date: Tue, 7 Dec 1999 19:19:23 -0500 (EST) CC: pgsql-sql@postgreSQL.org X-Mailer: ELM [version 2.4ME+ PL65 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit > To All, > > How can I call up the last oid used in an insert statement? I've checked > the docs (but not the source - getting a little big :-) by way of the > TOC's and didn't see it. I'm assuming/hoping there is a function > similar to lastval, curval, nextval for sequences available to > do this that I would like to use in a trigger to populate another table. > > I also did a perusal of the new book, which looks *_really_* good so far, > but it didn't have what I was hoping to find. > > I can do it normally of course (select oid, 'last_inserted_unique_field') > from table;) but > i would like a more behind the scenes way. 6.6 or 7.0 will have a :LastOid variable in psql. From libpq in C, there are functions to access it. -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026