• 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
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Count of 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 All..
Which is the best method to count the number of records retrieved by an SQL??
Is it to navigate through the RecordSet till the end? or is there a better method ?
Pls suggest
Thanks
Sridhar
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi sridhar,
it depends on ur requirement.To keep a count of the number of records in the middle of the query,
then u can define a integer variable and keep incrementing it after each retreiving each record.
i already posted the code in this forum some time back..
cheers,
Raj
 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Instead of traversing the whole ResultSet and then getting the count, a simpler option is do get the count of the rows using the statement
select count(*) from <table-name>
Hope It Helps.

Mahesh
 
Sridhar M Swaminathan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Raj & Mahesh..
Thanks
reply
    Bookmark Topic Watch Topic
  • New Topic