This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Recent Transaction Records Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Recent Transaction Records" Watch "Recent Transaction Records" New topic
Author

Recent Transaction Records

Mahendran Duraisamy
Greenhorn

Joined: Jun 27, 2001
Posts: 7
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

Joined: Feb 06, 2001
Posts: 358
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.


Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
Mahendran Duraisamy
Greenhorn

Joined: Jun 27, 2001
Posts: 7
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

Joined: Mar 13, 2001
Posts: 276
you can order DESCENDING
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
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

Joined: Jun 27, 2001
Posts: 7
Thank U very much parmeet.
It works.
Regards,
mahendran
 
jQuery in Action, 2nd edition
 
subject: Recent Transaction Records
 
Similar Threads
My JTable is not refreshing.
how to scroll data to view other records
Obtain fresh records from database for next and previous buttons
How to display variant number of record each page based on user's request ?
design database table for survey form