1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
CREATE or replace TRIGGER date_retour_trigger
BEFORE INSERT ON emprunte
FOR EACH ROW
DECLARE
CURSOR curseur IS
select categorie from emprunte em, exemplaires ex, documents d where em.id_exemplaire=ex.id_exemplaire and ex.reference_doc=d.reference_doc and em.id_exemplaire=:new.id_exemplaire;
id curseur%ROWTYPE;
BEGIN
OPEN curseur;
FETCH curseur INTO id;
WHILE(curseur%FOUND) LOOP
if (id.categorie='livres') then
:new.date_retour:=ADD_DAY(:new.date_emprunt, 8 );
dbms_output.put_line('la date '|| :new.date_retour);
end if;
FETCH curseur INTO id;
END LOOP;
CLOSE curseur;
end date_retour_trigger; |
Partager