Salutations à tous,

je vais tenter d'expliquer brièvement ce que je voudrais faire avec ma boucle while.
Je collecter des informations dans ma table "commandes" et "personnel" qui ont notamment les champs suivants : pour "commandes"(MATRAGENT, CODEART,TOTART,...) pour "personnel"(MATRAGENT, SOLDDISPO).
En fonction du code d'article je dois sélectionner le MATRAGENT et le TOTART de ma table "commandes" pour additionner TOTART à SOLDDISPO de ma table personnel en fonction du MATRAGENT correspondant.
La récupération des informations se fait correctement, mais la méthode boucle plusieurs fois sur le même MATRAGENT et récupère le SOLDDISPO du matricule précédent dans la table.
Voici le code source de la méthode qui devrait faire cette opération:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 
private String sqlQuerySupCom,rechArtSup,rechAgtSD,rechAgtSDMaj,totArtSup,soldDispoArtSup,mAAS,mAASRet;
  private int soldDisposupp,totArtSu,matrAgent;
  private RequestDB selArtSup,selAgtArtSup,majSDAgt;
  private void SupToutCmdes(java.awt.event.ActionEvent evt)                              
  {                                  
    // TODO add your handling code here:
    majSDAgt = new RequestDB();
    selArtSup = new RequestDB();
    selAgtArtSup = new RequestDB();
    soldDisposupp = totArtSu=0;
    rechArtSup = "SELECT c.MATRAGENT , c.TOTART , p.SOLDDISPO FROM commandes AS c, personnel AS p LEFT JOIN personnel ON c.MATRAGENT = p.MATRAGENT WHERE CODEART ='"+codArtSuppress.getText()+"'";
    selArtSup.openMyDataBaseConnection();
 
    if (selArtSup.byStatementQuery(rechArtSup) != null)
    {JOptionPane.showMessageDialog(null,"CODEART : "+codArtSuppress.getText());
      while (selArtSup.myGoNext())
      {
        mAAS=selArtSup.myGetString("c.MATRAGENT");
        mAASRet = mAAS.toString();
        totArtSu=Integer.parseInt(selArtSup.myGetString("c.TOTART"));
        soldDispoArtSup=selArtSup.myGetString("p.SOLDDISPO");
        JOptionPane.showMessageDialog(null,"Matricule à updater 1 : "+
                mAASRet+" total de l'article à supprimer : "+totArtSu+" Solde Disponible : "+soldDispoArtSup);
 
        JOptionPane.showMessageDialog(null,"SoldDispoArtSup : "+soldDispoArtSup);
 
        soldDisposupp=(Integer.parseInt(soldDispoArtSup))+totArtSu;
        JOptionPane.showMessageDialog(null, "après addition : "+soldDisposupp+" matricule à updater : "+mAASRet);
 
        rechAgtSDMaj = "UPDATE personnel SET SOLDDISPO='"+soldDisposupp+"' WHERE MATRAGENT ='"+ mAAS +"'";
 
        majSDAgt.openMyDataBaseConnection();
 
        majSDAgt.byStatementUpdate(rechAgtSDMaj);
 
 
        majSDAgt.closeMyDataBaseConnection();
 
        selArtSup.myGoNext();
 
      }
 
      selArtSup.myGoNext();
    }
    else
    {
      JOptionPane.showMessageDialog(null, "Aucune commande 96");
    }
    majSDAgt.closeMyDataBaseConnection();
    selArtSup.closeMyDataBaseConnection();
 
  }

Merci de votre aide car je tourne en rond dessus

Kamikazbe