Skip to content

Instantly share code, notes, and snippets.

@bendem
Created December 19, 2013 19:45
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/8045031 to your computer and use it in GitHub Desktop.
Save bendem/8045031 to your computer and use it in GitHub Desktop.
-- ----------------------------------------------
-- @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