vendredi 25 janvier 2013

Oracle : order by, different results [problem]


When you execute a SELECT .... ORDER BY query from a sql client (like SQuirreL), you may have a result with an order that is not the same when you execute your query with another sql client or inside your Java application.

It's depending on some locale parameters (country and language) on the client side.

For a Java application, you can update your locale by adding parameters to your jvm. 
For example : -Duser.country=en -Duser.language=en

There are more solutions here (adding a NLSSORT() to your ORDER BY clause, etc...).

FYI, you can check the NLS_LANGUAGE and the NLS_SORT on the Oracle server side :

Query:
select parameter,value from NLS_DATABASE_PARAMETERS where parameter in('NLS_LANGUAGE','NLS_SORT');

Result:
NLS_LANGUAGE AMERICAN
NLS_SORT BINARY


Source : http://stackoverflow.com/questions/8818201/oracle-order-by-different

Aucun commentaire:

Categories