• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Recent Transaction Records

 
Mahendran Duraisamy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is there a way to pull the recent 20 records from Oracle Database table without using any field in particular.
My table contains fields like ,
session_id - looks like random number generator
timestamp with only date not the time.
The table is logged by some application in the background whenever a transaction is occurred.
For example , in any web server if u view the log file thru the administrative screen/console u have this option like display the recent 20 records or display the last first. That kind of thing.
but i don't know how to write SQL query to display the recently inserted 20 records at any point of time.

Thanks and Regards,
mahendran
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I don't think there is a direct method to retreive the last 20 records. You will either have to add a timestamp field in your table or if thats not possible add another table in your database which will keep track of the records inserted in the reqd. table.
 
Mahendran Duraisamy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Parmeet,
Thanks for ur reply.
I was talking to one of our developer who is logging that table which has date field. He told me to write a query to display both the date and time from "date" field.
It appears like this "MM-DD-YYYY:HH:MM:SS" will u pls. tell me how to sort this particular column to get the recent 20 records at any point of time.
Thanks,
mahendran
 
Daniel Dunleavy
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can order DESCENDING
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can write a query using ORDERBY clause on the date column. Then from the resultset you can retrieve 20 records using a for loop.
 
Mahendran Duraisamy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank U very much parmeet.
It works.
Regards,
mahendran
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic