Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Partial Result Sets

 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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).
 
Vinod John
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • 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 ]
 
Rudy Dakota
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic