1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| ---je cree une vue pour visualiser update
CREATE OR REPLACE VIEW VW_Service AS
Select SerNo,NomS,Lieu,NbEmploye
From SERVICE;
---je cree un trigger pour compter nombre de employe à l'aide SerNo dans la table employe.
CREATE OR REPLACE TRIGGER VW_Service
INSTEAD OF UPDATE -- à la place de l'insertion
ON VW_Service -- sur la vue VW_Service
FOR EACH ROW -- pour chaque ligne
DECLARE
NB_Employe INTEGER;
BEGIN
SELECT COUNT(*) INTO NB_Employe
FROM Employe e
WHERE e.SerNo=:NEW.SerNo;
UPDATE SERVICE
set NbEmployes=NB_Employe;
End ;
/ |
Partager