Skip to content

Instantly share code, notes, and snippets.

@bendem
Created December 19, 2013 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bendem/8045040 to your computer and use it in GitHub Desktop.
Save bendem/8045040 to your computer and use it in GitHub Desktop.
-- ----------------------------------------------
-- @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