> 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)