0% found this document useful (0 votes)
26 views6 pages

ORACLE

Uploaded by

aya belmahi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views6 pages

ORACLE

Uploaded by

aya belmahi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

AIT ALI MAROUANE

TP4 : ORACLE SQL*PLUS

Exercice 1 :
set serveroutput ON

DECLARE

a number(2):=1;

b number(2):=2;

c number(2);

BEGIN

dbms_output.put_line('La valeur de a avant la permutation : ' ||a);

dbms_output.put_line('La valeur de b avant la permutation : ' ||b);

c:=a;

a:=b;

b:=c;

dbms_output.put_line('La valeur de a apres la permutation : ' ||a);

dbms_output.put_line('La valeur de b apres la permutation : ' ||b);

END;

/
Exercice 2 :

set serveroutput ON

DECLARE

a number(2):=6;

m number(2);

BEGIN

for i IN 1..10

loop

m := a*i;

dbms_output.put_line('6 x '||i||' = '||m);

end loop;

end;

/
Exercice 3 :

set serveroutput ON
PROMPT 'Veuillez saisir ID de employe :'
accept idfonc number;
DECLARE
idfonc employees.employee_id%TYPE;
salaire employees.salary%TYPE;
BEGIN
idfonc:=&id;
select salary into salaire from employees where employee_id =
idfonc;
dbms_output.put_line('Le salaire de l employee dont ID est
'||idfonc||' est : '||salaire);
END;
/
Exercice 4 :

set serveroutput ON
s111 number;
s122 number;
DECLARE
s111 employees.salary%TYPE;
s122 employees.salary%TYPE;
BEGIN
select salary into s111 from employees where employee_id = 111;
select salary into s122 from employees where employee_id = 122;
UPDATE employees set salary = s111 where employee_id = 122;
UPDATE employees set salary = s122 where employee_id = 111;
END;
/

Exercice 5 :
SET SERVEROUTPUT ON

CREATE TABLE EST (

No NUMBER

);

DECLARE

v_number NUMBER := 1;

BEGIN
WHILE v_number <= 58 LOOP

INSERT INTO EST (No) VALUES (v_number);

v_number := v_number + 1;

END LOOP;

END;

Exercice 6 :
SET SERVEROUTPUT ON

CREATE TABLE VOL (

Numvol VARCHAR2(10),

Heure_départ VARCHAR(10),
Heure_arrivée VARCHAR(10),

Ville_départ VARCHAR2(50),

Ville_arrivée VARCHAR2(50)

);

BEGIN

INSERT INTO VOL (Numvol, Heure_départ, Heure_arrivée, Ville_départ,


Ville_arrivée)

VALUES ('AF110', '21h40', '23h20', 'Belgique', 'Oujda');

END;

You might also like