Created
May 29, 2012 10:09
-
-
Save ObKo/2823857 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
CREATE OR REPLACE TRIGGER check_artist | |
BEFORE INSERT ON genre_artist | |
FOR EACH ROW | |
DECLARE | |
artist_id INTEGER; | |
new_id INTEGER; | |
BEGIN | |
SELECT id INTO artist_id FROM jobs WHERE name = 'Artist'; | |
SELECT job INTO new_id FROM persons WHERE id = :new.artist; | |
IF (artist_id != new_id) THEN | |
RAISE_APPLICATION_ERROR(-20773, 'Not an artist!'); | |
END IF; | |
END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment