Order by : tri différent avec jdbc et sqlplus dans Oracle!!!

szam69 Messages postés 3 Date d'inscription mercredi 12 mai 2004 Statut Membre Dernière intervention 12 mai 2004 - 12 mai 2004 à 11:57
cs_tds Messages postés 351 Date d'inscription mercredi 21 janvier 2004 Statut Membre Dernière intervention 9 décembre 2004 - 14 mai 2004 à 08:54
Bonjour, j'ai un gros problème, je ne comprend pas : j'exécute une requete dans java (avec jdbc oracle) et le tris n'est pas du tout le même. C'est incompréhensible...

la requète :
select g.nom_signal,c11.nom_sous_ens,ds11.location,ds1.location,b1.nom_broch,ds1.bcncon,c21.nom_sous_ens,ds21.location,ds2.location,b2.nom_broch,ds2.bcncon,'_id_functions',sig.torsade_avec,'_notes','_etat','_code_ata2',c1.nom_connect,c2.nom_connect from connec c1,connec c2,connec c11,connec c21,broche b1,broche b2,sigele sig, dns_connec ds1,dns_connec ds2,dns_connec ds11,dns_connec ds21,sousen so1 where c1.id_connec = b1.id_connec and b1.id_broche != b2.id_broche and c2.id_connec = b2.id_connec and ((b1.id_sigele = sig.id_sigele and (b2.id_sigele = b1.id_sigele or b2.id_sigele = sig.torsade_avec)) or (b2.id_sigele = sig.id_sigele and (b2.id_sigele = b1.id_sigele or b1.id_sigele = sig.torsade_avec))) and b1.id_connec = ds1.id_connec and ds1.id_mirror = c11.id_connec and ds1.id_mirror = ds11.id_connec and b2.id_connec = ds2.id_connec and ds2.id_mirror = c21.id_connec and ds2.id_mirror = ds21.id_connec and c1.nom_sous_ens = c2.nom_sous_ens and c11.nom_sous_ens = so1.nom_sous_ens and c1.nom_sous_ens = '100W01' order by so1.nom_produit,c21.nom_sous_ens,ds1.location,b1.nom_broch,ds2.location,b2.nom_broch

elle est un peu longue je sais ;)

Le résultat sous sqlplus (celui que je veux) :

28V_ALTC_P RELAIS 103J2 103P2 A 99XX CMTAV 182J10 182P10 B 99XX _id_functions null _notes _etat _code_ata2 103P2 182P10 {}
28V_ALTC_R RELAIS 103J2 103P2 D 99XX CMTAV 182J10 182P10 D 99XX _id_functions null _notes _etat _code_ata2 103P2 182P10 {}
CMDCH2_ISOM_P RELAIS 103J2 103P2 PB 99XX CMTAV 182J10 182P10 R 99XX _id_functions null _notes _etat _code_ata2 103P2 182P10 {}
CMDCH1_ISOM_M RELAIS 103J2 103P2 PC 99XX CMTAV 182J10 182P10 J 99XX _id_functions null _notes _etat _code_ata2 103P2 182P10 {}
CMDCH2_ISOM_M RELAIS 103J2 103P2 PD 99XX CMTAV 182J10 182P10 N 99XX _id_functions null _notes _etat _code_ata2 103P2 182P10 {}
TEMPRECH_RELAIS_P RELAIS 103J2 103P2 S 99XX CMTAV 182J10 182P10 U 99XX _id_functions null _notes _etat _code_ata2 103P2 182P10 {}
TEMPRECH_RELAIS_M RELAIS 103J2 103P2 V 99XX CMTAV 182J10 182P10 S 99XX _id_functions null _notes _etat _code_ata2 103P2 182P10 {}
CMDCH3_ISOM RELAIS 103J2 103P2 X 99XX CMTAV 182J10 182P10 V 99XX _id_functions null _notes _etat _code_ata2 103P2 182P10 {}
CMDCH1_ISOM_P RELAIS 103J2 103P2 Z 99XX CMTAV 182J10 182P10 L 99XX _id_functions null _notes _etat _code_ata2 103P2 182P10 {}
28V_ALTC_P 130W01 132J2 132P2 09 99XX CMTAV 182J10 182P10 B 99XX _id_functions null _notes _etat _code_ata2 132P2 182P10 {}
28V_ALTC_P 130W01 132J2 132P2 19 99XX CMTAV 182J10 182P10 B 99XX _id_functions null _notes _etat _code_ata2 132P2 182P10 {}
etc...

et le résultat avec jdbc :

28V_ALTC_P RELAIS 103J2 103P2 A 99XX 130W01 132J2 132P2 09 99XX _id_functions null _notes _etat _code_ata2
28V_ALTC_P RELAIS 103J2 103P2 A 99XX 130W01 132J2 132P2 19 99XX _id_functions null _notes _etat _code_ata2
28V_ALTC_P RELAIS 103J2 103P2 A 99XX 130W01 132J2 132P2 22 99XX _id_functions null _notes _etat _code_ata2
CDE_MCS_PRCS_P 130W01 132J2 132P2 01 99XX 130W01 132J2 132P2 03 99XX _id_functions null _notes _etat _code_ata2
CDE_MCS_PRCS_P 130W01 132J2 132P2 01 99XX 130W01 132J2 132P2 05 99XX _id_functions null _notes _etat _code_ata2
CDE_MCS_PRCS_M 130W01 132J2 132P2 02 99XX 130W01 132J2 132P2 04 99XX _id_functions null _notes _etat _code_ata2
CDE_MCS_PRCS_M 130W01 132J2 132P2 02 99XX 130W01 132J2 132P2 06 99XX _id_functions null _notes _etat _code_ata2
CDE_MCS_PRCS_P 130W01 132J2 132P2 03 99XX 130W01 132J2 132P2 01 99XX _id_functions null _notes _etat _code_ata2
CDE_MCS_PRCS_P 130W01 132J2 132P2 03 99XX 130W01 132J2 132P2 05 99XX _id_functions null _notes _etat _code_ata2
CDE_MCS_PRCS_M 130W01 132J2 132P2 04 99XX 130W01 132J2 132P2 02 99XX _id_functions null _notes _etat _code_ata2
CDE_MCS_PRCS_M 130W01 132J2 132P2 04 99XX 130W01 132J2 132P2 06 99XX _id_functions null _notes _etat _code_ata2
CDE_MCS_PRCS_P 130W01 132J2 132P2 05 99XX 130W01 132J2 132P2 01 99XX _id_functions null _notes _etat _code_ata2
CDE_MCS_PRCS_P 130W01 132J2 132P2 05 99XX 130W01 132J2 132P2 03 99XX _id_functions null _notes _etat _code_ata2
CDE_MCS_PRCS_M 130W01 132J2 132P2 06 99XX 130W01 132J2 132P2 02 99XX _id_functions null _notes _etat _code_ata2
CDE_MCS_PRCS_M 130W01 132J2 132P2 06 99XX 130W01 132J2 132P2 04 99XX _id_functions null _notes _etat _code_ata2
28V_ALTC_P 130W01 132J2 132P2 09 99XX 130W01 132J2 132P2 19 99XX _id_functions null _notes _etat _code_ata2
28V_ALTC_P 130W01 132J2 132P2 09 99XX 130W01 132J2 132P2 22 99XX _id_functions null _notes _etat _code_ata2
etc...

3 réponses

szam69 Messages postés 3 Date d'inscription mercredi 12 mai 2004 Statut Membre Dernière intervention 12 mai 2004
12 mai 2004 à 14:21
J'ai trouvé la source du problème mais pas la solution !

C'est à cause de java : je développe une appli en Francais-Anglais, donc je fait un Locale.setDefault(FR) ou ENGL. Or, en fonction de la localité, java tri les éléments avec les numéros en premier pour l'anglais et les numéros après les lettres pour le francais.

Je l'avais déja remarque pour les JTree, mais pour les requetes SQL, je trouve que c'est n'importe quoi !!!!
Personne a une solution pour éviter ces changements dû au au Locale(fr ou eng) ?

En attendant, je fait un
Locale.setDefault(new Locale("fr","FR"));
ma requete
Locale.setDefault(new Locale("en","GB"));
et ca marche, l'ordre est le même que dans sqlplus !
0
szam69 Messages postés 3 Date d'inscription mercredi 12 mai 2004 Statut Membre Dernière intervention 12 mai 2004
12 mai 2004 à 16:11
Encore mieux, dans ma classe de connexion, j'ai crée une méthode qui permet de changer la localité pour la session :
/**
* Change the NLS Language in oracle. It influence the clause order by , or date format for example.
* In French, "order by" sort alpha after numeric
* @param String language "FR" or "EN"
*/
public void changeNLSLanguage(String language) {
NLSLocale nlslocale = NLSLocale.getInstance();
Locale loc;
if (language.equalsIgnoreCase("FR")) {
loc = new Locale("fr", "FR");
} else {
loc = new Locale("en", "GB");
}String alter_language "ALTER SESSION SET NLS_LANGUAGE '" + nlslocale.getNLSLanguage(loc) + "'";String alter_territory "ALTER SESSION SET NLS_TERRITORY '" + nlslocale.getNLSTerritory(loc) + "'";
System.out.println("DEBUG : "+alter_language+"\n"+alter_territory);
// alter NLS_Language in this session
execQueryToResultSet(alter_language, true);
execQueryToResultSet(alter_territory, true);
}
0
cs_tds Messages postés 351 Date d'inscription mercredi 21 janvier 2004 Statut Membre Dernière intervention 9 décembre 2004
14 mai 2004 à 08:54
Mmmmh, intérêssant à savoir. Quelle idée de lier les tris au langage...

B@ron {EU.BELGIUM}
0
Rejoignez-nous