CREATE TABLE tIntervenantSav (
pknom varchar2(20) PRIMARY KEY,
prenom varchar2(20) NOT NULL
);
CREATE OR REPLACE TRIGGER trIntervenant
BEFORE DELETE OR INSERT ON tIntervenant
FOR EACH ROW
BEGIN
IF DELETING THEN
INSERT INTO tIntervenantSav VALUES (:old.pknom, :old.prenom);
ELSIF INSERTING THEN
DELETE FROM tIntervenantSav WHERE pknom = :new.pknom;
END IF;
END;
/
DELETE FROM tCours;
DELETE FROM tIntervenant;
SELECT * FROM tIntervenantSav;
PKNOM PRENOM
-------------------- --------------------
CROZAT Stéphane
JOUGLET Antoine
VINCENT Antoine
INSERT INTO tIntervenant (pknom, prenom, poste)
VALUES ('CROZAT', 'Stéphane', '4287');
SELECT * FROM tIntervenantSav;
PKNOM PRENOM
-------------------- --------------------
JOUGLET Antoine
VINCENT Antoine