Skip to content

Instantly share code, notes, and snippets.

@bendem
Created December 19, 2013 19:46
Show Gist options
  • Save bendem/8045032 to your computer and use it in GitHub Desktop.
Save bendem/8045032 to your computer and use it in GitHub Desktop.
-- ----------------------------------------------
-- @Author: bendem
-- @Date: 2013-12-16 08:24:05
-- @Last Modified by: bendem
-- @Last Modified time: 2013-12-16 13:37:09
-- ----------------------------------------------
CREATE OR REPLACE TRIGGER PlanningDistance
BEFORE INSERT OR UPDATE OF Distance, Jour ON Planning
FOR EACH ROW
WHEN (old.Competition = 1)
DECLARE
ExcPlanningDistance EXCEPTION;
BEGIN
IF (:new.Distance <= 200) THEN
IF (:new.Jour <> 1 OR :new.Jour <> 2) THEN
raise ExcPlanningDistance;
END IF;
ELSE IF (:new.Distance <= 1500) THEN
IF (:new.Jour <> 3) THEN
raise ExcPlanningDistance;
END IF;
END IF;
END IF;
EXCEPTION
WHEN ExcPlanningDistance THEN
RAISE_APPLICATION_ERROR(-20001, 'Erreur de trigger : 1');
WHEN OTHERS THEN
raise;
END;
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment