• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Partial Result Sets

 
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was wondering if its possible to only retrieve a partial result set from a query. If I have a large result but only wish to look at the first 25 OR if I was wishing to check out 26 to 50. Can this be done? I'm using db2 with WebSphere 4.0.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some databases allow you to slice the result set in this way, but there's not a standard syntax. PostgreSQL for example, supports the LIMIT and OFFSET keywords. MySQL also allows this with (I believe) two values on the LIMIT keyword. I'm not sure if DB2 even has this capability; you'd need to look into the docs (or someone here with DB2 knowledge might chime in with info).
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think JDBC internally has this feature, I may be wrong, there is some way to set the fetch size in the JDBC which restrict the number of rows retrieved in one fetch by default it is 20 (I think).
Can some on confirm this.
[ April 19, 2004: Message edited by: Vinod John ]
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vinod,
You 're both right and wrong. What you describe is how the fetch size is supposed to work. But! If you were a driver builder, you are under no obligation to build your driver like that. The fetch size has no more status than a suggestion to the implementor. There is every freedom not to implement it and still maintain that you build a JDBC driver
For us programmers this simply means we can never trust on a driver to implement the fetch size if we haven't somehow checked. And even then, this works behind the scenes, so you 'd better be very sure the driver doesn't do some sort of pre-fetching as well
Good riding,
Rudy.
 
reply
    Bookmark Topic Watch Topic
  • New Topic