-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfonction.sql
82 lines (57 loc) · 1023 Bytes
/
fonction.sql
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
71
72
73
74
75
76
77
78
79
80
81
82
create
or replace function nbre_emp(y number) return number is i number;
begin
select
count(*) into i
from
Personne
where
NumServP = y;
return i;
end;
/
select
nbre_emp(10)
from
dual;
create
or replace function minimum(a number, b number) return number is begin if (a < b) then return a;
else return minimum(a - b, b);
end if;
end;
/
select
minimum(100, 55)
from
dual;
create
or replace function verif_sal(num in number) return boolean is i number;
salaire number;
numS number;
begin
select
SalaireP,
NumServP into salaire,
numS
from
Personne
where
numP = num;
exception
when NO_DATA_FOUND then return Null;
select
avg(SalaireP) into i
from
Personne
where
NumServP = numS;
if (i < salaire) then return True;
elsif (i > salaire) then return False;
end if;
end;
/ begin if(verif_sal(25)) then dbms_output.put_line('True');
elsif (verif_sal(25) = False) then dbms_output.put_line('False');
else dbms_output.put_line('erreur');
end if;
end;
/