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
| PROCEDURE RecupereDateEffetHistoPostes(param_numsalarie est un entier, param_dateHisto est une Date, param_champ est une chaîne, param_valeurChaine est une chaîne, param_valeurEntier est un entier=0, param_valeurNumerique est un numérique=0) : Date
SI param_valeurChaine="" ET param_valeurEntier=0 ET param_valeurNumerique=0 ALORS
RENVOYER ""
FIN
l_nb est un entier=0
l_retour est une Date=""
l_idreq est une chaîne="RecupereDonnee_nb"
l_req est une chaîne=[
select count(*)
from T_HST_AFFECTATION
where NumSalarie=%1
and (infoEnCours=1 or (InfoEnCours=0 and Departement is not null and Service is not null and unite is not null))
]
l_req=ChaîneConstruit(l_req,param_numsalarie)
SI PAS SQLExec(l_req,l_idreq) ALORS
SQLInfoGene(l_idreq)
Erreur(SQL.MesErreur)
RENVOYER ""
SINON
SQLPremier(l_idreq)
SI PAS SQL.EnDehors ALORS
l_nb=SQLCol(l_idreq,1)
FIN
SQLFerme(l_idreq)
FIN
//si le salarie n'a aucun poste dans l'historique, on renvoit sa date d'embauche
SI l_nb=1 ALORS
RENVOYER gp_DateEmbauche
FIN
l_idreq="Recuperedonnee"
l_req=[
select convert(varchar(8), min(DateHisto), 112) as DateHistorique
from (
select %3, isnull(datehist, getdate()) as DateHisto
from T_HST_AFFECTATION
where NumSalarie=%1
and %3=%4
and (infoEnCours=1 or (InfoEnCours=0 and Departement is not null and Service is not null and unite is not null))
) Vue
where convert(varchar(8), datehisto, 112)<='%2'
]
SI param_valeurChaine<>"" ALORS
l_req=ChaîneConstruit(l_req,param_numsalarie,param_dateHisto,param_champ, "'"+Remplace(param_valeurChaine,"'","''")+"'")
SINON
SI param_valeurEntier<>0 ALORS
l_req=ChaîneConstruit(l_req,param_numsalarie,param_dateHisto,param_champ, param_valeurEntier)
SINON
l_req=ChaîneConstruit(l_req,param_numsalarie,param_dateHisto,param_champ, param_valeurNumerique)
FIN
FIN
SI PAS SQLExec(l_req,l_idreq) ALORS
SQLInfoGene(l_idreq)
Erreur(SQL.MesErreur)
RENVOYER ""
SINON
SQLPremier(l_idreq)
SI PAS SQL.EnDehors ALORS
l_retour=SQLCol(l_idreq,1)
FIN
SQLFerme(l_idreq)
FIN
SI l_retour="" OU PAS DateValide(l_retour) ALORS
RENVOYER gp_DateEmbauche
SINON
RENVOYER l_retour
FIN |
Partager