Create or replace function isCreneauLibre(ID_SESSION NUMBER,
ID_JURY NUMBER,
DATE_JURY varchar2,
P2_DEBUT varchar2,
P2_FIN varchar2) return number
IS
/* Variables */
isLibre NUMBER(1);
nombreCreneau NUMBER(10);
hDebut VARCHAR2(5);
hFin VARCHAR2(5);
/* Curseur */
CURSOR curCreneau IS
Select CRENEAU_HDEBUT as hDebut,
CRENEAU_HFIN as hFin
From ENT_CRENEAUH
Where CRENEAU_IDSESSION=ID_SESSION
and CRENEAU_IDJURY=ID_JURY
and to_char(CRENEAU_DATE,'dd fmmonth yyyy')=lower(DATE_JURY)
and (CRENEAU_HDEBUT > P2_DEBUT AND (CRENEAU_HDEBUT < P2_FIN OR CRENEAU_HFIN < P2_FIN)) OR
(P2_DEBUT > CRENEAU_HDEBUT AND (P2_DEBUT < CRENEAU_HFIN OR P2_FIN < CRENEAU_HFIN)) OR
(CRENEAU_HDEBUT = P2_DEBUT AND (CRENEAU_HFIN IS NOT NULL AND P2_FIN IS NOT NULL));
/* Corps */
Begin
OPEN curCreneau;
LOOP
FETCH curCreneau INTO hDebut,hFin;
EXIT WHEN curCreneau%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(hDebut||'-'||hFin);
END LOOP;
CLOSE curCreneau;
RETURN 1;
End;
/
Partager