PL SQL afficher une liste

freygeo Messages postés 24 Statut Membre -  
 Utilisateur anonyme -
Bonjour le forum

j'ai deux tables :
PILOTE avec la variable NoSecu, nom
DEPART avec la variable Novol, NoPil

Je dois afficher la liste de tout les pilotes (en affichant leur nom) et la somme des vols pour chaque pilote...

voici le code que j'utilise mais rien ne s'affiche...

SET ECHO ON
SET SERVER OUTPUT ON

BEGIN

SELECT NoSecu, nom, count(NoVol) as Nombre_Vols
FROM pilot, depart
WHERE NoSecu=NoPil

END;
/

d'avance merci de votre aide =)

1 réponse

  1. Utilisateur anonyme
     
    Bonjour,

    La structure devrait ressembler à quelques choses comme ça :

    N.B. Pas testé !

    SET ECHO ON     
    SET SERVER OUTPUT ON    
    
    DECLARE    
    
     --Nom Variable    NomTable.NomChamps%TYPE
    
     v_No_Secu     NomTable.NoSecu%TYPE;  
     v_Nom           NomTable.Nom%TYPE;   
     v_count         NomTable.Nombre_Vols%TYPE;    
            
        CURSOR MEMBRE IS    
         SELECT NoSecu, nom, count(NoVol) as Nombre_Vols     
         FROM pilot, depart     
         WHERE NoSecu=NoPil;    
    
    BEGIN     
    
     OPEN MEMBRE;    
            
        LOOP    
         FETCH MEMBRE INTO v_No_Secu, v_Nom, v_Count;    
             EXIT WHEN MEMBRE%NOTFOUND    
                    
      -- Calcul et traitement    
            DBMS_OUTPUT.PUT_LINE('v_No_Secu = ' || v_No_Secu ); 
            DBMS_OUTPUT.PUT_LINE('v_Nom = ' || v_Nom); 
            DBMS_OUTPUT.PUT_LINE('v_Count = ' || v_Count);            
                
        END LOOP;    
            
        CLOSE MEMBRE;    
            
        --  EXCEPTION    
    
     /* Gestion des exceptitions */    
            
    END;   
    /    
    


    Cdt

    Lupin
    0