pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to...
2+ messages / 2 participants
[nested] [flat]
* How to...
@ 2000-12-08 22:30 W. van den Akker <wvdakker@wilsoft.nl>
0 siblings, 1 reply; 2+ messages in thread
From: W. van den Akker @ 2000-12-08 22:30 UTC (permalink / raw)
To: 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?
gr,
Willem
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: How to...
@ 2000-12-08 23:12 Joel Burton <jburton@scw.org>
parent: W. van den Akker <wvdakker@wilsoft.nl>
0 siblings, 0 replies; 2+ messages in thread
From: Joel Burton @ 2000-12-08 23:12 UTC (permalink / raw)
To: W. van den Akker <wvdakker@wilsoft.nl>; +Cc: 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@scw.org
Support Center of Washington (www.scw.org)
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2000-12-08 23:12 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-12-08 22:30 How to... W. van den Akker <wvdakker@wilsoft.nl>
2000-12-08 23:12 ` Joel Burton <jburton@scw.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox