[linux] Re: Last record in table
remco-blaakmeer na quicknet.nl
Pátek Leden 28 21:21:19 CET 2000
On Fri, 28 Jan 2000, Pedro Fradique da Silva wrote:
> Hi all,
> After inserting a record I'm trying to retrieve the last record in a
> table(that would be the one I just inserted), so I can use one of its
> values in another insert.
> Is there a simple way to do it?
> How can I lock the database so that nothing is done between that first
> insert and the select?
There is no such thing as the 'last record' in a table. Records are not
stored in any particular order. There is no way of retrieving the 'last'
record unless you provide a mechanism for it. One way of doing this, is to
use a DATE column that gets the value of sysdate when the record is
inserted. But that only gives you a granularity of one second, so it won't
be accurate on tables where many records are entered simultaneously.
But why don't you just keep the values of the inserted record where they
came from? If you use some kind of application to insert the records, this
application will know what is inserted. You can get the values from the
If you want to immediately insert a record into another table for every
inserted record, you can also use a database trigger.
rd1936: 7:50pm up 20 days, 30 min, 8 users, load average: 1.10, 1.26, 1.37
Don't forget! Abstracts are due January 25th 2000. Act now and make your
reservations for ODTUG 2000 -- the best conference of the new century! See
the website at http://www.odtug.com for full details.
Author: Remco Blaakmeer
INET: remco-blaakmeer na quicknet.nl
Fat City Network Services -- (619) 538-5051 FAX: (619) 538-5051
San Diego, California -- Public Internet access / Mailing Lists
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru na fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-LINUX-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
Další informace o konferenci linux