IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

AS/400 Discussion :

Programme en sql sur as400 qui tourne mais


Sujet :

AS/400

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2014
    Messages
    43
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Indre (Centre)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2014
    Messages : 43
    Points : 31
    Points
    31
    Par défaut Programme en sql sur as400 qui tourne mais
    bonjour,

    je suis actuellement sur un programme en sqlrpgle qui tourne mais j'ai l'impression qu'il ne s'arrête jamais. ok j'ai 125000 lignes à updater, mais je dois l'arrêter à chaque fois car je le trouve terriblement long. Je ne vois pas pourquoi.
    si une âme charitable passe sur mon post...
    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
       D  wrkf           DS
         D  itnbr                        15A
         D  safty                        10P 3
         D  fxorq                        10P 3
         D  itnb                         15A
         D  nods                          3S 0
         D  minq                         10S 3
         D  maxq                         10S 3
         D  mulq                         10S 3
         D  shfc                          3S 3
    
          /FREE
    
           exec sql declare c1 cursor for
           select itnbr, safty, fxorq, itnb, nods, minq, maxq, mulq, shfc
            from mery01/itembl, mery01/itmpln
            where itnbr = itnb and ltcod = 'M' for fetch only;
    
           exec sql open c1;
    
           dow (1 = 1);
    
           exec sql fetch next from c1 into :wrkf.itnbr, :wrkf.safty, :wrkf.fxorq,
               :wrkf.itnb, :wrkf.nods, :wrkf.minq, :wrkf.maxq, :wrkf.mulq,
               :wrkf.shfc;
    
    
           exec sql update mrp_parav/mrp_itembl set safty = :wrkf.safty,
           fxorq = :wrkf.fxorq where current of c1;
    
    
           exec sql update mrp_parav/mrp_itmpln set nods = :wrkf.nods,
             minq = :wrkf.minq,maxq = :wrkf.maxq, mulq = :wrkf.mulq,
            shfc = :wrkf.shfc where current of c1;
    
           ENDDO;
    
           exec sql close c1;
    
             *inlr = *on;
          /end-free

    merci

  2. #2
    Membre éprouvé
    Homme Profil pro
    Responsable de service informatique
    Inscrit en
    Octobre 2006
    Messages
    689
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Jura (Franche Comté)

    Informations professionnelles :
    Activité : Responsable de service informatique
    Secteur : Distribution

    Informations forums :
    Inscription : Octobre 2006
    Messages : 689
    Points : 994
    Points
    994
    Par défaut
    Bonjour

    Dow 1 = 1 ?

    Tu penses que ta boucle va se terminer ?

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2014
    Messages
    43
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Indre (Centre)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2014
    Messages : 43
    Points : 31
    Points
    31
    Par défaut
    oui je me suis rendu compte de mon erreur.

    j'ai changé par dow not %eof() mais même résultat

  4. #4
    Membre averti
    Homme Profil pro
    Analyste-Programmeur IBM i, IBM Cognos TM1
    Inscrit en
    Août 2002
    Messages
    234
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Analyste-Programmeur IBM i, IBM Cognos TM1
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2002
    Messages : 234
    Points : 355
    Points
    355
    Par défaut
    bonjour,

    tu dois faire un
    dow sqlCod = *Zero;

    pas de eof ou autre, tu fais du sql.

    Larry57

  5. #5
    Membre averti
    Homme Profil pro
    Analyste-Programmeur IBM i, IBM Cognos TM1
    Inscrit en
    Août 2002
    Messages
    234
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Analyste-Programmeur IBM i, IBM Cognos TM1
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2002
    Messages : 234
    Points : 355
    Points
    355
    Par défaut
    Par ailleurs, pas besoin d'affecter les record de ton fetch si tu as une DS.

  6. #6
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2014
    Messages
    43
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Indre (Centre)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2014
    Messages : 43
    Points : 31
    Points
    31
    Par défaut
    merci pour les conseils.

    voila maintenant mon code :
    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
     /FREE
    
           exec sql declare c1 cursor for
           select * from MRP_PARAV/MRP_L1;
    
           exec sql open c1;
    
           dow sqlcode = 0;
    
           exec sql fetch next from c1 into :wrkf;
    
    
           exec sql update amflib3/itembl set safty = 0,
           fxorq = 0 where current of c1;
    
    
           exec sql update amflib3/itmpln set nods = 0,
             minq = 0, maxq = 0, mulq = 0, shfc = 0
             where current of c1;
    
           ENDDO;
    
           exec sql close c1;
    
           exec sql commit;
    
             *inlr = *on;
          /end-free
    et ça ne fonctionne toujours pas

  7. #7
    Membre habitué
    Profil pro
    Inscrit en
    Août 2008
    Messages
    123
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2008
    Messages : 123
    Points : 146
    Points
    146
    Par défaut
    Bonjour,

    Les update "current of" ne peuvent pas marcher pour 2 raisons :
    1) le curseur est spécifié en lecture seule (for fetch only)
    2) la mise à jour n'est pas possible sur une jointure (même en indiquant " for update of" au lieu du "for fetch only")

    tu dois faire des updates classiques avec un where utilisant les clés retournées par le curseur


    d'autre part vu comme tu as construit ta boucle avec un dowhile, il te faudrait retester le sqlcode après le fetch :

    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
         
    
     /FREE
    
           exec sql declare c1 cursor for
           select * from MRP_PARAV/MRP_L1;
    
           exec sql open c1;
    
           dow sqlcode = 0;      
              exec sql fetch next from c1 into :wrkf;
               if sqlcode = 0;
                    exec sql update amflib3/itembl set safty = 0,
                           fxorq = 0 where......;
    
    
                    exec sql update amflib3/itmpln set nods = 0,
                            minq = 0, maxq = 0, mulq = 0, shfc = 0
                            where .....;
                endif; 
           ENDDO;
    
    etc...
    Bonne soirée

Discussions similaires

  1. Trigger PL/SQL sur AS400
    Par cmorell dans le forum DB2
    Réponses: 4
    Dernier message: 10/03/2015, 08h03
  2. [2008 R2]Job qui tourne mais sql server me dit le contraire
    Par Kropernic dans le forum Administration
    Réponses: 19
    Dernier message: 22/01/2013, 21h48
  3. Ajouter une durée à une date (sql sur as400)
    Par olympio dans le forum Langage SQL
    Réponses: 3
    Dernier message: 02/02/2012, 18h12
  4. Base de données sql sur AS400
    Par rijina dans le forum AS/400
    Réponses: 10
    Dernier message: 03/05/2010, 19h03
  5. Réponses: 19
    Dernier message: 07/11/2003, 08h10

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo