Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> [Maybe OT]Sorting VARCHAR with letters and numbers

[Maybe OT]Sorting VARCHAR with letters and numbers

From: Daniel Cloutier <danielcloutier_at_web.de>
Date: 31 Jan 2002 11:33:24 +0100
Message-ID: <3c591d74@netnews.web.de>


Hello everyone!

I have a slight problem which I donīt seem to understand why it is not working. I have a table which contains on column of type VARCHAR2. This column is filled with ID 'strings'. These strings are mixed, meaning some are numbers only and others are alphanumeric values or both (e.g. '123456', 'A123456' or 'ABCDEFG')

Now, I needed to fill a listbox which shows the 20 successors and predecessors of a selected value. For the predecessors I used something like this:

SELECT IDNUMBER FROM (SELECT IDNUMBER FROM MYTABLE WHERE FZNUM <='SELECTEDID' ORDER BY IDNUMBER DESC) WHERE ROWNUM<=20

This seems to work and the result looks ok.

Then for successors I simply did this:

SELECT IDNUMBER FROM MYTABLE WHERE IDNUMER >='SELECTEDID' AND ROWNUM<=20;

The strange thing is, that this works, when I type this string into SQL-Plus and execute it. As soon, as I use the Java programm, it does not work anymore and I get completely wrong unsorted results. Is there something I miss here or do I have to consider something in sorting thos type of data generally?

I īm not sure, if this is a Java problem or an Oracle one. So this is why I marked it 'OT'.

Any hint would be verry appreciated.

Thanks!
Joerg

-- 
__________________________________________________________
News suchen, lesen, schreiben mit http://newsgroups.web.de
Received on Thu Jan 31 2002 - 04:33:24 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US