Re: How to...

From: "Joel Burton" <jburton(at)scw(dot)org>
To: "W(dot) van den Akker" <wvdakker(at)wilsoft(dot)nl>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to...
Date: 2000-12-08 23:12:28
Message-ID: 3A31248C.3734.177F009@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> 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(at)scw(dot)org
Support Center of Washington (www.scw.org)

In response to

  • How to... at 2000-12-08 22:30:00 from W. van den Akker

Browse pgsql-sql by date

  From Date Subject
Next Message Kyle 2000-12-08 23:35:21 Re: "drop constraint trigger" on PostgreSQL
Previous Message W. van den Akker 2000-12-08 22:30:00 How to...