Oracle apex, PL_Sql. This is my trigger:
CREATE OR REPLACE TRIGGER NoMoreThanOneHorse
BEFORE INSERT OR UPDATE OF Jockey_ID
ON Horses
FOR EACH ROW
DECLARE
NumOfHorsesForJockey NUMBER(4);
BEGIN
SELECT COUNT(*) INTO NumOfHorsesForJockey FROM Horses
WHERE Jockey_ID = :NEW.Jockey_ID AND Horse_ID <> :NEW.Horse_ID;
IF NumOfHorsesForJockey > 0
THEN RAISE_APPLICATION_ERROR (-20445, 'Нельзя закрепить за лошадью уже занятого жокея!');
END IF;
END NoMoreThanOneHorse;
but every time i try to create it i have this error :ORA-24344: success with compilation error ORA-06512. I suppose it's because bad syntax