Prev: Intermittent JDBC connection
Next: change ISO8859-1 to GB2312 to UTF-8 to EBCDIC to Big5 to ...
From: tomo on 25 May 2010 06:13 I have three elements in list "a", "1","b". Java sort will give me 1,a,b, but when i do order by column_name asc in DB, oracle gives me a,b,1 . How can I write SQL query to get string sorted just like the way java does? Thanks __________ Information from ESET NOD32 Antivirus, version of virus signature database 5143 (20100525) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com
From: Lew on 25 May 2010 07:34 On 05/25/2010 06:13 AM, tomo wrote: > I have three elements in list "a", "1","b". Java sort will give me 1,a,b, > but when i [sic] do order by column_name asc in DB, oracle [sic] gives me a,b,1 . How > can I write SQL query to get string sorted just like the way java does? Please provide an SSCCE http://sscce.org/ What is your Java code? What is your SQL (both DDL and query)? What is the locale for both Java and the database? You have asked, "I have a problem. What is the solution?" There isn't enough detail to know, but the questions I asked are what you should ask yourself, and the answers are what make a solution possible. -- Lew
From: Tom Anderson on 25 May 2010 08:23 On Tue, 25 May 2010, tomo wrote: > I have three elements in list "a", "1","b". Java sort will give me > 1,a,b, but when i do order by column_name asc in DB, oracle gives me > a,b,1 . How can I write SQL query to get string sorted just like the way > java does? This isn't a java question, it's an Oracle question. Take it to an Oracle group. tom -- Vive la chimie, en particulier, et la connaissance en general. -- Herve This
From: Jim Janney on 25 May 2010 13:50 "tomo" <tomo(a)tomo.net> writes: > I have three elements in list "a", "1","b". Java sort will give me 1,a,b, > but when i do order by column_name asc in DB, oracle gives me a,b,1 . How > can I write SQL query to get string sorted just like the way java does? > Thanks That's the behaviour you get when the data is encoded in EBCDIC. Assuming that's the problem, it may be possible to write something like select * from data order by ASCII_STR(column_name) where ASCII_STR is a SQL function that converts the data to ASCII. You'd have to check the Oracle docs to see if they have anything like that. Problems are that you lose portability, if you care about that, and that the database can't use an index in the ORDER BY so it has to sort the result set in memory before sending it to you. Sorting in Java may be faster. -- Jim Janney
From: jaap on 25 May 2010 14:33 Op 25-05-10 12:13, schreef tomo: > I have three elements in list "a", "1","b". Java sort will give me 1,a,b, > but when i do order by column_name asc in DB, oracle gives me a,b,1 . How > can I write SQL query to get string sorted just like the way java does? > Thanks > A Java List is not sorted, it keeps the order in which you insert the elements. A database has no defined order, that's why you use the "order by" clause. If the order is important, you can use an extra field with a number and use that field in the "order by". Succes, Jaap
|
Pages: 1 Prev: Intermittent JDBC connection Next: change ISO8859-1 to GB2312 to UTF-8 to EBCDIC to Big5 to ... |