Home » SQL & PL/SQL » SQL & PL/SQL » get last inserted record
get last inserted record [message #247782] Wed, 27 June 2007 03:59 Go to next message
huje
Messages: 7
Registered: May 2007
Location: kolkata
Junior Member

how could i get the last row,consider i have table emp and the last record i inserted is empno 1234 and ename xyz and so on,i dont have logtime,
now i want the last inserted record without using cursor.any one can help me
Re: get last inserted record [message #247787 is a reply to message #247782] Wed, 27 June 2007 04:10 Go to previous messageGo to next message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You can't.
The only thing you can get if the data from the INSERT statement itself with the "returning" clause.

Regards
Michel
Re: get last inserted record [message #247793 is a reply to message #247787] Wed, 27 June 2007 04:20 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
You could turn on AUDIT for the table.


MHE
Re: get last inserted record [message #247813 is a reply to message #247782] Wed, 27 June 2007 05:11 Go to previous messageGo to next message
huje
Messages: 7
Registered: May 2007
Location: kolkata
Junior Member

i already inserted the records,now i could not identify the last few records. is there no way to identify,
Re: get last inserted record [message #247818 is a reply to message #247813] Wed, 27 June 2007 05:18 Go to previous message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Nope...however, if you fiddled with FLASHBACK...but I wouldn't go that road. It's a twisted approach but you could try something like:
SELECT *
FROM yourtable
MINUS
SELECT *
FROM yourtable AS OF TIMESTAMP ( time_just_before_insert )
/


Edit: syntax comes from memory, no guarantee Very Happy
MHE

[Updated on: Wed, 27 June 2007 05:19]

Report message to a moderator

Previous Topic: Union problem
Next Topic: Problem with date format (literal does not match format string)
Goto Forum:
  


Current Time: Tue Dec 06 12:36:15 CST 2016

Total time taken to generate the page: 0.08797 seconds