CREATE FUNCTION trigOutlaw_4() RETURNStrigger
AS $$ DECLARE nbol int; BEGIN SELECT COUNT(*) INTO nbol FROM outlaw; RAISE NOTICE '% outlaws dans la table', nbol;NEW.ol_nom := 'Stilton';
RETURN NEW;
END $$ LANGUAGE plpgsql; CREATE TRIGGER trigOLBEFORE
INSERT ON outlawFOR EACH ROW
EXECUTE PROCEDURE trigOutlaw_4(); 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;
DELETE 0 fichier.sql:118: NOTICE: 0 outlaws dans la table fichier.sql:118: NOTICE: 1 outlaws dans la table fichier.sql:118: NOTICE: 2 outlaws dans la table fichier.sql:118: NOTICE: 3 outlaws dans la table INSERT 0 4 ol_id | ol_nom | ol_prenom | ol_naissance -------+---------+-----------+--------------17
| Stilton | Joe | 1865-04-0118
| Stilton | Jack | 1866-07-0419
| Stilton | William | 1867-11-2820
| Stilton | Averell | 1868-12-25 (4 rows)