last entry

Started by mixoover 23 years ago3 messagesgeneral
Jump to latest
#1mixo
mixo@beth.uniforum.org.za

Is it possible to identify the last entry that has been just insterted
into a table?

#2Ian Harding
ianh@tpchd.org
In reply to: mixo (#1)
Re: last entry

If you mean the value of the primary key (if a sequence is used) the way to do that is (in the same connection) to issue a "select currval('sequencename')" which will return the last used value of that sequence within the current connection.

If you mean the OID, there is a way to do that too, but I don't use them for ID so I don't know.

Ian A. Harding
Programmer/Analyst II
Tacoma-Pierce County Health Department
(253) 798-3549
mailto: iharding@tpchd.org

We have only two things to worry about: That things will never get
back to normal, and that they already have.

mixo <mixo@beth.uniforum.org.za> 08/16/02 01:33AM >>>

Is it possible to identify the last entry that has been just insterted
into a table?

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

#3omid omoomi
oomoomi@hotmail.com
In reply to: Ian Harding (#2)
Re: last entry

select * from yourtable order by oid desc limit 1;

From: mixo <mixo@beth.uniforum.org.za>
To: pgsql-general@postgresql.org
Subject: [GENERAL] last entry
Date: Fri, 16 Aug 2002 10:33:03 +0200

Is it possible to identify the last entry that has been just insterted into
a table?

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

_________________________________________________________________
Join the world�s largest e-mail service with MSN Hotmail.
http://www.hotmail.com