Created
December 19, 2013 19:46
-
-
Save bendem/8045040 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- ---------------------------------------------- | |
-- @Author: bendem | |
-- @Date: 2013-12-16 11:28:14 | |
-- @Last Modified by: bendem | |
-- @Last Modified time: 2013-12-16 12:01:35 | |
-- ---------------------------------------------- | |
CREATE OR REPLACE TRIGGER NageursCategorie | |
BEFORE INSERT OR UPDATE ON Nageurs | |
FOR EACH ROW | |
DECLARE | |
age NUMBER; | |
BEGIN | |
SELECT AnneeEnCours - :new.AnneeNaiss INTO age FROM InfoGenerales; | |
SELECT categorie INTO :new.categorie FROM categories, InfoGenerales WHERE | |
-- age BETWEEN AgeMin AND AgeMax? | |
age >= AgeMin | |
AND age < AgeMax; | |
EXCEPTION | |
WHEN OTHERS THEN | |
raise; | |
END; | |
/ | |
-- ----------------------------------------------------- | |
-- OU (FAUX, le déclencheurs va tourner en boucle...!) | |
-- Erreur de table mutante! | |
-- ----------------------------------------------------- | |
-- CREATE OR REPLACE TRIGGER NageursCategorie | |
-- AFTER INSERT OR UPDATE ON Nageurs | |
-- FOR EACH ROW | |
-- BEGIN | |
-- UPDATE Nageurs SET categorie = ( | |
-- SELECT categorie FROM categories, InfoGenerales | |
-- WHERE | |
-- AnneeEnCours - AnneeNaiss >= AgeMin | |
-- AND AnneeEnCours - AnneeNaiss < AgeMax | |
-- ) | |
-- WHERE nrligue = :new.nrligue; | |
-- EXCEPTION | |
-- WHEN OTHERS THEN | |
-- raise; | |
-- END; | |
-- / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment