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

SQL Firebird Discussion :

Procedure Stockée et IF


Sujet :

SQL Firebird

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2002
    Messages
    34
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2002
    Messages : 34
    Points : 35
    Points
    35
    Par défaut Procedure Stockée et IF
    Cette procedure fonctionne bien sous IBCONSOLE

    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
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    CREATE PROCEDURE "CDE_TOTAL_XXX"
    (
      "ADH_NU" INTEGER,
      "CDE_NU" INTEGER,
      "MAG_NU" INTEGER,
      "IND_NU" INTEGER
    )
    RETURNS
    (
      "QLV_01" INTEGER,
      "QLV_02" INTEGER,
      "QLV_03" INTEGER,
      "QLV_04" INTEGER,
      "QLV_05" INTEGER,
      "QLV_06" INTEGER,
      "QLV_07" INTEGER,
      "QLV_08" INTEGER,
      "QLV_09" INTEGER,
      "QLV_10" INTEGER,
      "QLV_11" INTEGER,
      "QLV_12" INTEGER,
      "QLV_13" INTEGER
    )
    AS
    	BEGIN
    	     /* Interrogation des livraisons */
    	     FOR SELECT
                     Sum(QLV_01),
                     Sum(QLV_02),
                     Sum(QLV_03),
                     Sum(QLV_04),
                     Sum(QLV_05),
                     Sum(QLV_06),
                     Sum(QLV_07),
                     Sum(QLV_08),
                     Sum(QLV_09),
                     Sum(QLV_10),
                     Sum(QLV_11),
                     Sum(QLV_12),
                     Sum(QLV_13)
    	         FROM CDE_LIV_DET
                     WHERE
    		(ADH_NUMERO = :ADH_NU) And
    		(CDE_NUMERO = :CDE_NU) And
    		(CDE_INDICE = :IND_NU) And
    		(MAG_NUMERO = :MAG_NU)
    	         INTO
                     :QLV_01,
                     :QLV_02,
                     :QLV_03,
                     :QLV_04,
                     :QLV_05,
                     :QLV_06,
                     :QLV_07,
                     :QLV_08,
                     :QLV_09,
                     :QLV_10,
                     :QLV_11,
                     :QLV_12,
                     :QLV_13
                 DO
                 BEGIN
                 SUSPEND;
                 EXIT;
                 END
     
     
    END
     ^
    Je rajoute une ligne

    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
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    CREATE PROCEDURE "CDE_TOTAL_XXX"
    (
      "ADH_NU" INTEGER,
      "CDE_NU" INTEGER,
      "MAG_NU" INTEGER,
      "IND_NU" INTEGER
    )
    RETURNS
    (
      "QLV_01" INTEGER,
      "QLV_02" INTEGER,
      "QLV_03" INTEGER,
      "QLV_04" INTEGER,
      "QLV_05" INTEGER,
      "QLV_06" INTEGER,
      "QLV_07" INTEGER,
      "QLV_08" INTEGER,
      "QLV_09" INTEGER,
      "QLV_10" INTEGER,
      "QLV_11" INTEGER,
      "QLV_12" INTEGER,
      "QLV_13" INTEGER
    )
    AS
    	BEGIN
    	     /* Interrogation des livraisons */
    	     FOR SELECT
                     Sum(QLV_01),
                     Sum(QLV_02),
                     Sum(QLV_03),
                     Sum(QLV_04),
                     Sum(QLV_05),
                     Sum(QLV_06),
                     Sum(QLV_07),
                     Sum(QLV_08),
                     Sum(QLV_09),
                     Sum(QLV_10),
                     Sum(QLV_11),
                     Sum(QLV_12),
                     Sum(QLV_13)
    	         FROM CDE_LIV_DET
                     WHERE
    		(ADH_NUMERO = :ADH_NU) And
    		(CDE_NUMERO = :CDE_NU) And
    		(CDE_INDICE = :IND_NU) And
    		(MAG_NUMERO = :MAG_NU)
    	         INTO
                     :QLV_01,
                     :QLV_02,
                     :QLV_03,
                     :QLV_04,
                     :QLV_05,
                     :QLV_06,
                     :QLV_07,
                     :QLV_08,
                     :QLV_09,
                     :QLV_10,
                     :QLV_11,
                     :QLV_12,
                     :QLV_13
                 DO
                 BEGIN
                 [b]IF (:QLV_01 IS NULL) THEN :QLV_01 =0;[/b]    
                 SUSPEND;
                 EXIT;
                 END
     
     
    END
     ^
    et là erreur

    Dynamic SQL Error
    SQL error code = -104
    Token unknown - line 63, char 38
    :

    Je ne comprend pas pourquoi !!!!

    Merci : : :

    Edité par Barbibulle :

  2. #2
    Membre expert
    Avatar de Barbibulle
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    2 048
    Détails du profil
    Informations personnelles :
    Âge : 54
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 2 048
    Points : 3 342
    Points
    3 342
    Par défaut
    Les : sont à utiliser dans les ordres SQL des procédures stoquées (dans le INTO également)
    Mais dans la PS elle même pas besoin de les mettres donc mettez tout simplement :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    IF (QLV_01 IS NULL) THEN QLV_01 =0;
    Et celà va fonctionner.
    De plus comme votre ordre Select ne renvoit qu'un enregistrement le EXIT est de trop et vous n etes pas obligé d'utiliser FOR :

    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
    54
    55
    56
    57
    58
    59
    60
    61
    CREATE PROCEDURE "CDE_TOTAL_XXX" 
    ( 
      "ADH_NU" INTEGER, 
      "CDE_NU" INTEGER, 
      "MAG_NU" INTEGER, 
      "IND_NU" INTEGER 
    ) 
    RETURNS 
    ( 
      "QLV_01" INTEGER, 
      "QLV_02" INTEGER, 
      "QLV_03" INTEGER, 
      "QLV_04" INTEGER, 
      "QLV_05" INTEGER, 
      "QLV_06" INTEGER, 
      "QLV_07" INTEGER, 
      "QLV_08" INTEGER, 
      "QLV_09" INTEGER, 
      "QLV_10" INTEGER, 
      "QLV_11" INTEGER, 
      "QLV_12" INTEGER, 
      "QLV_13" INTEGER 
    ) 
    AS 
    BEGIN 
      /* Interrogation des livraisons */ 
      SELECT Sum(QLV_01), 
             Sum(QLV_02), 
             Sum(QLV_03), 
             Sum(QLV_04), 
             Sum(QLV_05), 
             Sum(QLV_06), 
             Sum(QLV_07), 
             Sum(QLV_08), 
             Sum(QLV_09), 
             Sum(QLV_10), 
             Sum(QLV_11), 
             Sum(QLV_12), 
             Sum(QLV_13) 
        FROM CDE_LIV_DET 
        WHERE (ADH_NUMERO = :ADH_NU) 
          And (CDE_NUMERO = :CDE_NU) 
          And (CDE_INDICE = :IND_NU) 
          And (MAG_NUMERO = :MAG_NU) 
        INTO :QLV_01, 
             :QLV_02, 
             :QLV_03, 
             :QLV_04, 
             :QLV_05, 
             :QLV_06, 
             :QLV_07, 
             :QLV_08, 
             :QLV_09, 
             :QLV_10, 
             :QLV_11, 
             :QLV_12, 
             :QLV_13;
      IF (QLV_01 IS NULL) THEN QLV_01 =0;
      SUSPEND; 
    END 
     ^

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2002
    Messages
    34
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2002
    Messages : 34
    Points : 35
    Points
    35
    Par défaut Merci Barbibulle
    Merci Barbibulle !!!

    Au fait ou peut t'on trouver des exemples de procedures Interbase !





  4. #4
    Membre actif Avatar de TMuet
    Homme Profil pro
    Responsable de service informatique
    Inscrit en
    Septembre 2003
    Messages
    225
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Responsable de service informatique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Septembre 2003
    Messages : 225
    Points : 288
    Points
    288

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Ecriture d'une procedure stockée XP
    Par WOLO Laurent dans le forum Langage SQL
    Réponses: 2
    Dernier message: 17/07/2003, 13h09
  2. Réponses: 1
    Dernier message: 04/06/2003, 11h48
  3. procedure stockée champ date
    Par tripper.dim dans le forum SQL
    Réponses: 5
    Dernier message: 25/04/2003, 09h47
  4. Appel a une procedure stockée en vba
    Par The_Nail dans le forum VBA Access
    Réponses: 36
    Dernier message: 01/04/2003, 16h44
  5. procedure stockée dans un dbbatch
    Par pram dans le forum XMLRAD
    Réponses: 4
    Dernier message: 07/02/2003, 16h35

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