problem with sorting order in result set

Hi,

i am using jdbc

[b]and my query is

String sql="select empname from emp order by lower(empname) where userid=?";

pst = con.prepareStatement(sql);

pst.setString(1,userId);

rs = pst.executeQuery();[/b]in oracle side the results are in sorted order

by where in java console they are not comming in sorted order.

can any one help how to get result set in exact sorted order.

with regards

ss

[486 byte] By [shannua] at [2007-11-27 11:05:40]
# 1

This has nothing to due with JSF. It really doesn't have anything to do with Java either. This is a basic SQL question. I suggest you find a tutorial on SQL or a beginners SQL forum.

RaymondDeCampoa at 2007-7-29 13:10:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

yes i know this in not releated to jsf but it is related to java

you are not properly understand my question.

when i am firing this query from java jdbc

String sql="select empname from emp order by lower(empname) where userid=?";

pst = con.prepareStatement(sql);

pst.setString(1,userId);

rs = pst.executeQuery();i

in java the result set which i am getting in not order how actually the results are generated in oracle.

means

in oracle side

empname

a

a

ab

b

c

and in java result set

i am getting is

ab

a

c

b

a

with regards

ss

shannua at 2007-7-29 13:10:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Put the WHERE-Part first and THEN the "ORDER BY"-part

String sql="SELECT empname FROM emp WHERE userid=? ORDER BY lower(empname) ";

normaly you have:

SELECT ... FROM ... WHERE ... ORDER BY ... GROUP BY ... HAVING ...

Reddingoa at 2007-7-29 13:10:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

> yes i know this in not releated to jsf but it is

> related to java

> you are not properly understand my question.

Yes, I do properly understand the question and I know the answer. It has nothing to do with Java and everything to do with SQL.

RaymondDeCampoa at 2007-7-29 13:10:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...