Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

o/*--Question 1--*/

create or replace procedure Augmente10


is

begin

UPDATE pilote set SALAIRE=SALAIRE*1.1 where SALAIRE=(select MIN(SALAIRE) from


pilote);

end;
/*--QUESTION 2--*/
create or replace procedure Delete_vol(v_num PILOTE.PLNUM%type)
is
nbS Number(3);

begin

delete from VOL where PLNUM = v_num;


if SQL%notfound then
raise_application_erreur(-20115,'pas de vol pour ce pilote');
else
nbS := SQL%ROWCOUNT;
DBMS_OUTPUT.PUT_LINE(nbS||' enregistrements affectés');
end if;
end;
/*--Question 3--*/
create table TAB_CAP ( noms varchar2(100),capacites varchar2(50));
create or replace procedure Inserer_IN_TAB_CAP (Nbav number )
is
v_capacite AVION.CAPACITE%TYPE;
v_Nom AVION.AVNOM%TYPE;

cursor top_CAPACITE is
select AVNOM,CAPACITE from AVION
order by CAPACITE desc;
begin
open top_CAPACITE;
loop
fetch top_CAPACITE into v_Nom,v_capacite;
Exit When top_CAPACITE%NOTFOUND OR top_CAPACITE%ROWCOUNT>Nbav;
insert into TAB_CAP(noms,capacites) values(v_Nom,v_capacite);
end loop;
close top_CAPACITE;
end;

/*--QUESTION 4--*/
create table AVION_VOL(Results varchar2(100));

create or replace procedure In_AVION_VOL


is
v_AVNUM AVION.AVNUM%TYPE;
v_VOLNUM VOL.VOLNUM%TYPE;
v_AVNOM AVION.AVNOM%TYPE;
cursor Avion_c is
select AVNUM ,AVNOM from AVION;

cursor VOL_c(v_vol NUMBER) is : numero de l'avion


select VOLNUM from VOL
where AVNUM= v_vol;
begin

open Avion_c;
loop
fetch Avion_c into v_AVNUM,v_AVNOM ;
Exit When Avion_c%NOTFOUND;
open VOL_c(v_AVNUM);
loop
fetch VOL_c into v_VOLNUM;
Exit When VOL_c%NOTFOUND;
insert into AVION_VOL(Results) values(v_AVNOM||'-
avion a le vol numero-'||to_char(v_VOLNUM) );
end loop;
close VOL_c;
end loop;
close Avion_c;

end;
AUTRE solution
for c in Avion_c
loop
for c1 in VOL_c(c.AVNUM)
loop
insert into AVION_VOL(Results) values(c.AVNOM||'-avion a le vol numero-'||
to_char(c1.VOLNUM) );
END loop;
END loop;
end;

/*--Question 5--*/
create or replace procedure NB_Pilote
is
v_nb_pilote NUMBER(10);
ex exception;

begin

select count(*) into v_nb_pilote


from pilote
where PLNOM like 'H%'
or PLNOM like 'R%';
if v_nb_pilote = 0 then
raise ex;
else
DBMS_OUTPUT.PUT_LINE('le nombre de pilotes satisfaisant la condition
est :'||v_nb_pilote);
end if;
EXCEPTION

When ex Then
DBMS_OUTPUT.PUT_LINE('Il y''a aucun pilote satisfaisant la
condition');
When others Then
DBMS_OUTPUT.PUT_LINE('Une menace est detecter :p hhhhhhhh !!');
end;
/*--QUESTION 6--*/
create table Historique_Salaire (PLNUM Number(10), Anc_sal Number(7,2), Nouv_sal
Number(7,2), Date_Modif Date) ;
create or REPLACE TRIGGER historique
is
after update of Salaire
on PILOTE
for each row
BEGIN
insert into Historique_Salaire(PLNUM,Anc_sal,Nouv_sal,Date_Modif) values
(:old.PLNUM,:old.SALAIRE,:new.SALAIRE,sysDate);

end;

You might also like