File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Oracle/OAS and the fly likes Reg:Getting vaues from DB with out sorting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Reg:Getting vaues from DB with out sorting" Watch "Reg:Getting vaues from DB with out sorting" New topic
Author

Reg:Getting vaues from DB with out sorting

kirans reddy
Greenhorn

Joined: May 02, 2009
Posts: 15
Hi,
I need to get data from Employee table like

select * from Employee where id in(8,7,5,9,1);

It is fetching data like

1
5
7
8
9
But i need like
8
7
5
9
1

Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30917
    
158

You have a few choices:
1) Do the queries one at a time
2) Do the "sort" in your desired order after getting back from the database if using JDBC
3) Sort in Oracle. I think you can define a custom function (which returns your desired order) and sort by that. (I did it in a different database, but I think Oracle supports it too.)


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reg:Getting vaues from DB with out sorting