CREATE FUNCTION trigOutlaw_1() RETURNStrigger
AS $$ DECLARE nbol int; BEGIN SELECT COUNT(*) INTO nbol FROM outlaw; RAISE NOTICE '% outlaws dans la table', nbol;RETURN NEW
; END $$ LANGUAGE plpgsql; CREATE TRIGGER trigOLBEFORE
INSERT ON outlawFOR EACH ROW
EXECUTE PROCEDURE trigOutlaw_1(); DELETE FROM outlaw; INSERT INTO outlaw(ol_nom,ol_prenom,ol_naissance) SELECT etud_nom, etud_prenom, etud_naissance FROM etudiant WHERE etud_nom = 'Dalton'; SELECT * FROM outlaw;
CREATE FUNCTION
CREATE TRIGGER
DELETE 4
psql:fichier.sql:27: NOTICE: 0 outlaws dans la table
psql:fichier.sql:27: NOTICE: 1 outlaws dans la table
psql:fichier.sql:27: NOTICE: 2 outlaws dans la table
psql:fichier.sql:27: NOTICE: 3 outlaws dans la table
INSERT 0 4
ol_id | ol_nom | ol_prenom | ol_naissance
-------+--------+-----------+--------------
5 | Dalton | Joe | 1865-04-01
6 | Dalton | Jack | 1866-07-04
7 | Dalton | William | 1867-11-28
8 | Dalton | Averell | 1868-12-25
(4 rows)