PL SQL afficher une liste

Fermé
freygeo Messages postés 20 Date d'inscription mardi 26 octobre 2010 Statut Membre Dernière intervention 14 mars 2013 - 24 mars 2011 à 11:33
 Utilisateur anonyme - 24 mars 2011 à 14:08
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

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