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
|
declare
cursor req_agtnat ( matricule NUMBER) is
select idf_agent from agtnat
where idf_agent = matricule ;
cursor req_agtgrd (matricule NUMBER ) is
select dat_debut,cod_posagt from agtgrd
where idf_agent = matricule
and dat_debut < '01/10/2008'
order by dat_debut desc;
date1 agtgrd.dat_debut%type;
date2 agtgrd.dat_debut%type;
code1 agtgrd.dat_debut%type;
code2 agtgrd.dat_debut%type;
trouve boolean;
begin
open req_agtnat (10);
open req_agtgrd (10);
fetch req_agtgrd into date1,code1;
date2 := date1;
code2 := code1;
trouve := false;
loop
code1 := code2;
date1 := date2;
fetch req_agtgrd into date2,code2;
exit when req_agtgrd%NOTFOUND;
if ( code2 not in ( 'AC','AP','CP','AT','AD','CA','LM','BG','FO','CB','LD','MA','ES','MT','ST')
and code1 in ( 'AC','AP','CP','AT','AD','CA','LM','BG','FO','CB','LD','MA','ES','MT','ST')
)
then
dbms_output.put_line ('la date d''entrée est:'||to_char (date1,'DD-MON-YYYY'));
trouve := true;
end if;
exit when
( code2 not in ( 'AC','AP','CP','AT','AD','CA','LM','BG','FO','CB','LD','MA','ES','MT','ST')
and code1 in ( 'AC','AP','CP','AT','AD','CA','LM','BG','FO','CB','LD','MA','ES','MT','ST')
);
end loop;
if not trouve then
dbms_output.put_line ('la date d''entrée est:'||to_char (date2,'DD-MON-YYYY'));
end if;
end;
/ |
Partager