Created
December 19, 2013 19:45
-
-
Save bendem/8045031 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 08:23:17 | |
-- @Last Modified by: bendem | |
-- @Last Modified time: 2013-12-16 11:27:06 | |
-- ---------------------------------------------- | |
CREATE OR REPLACE TRIGGER ResulatsDecision | |
BEFORE INSERT ON Resultats | |
FOR EACH ROW | |
DECLARE | |
ExcResulatsDecision EXCEPTION; | |
BEGIN | |
IF (:new.Decision IS NOT NULL) THEN | |
IF (:new.TempsReel IS NOT NULL OR :new.Place IS NOT NULL) | |
THEN | |
raise ExcResulatsDecision; | |
END IF; | |
ELSE | |
IF (:new.TempsReel IS NULL OR :new.Place IS NULL) | |
THEN | |
raise ExcResulatsDecision; | |
END IF; | |
END IF; | |
EXCEPTION | |
WHEN ExcResulatsDecision THEN | |
RAISE_APPLICATION_ERROR(-20001, 'Cest mon exception'); | |
WHEN OTHERS THEN | |
raise; | |
END; | |
/ | |
INSERT INTO RESULTATS (Nrligue,Competition,Annee,Jour,Course,TempsReference,TempsReel,Place,Decision) | |
VALUES('999/00', 1, 2002, 2, 3, TO_DSINTERVAL('+00 00:03:23'), TO_DSINTERVAL('+00 00:03:05'), 1, 'DQ'); | |
INSERT INTO RESULTATS (Nrligue,Competition,Annee,Jour,Course) | |
VALUES('999/00', 1, 2002, 2, 3); | |
ROLLBACK; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment