• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Recent Transaction Records

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can order DESCENDING
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank U very much parmeet.
It works.
Regards,
mahendran
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic