1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| CREATE TRIGGER ajoutCommande
AFTER INSERT
ON Ligne_Coms
FOR EACH ROW
BEGIN
IF (verifier_qtecom(Qte_Com,Num_Pro)) then
BEGIN
UPDATE Commandes
SET nbre_lc= nbre_lc+1 where Ligne_Coms.Num_Com=Commandes.Num_Com ;
UPDATE Commandes
SET Mtot_Com = Mtot_Com + :new.Qte_Com * Prix_U WHERE Num_Com = :new.Num_Com;
UPDATE Produits
SET qtestock = qtestock - :new.Qte_Com WHERE Num_Pro = :new.Num_Pro;
COMMIT;
END;
ELSE
BEGIN
DBMS_OUTPUT.PUT_LINE('Ajout annulé') ;
ROLLBACK;
END;
end if;
END; |