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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
ACCEPT mode CHAR PROMPT 'Voulez-vous travailler sur toute l''année ou pour un mois précis (O,o/N,n) ';
ACCEPT age char PROMPT 'Saisisser l''age de la personne > : ';
ACCEPT date_saisie DATE FORMAT 'DD/MM/YYYY' PROMPT 'Entrer la période de recherche au format JJ/MM/YYYY ou taper sur entré si recherche sur l''année : ';
--@entete_portrait.sql &2
set serveroutput on
set echo on
declare
date_travail date;
requete1 varchar(1024) ;
requete2 varchar(1024) ;
procedure F_TRACE ( PC$Message in VARCHAR2, PC$Output in VARCHAR2 DEFAULT 'E' )
Is
PRAGMA AUTONOMOUS_TRANSACTION ;
LC$Chaine Varchar2(4000) ;
LN$Tranches PLS_INTEGER ;
LN$Reste PLS_INTEGER ;
LN$Pos PLS_INTEGER := 1 ;
LN$Inc PLS_INTEGER ;
Begin
If PC$Output = 'E' Then
-- Sortie sur ecran (DBMS_OUTPUT) --
LN$Inc := 255 ;
LN$Tranches := Length( PC$Message ) / LN$Inc ;
LN$Reste := MOD( Length( PC$Message ), LN$Inc ) ;
If LN$Reste > 0 Then LN$Tranches := LN$Tranches + 1 ; End if ;
-- Sortie --
For i in 1..LN$Tranches Loop
LC$Chaine := Substr( PC$Message, LN$Pos, LN$Inc ) ;
DBMS_OUTPUT.PUT_LINE( LC$Chaine ) ;
LN$Pos := LN$Pos + LN$Inc ;
End loop ;
Else
-- Sortie sur table (INSERT) --
LN$Inc := 4000 ;
LN$Tranches := Length( PC$Message ) / LN$Inc ;
LN$Reste := MOD( Length( PC$Message ), LN$Inc ) ;
If LN$Reste > 0 Then LN$Tranches := LN$Tranches + 1 ; End if ;
/* -- Sortie --
For i in 1..LN$Tranches Loop
LC$Chaine := Substr( PC$Message, LN$Pos, LN$Inc ) ;
Insert into TRACE (LIGNE) Values ( LC$Chaine ) ;
Commit ;
LN$Pos := LN$Pos + LN$Inc ;
End loop ;
*/
End if ;
End F_TRACE;
begin
if ( '&mode' in ('O','o') ) then
date_travail := sysdate;
dbms_output.put_line('Date travail courante: ' ||to_char(date_travail,'DD/MM/YYYY'));
else
date_travail := to_date ('&date_saisie','DD/MM/YYYY');
dbms_output.put_line('Date travail saisie : ' ||to_char(date_travail,'DD/MM/YYYY'));
end if;
requete1 := '
SELECT nat.idf_agent MATRICULE ,
his.nom_usuel || '' '' || his.Nom_prenom NOM_PRENOM, '
||to_number(to_char(date_travail,'YYYY'),'9999')||'-to_number(to_char(ide.dat_naissance,''YYYY'')) AGE,
to_char(ide.dat_naissance,''DD/MM/YYYY'') DATE_NAISSANCE
FROM OG.IDENT ide,
OG.IDENT_HIS his,
RH.AGTNAT nat
WHERE ide.ident_id = his.ident_id
AND nat.ident_id = his.ident_id
AND cod_gestion in (''0'',''2'')
and idf_agent in (select distinct idf_agent from agtpai)
AND nat.cod_coll =''toto''
AND '||to_number( to_char(date_travail,'YYYY' ),'9999' ) || ' - to_number(to_char(ide.dat_naissance,''YYYY'')) = 65
AND to_date(to_char(his.dat_debut,''DD/MM/YYYY''),''DD/MM/YYYY'') <=' ||date_travail||
' AND to_date(to_char(his.dat_fin,''DD/MM/YYYY''),''DD/MM/YYYY'') > ' ||date_travail||'
ORDER BY MATRICULE ';
requete2 := '
SELECT nat.idf_agent MATRICULE ,
his.nom_usuel || '' '' || his.Nom_prenom NOM_PRENOM,
to_char(sysdate,''YYYY'')-to_char(ide.dat_naissance,''YYYY'') AGE,
to_char(ide.dat_naissance,''DD/MM/YYYY'') DATE_NAISSANCE
FROM OG.IDENT ide,
OG.IDENT_HIS his,
RH.AGTNAT nat
WHERE ide.ident_id = his.ident_id
AND nat.ident_id = his.ident_id
AND cod_gestion in (''0'',''2'')
and idf_agent in (select distinct idf_agent from agtpai)
AND nat.cod_coll =''toto''
AND to_number( to_char( '|| date_travail|| ',''YYYY'' ) ) - to_number(to_char(ide.dat_naissance,''YYYY''))= 65
AND to_number(to_char('||date_travail||',''MM'')) = to_number(to_char(ide.dat_naissance,''MM''))
AND to_date(to_char(his.dat_debut,''DD/MM/YYYY''),''DD/MM/YYYY'') <= '||date_travail||'
AND to_date(to_char(his.dat_fin,''DD/MM/YYYY''),''DD/MM/YYYY'') > '||date_travail||'
ORDER BY MATRICULE ';
if ( '&mode' in ('O','o') ) then
dbms_output.put_line ('On passe dans la requete 1');
--dbms_output.put_line ('La requete est la suivante:'||requete1);
f_trace (requete1);
execute immediate requete1 ;
else
dbms_output.put_line ('On passe dans la requete 2');
execute immediate requete2;
end if;
end;
/ |
Partager