Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Result Set Sorting

 
RAJEEV BAHL
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had gone through documentation on Result set and unable to find the way to sort Result Set. If I get a Result Set from Tabel with Primary Key in MS Access will I get Result Set Sorted on Primary Key ascending order?
 
Daniel Dunleavy
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you not doing an order by in your select statement?
Dan
 
Brian Boyd
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also am interested in a solution to this problem.
"Why are you not doing an order by in your select statement?"
I do order the result set in the select statement. But I need to reorder the result set on a different column after processing the result set.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally, I create a 2D vector as resultset representation.
Then do the necessary order by as per the user input. Say intial order by was with Date, user asked by Name, manipulate the vector to do the order.
Hope this gives some input!
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Brian Boyd:
I also am interested in a solution to this problem.
"Why are you not doing an order by in your select statement?"
I do order the result set in the select statement. But I need to reorder the result set on a different column after processing the result set.

After moving the result set values to an array or vector, then sorting, it seems like it would be faster and easier just to requery the database a second time and sort the ResultSet in the order that you need.
Jamie

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Every database connection is much costlier than a in-memory vector sorting. Literature says almost 50 times.
 
RAJEEV BAHL
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Database connection can be maintained for group of calls ie till one call closeConnection.
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gadzooks! That's crazy talk. If I had to make a connection for every query I made, I'd still be waiting for my fall 2000 audit to finish! I wasn't expecting you to reconnect after every query!
Assumption: One connection per session or thereabouts.
Jamie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic