Somme colonne datatable à partir ResultSet
Bonjour,
J'ai un souci avec le calcul de la somme d'une colonne dans un resultset;
j'ai le code suivant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| rs=stmt.executeQuery("SELECT sym,soldf,pmp,vm.get_data(sym,sysdate) RES, (SUM(RES)) RES5 FROM PVMCA WHERE id=4");
}
catch ......
while (rs.next())
{
String tmpSym = rs.getString("sym");
String tmpSoldf = rs.getString("soldf");
f1 = strToFloat(tmpSoldf);
String tmpPmp = rs.getString("pmp");
f2 = strToFloat2(tmpPmp);
tmpVal_c = f2*f1;
String tmpRes = rs.getString("RES");
String tmpRes5 = rs.getString("RES5");
tmpP_pi = strToFloat2(tmpRes);
tmpEval = tmpP_pi*f1;
tmpP_net = tmpEval-tmpVal_c;
tmpP_proc = ((tmpP_pi-f2)/f2)*100; |
En fait dans ma table PVMCA j'ai pas mal d'attributs parmis lequels sym (string), pmp (nombre), et soldf(nombre). Apres j'ai des valeurs calculées tmpVal_c (qui est le soldf*pmp)....et avec le RES je recupere aussi des nombres. Je voulais faire la somme des valeurs recuperées avec la fonction get_data du package vm (qui fonctionne bien). Or quand je rajoute le (SUM(RES)) RES5 j'ai en retour une erreur NULLPOINTEREXCEPTION.
Comment je pourrais faire cette somme dans la requete SQL ? Sinon en Java ?
merci de votre aide