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
|
SQL> accept &n prompt 'entrez le nombre des employes les mieux rémunérés:
entrez le nombre des employés les mieux rémunérés:8
SQL> declare
2 cursor c_sal is select ename,sal from emp order by sal desc;
3 salaire emp.sal%type;
4 nom emp.ename%type;
5 nbr number(5) ;
6 begin
7 open c_sal;
8 select count(*) into nbr from emp;
9 for i in 1..&n loop
10 if(&n<>0 and &n<nbr) then
11 fetch c_sal into nom,salaire;
12 insert into top_dogs values(nom,salaire);
13 end if;
14 end loop;
15 close c_sal;
16 end;
17 /
ancien 9 : for i in 1..&n loop
nouveau 9 : for i in 1..7 loop
ancien 10 : if(&n<>0 and &n<nbr) then
nouveau 10 : if(7<>0 and 7<nbr) then
ProcÚdure PL/SQL terminÚe avec succÞs.
SQL> select * from top_dogs;
NAME SALARY
---------- ----------
NAME SALARY
---------- ----------
JAMES
youne
younes
king 5000
FORD 3000
SCOTT 3000
JONES 2975
19 ligne(s) sÚlectionnÚe(s). |
Partager