Received: from thor.tht.net (thor.tht.net [209.47.145.4]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eB8NaQZ21742 for ; Fri, 8 Dec 2000 18:36:26 -0500 (EST) (envelope-from jburton@scw.org) Received: from olympus.scw.org (209-9-156-98.sdsl.cais.net [209.9.156.98]) by thor.tht.net (8.9.3/8.9.3) with ESMTP id TAA17584 for ; Fri, 8 Dec 2000 19:13:52 GMT (envelope-from jburton@scw.org) Received: from hades (eos.scw.org [209.9.156.112]) by olympus.scw.org (8.10.1/8.10.1) with ESMTP id eB8NCfg11600; Fri, 8 Dec 2000 18:12:41 -0500 From: "Joel Burton" Organization: Support Center of Washington To: "W. van den Akker" Date: Fri, 8 Dec 2000 18:12:28 -0500 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: How to... CC: pgsql-sql@postgresql.org Message-ID: <3A31248C.3734.177F009@localhost> In-reply-to: <004401c06166$66bf1090$0500020a@wilsoft.nl> X-mailer: Pegasus Mail for Win32 (v3.12c) X-Archive-Number: 200012/65 X-Sequence-Number: 396 > Hi, > > I'am wondering if it is possible to retrieve the last added > record of a table? > I don't think there is a default SQl-query to do so. Is there > a PostgreSQL way? What is it you want to do? If you want to find out what auto- generated ID will be or was inserted, you can use a sequence function, like currval() on the sequence. If you're just working in psql, you're shown the OID of insert as it happens. You could SELECT ... WHERE oid=xxxx to get the record back. Some interfaces (like DBD::Pg) provide functions to get this oid, so you could get the record that way. If you don't mean the last insert period, but rather the last insert just to this table, you could add a TIMESTAMP column DEFAULT CURRENT_TIMESTAMP and just select the record w/the latest timestamp. HTH, -- Joel Burton, Director of Information Systems -*- jburton@scw.org Support Center of Washington (www.scw.org)