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
|
/* selectionner les interventions */
DELIMITER //
Create procedure selectinter(date_actuelle date,utilisateur integer,future boolean,passee boolean,fait boolean,pause boolean,cours boolean,faire boolean,moi boolean)
BEGIN
declare tut text;
set tut='select * from intervention where ';
if not future then set tut=concat(tut,'date_intervention < @date_actuelle') ;
end if;
if not passee then
if tut!='select * from intervention where ' then set tut=concat(tut,' and ');
end if;
set tut=concat(tut,'date_intervention> @date_actuelle') ;
end if;
if not fait then
if tut!='select * from intervention where ' then set tut=concat(tut,' and ');
end if;
set tut=concat(tut,'id_statut!=1') ;
end if;
if not pause then
if tut!='select * from intervention where ' then set tut=concat(tut,' and ');
end if;
set tut=concat(tut,'id_statut!=2') ;
end if;
if not cours then
if tut!='select * from intervention where ' then set tut=concat(tut,' and ');
end if;
set tut=concat(tut,'id_statut!=3') ;
end if;
if not faire then
if tut!='select * from intervention where ' then set tut=concat(tut,' and ');
end if;
set tut=concat(tut,'id_statut!=4') ;
end if;
if moi then
if tut!='select * from intervention where ' then set tut=concat(tut,' and ');
end if;
set tut=concat(tut,'uti_id_utilisateur=utilisateur') ;
end if;
if tut!='select * from intervention where ' then set tut=concat(tut,' and ');
end if;
set tut=concat(tut,'actif_intervention=1;') ;
SET @tut = `tut`;
PREPARE `tut` FROM @tut;
EXECUTE `tut`;
DEALLOCATE PREPARE `tut`;
end;
//
DELIMITER ; |
Partager