SOURCE
create or replace TRIGGER t_etudiants_absences_2
BEFORE INSERT ON etudiants_absences
FOR EACH ROW
DECLARE
compte number;
BEGIN
SELECT COUNT(*)
INTO compte
FROM absences_justifiees aj
WHERE aj.f_groupe = :new.pf_groupe
AND (SELECT e.jour FROM edt e WHERE e.p_id = :new.pf_edt)+1 BETWEEN to_char(aj.date_debut, 'D') AND to_char(aj.date_fin, 'D')
AND (SELECT e.semaine FROM edt e WHERE e.p_id = :new.pf_edt) BETWEEN to_char(aj.date_debut, 'WW') AND to_char(aj.date_fin, 'WW');
IF (compte != 0)
THEN
	:new.justification := 'aj';
END IF;
END;