• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

to retrive the last row

 
bakiyalakshmi dhanraj
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
how to retrieve the last added row,without using query.there is one keyword. can any one tel me the keyword for that one.
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use Last() method to moves your cursor to the last row in the ResultSet object. see Java Doc here.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4028
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you want any records other than the last? If you just want the last record I'd reorganize the query so that it selects only a single record.
 
Jan Cumps
Bartender
Posts: 2602
13
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Muhammad Saifuddin:
you can use Last() method to moves your cursor to the last row in the ResultSet object. see Java Doc here.
The last row in a Resultset object might not be the last added row.
The requestor will first have to define the criterea that determine the last added row.
Using the highest auto-generated record ID might not help, because several databases pool sequence IDs, and do not guarantee that these IDs are used in order.
 
Kevin Smither
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just write the query appropriately depending on your database design, although why you would want to do this is beyond me...it's better to use exact criteria rather than being arbitrary such as "last updated row"
[ March 26, 2008: Message edited by: Kevin Smither ]
 
bakiyalakshmi dhanraj
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In one interview there ask this question,that's why i ask u
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
378
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by bakiyalakshmi dhanraj:
In one interview there ask this question,that's why i ask u

Sometimes an interviewer wants to see how you think rather than an exact answer. It could be they were looking to see if you would suggest a better design.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic