문제

CREATE OR REPLACE TRIGGER CRIMEDATE
    BEFORE INSERT or UPDATE of DATE_CLOSED
    ON CRIME
    for each row
    declare :new.date_closed

BEGIN

   if (:new.date_closed < crime_date) then raise_application_error(-20002, 'Date Closed must be after crime date');
   end if;
END;

I am trying to create a trigger that will fire if the date entered for date_closed is before the actual crime date but i keep gettng the following error:

    Error at line 1: PLS-00103: Encountered the symbol "" when expecting one of the 
    following: begin function pragma procedure subtype type <an identifier> <a double-quoted 
    -identifier> current cursor delete exists prior The symbol "" was ignored. 0.06 seconds

I've been trying for ages to figure it out, can any one help? thanks

도움이 되었습니까?

해결책

Try this:

CREATE OR REPLACE TRIGGER CRIMEDATE
    BEFORE INSERT or UPDATE of DATE_CLOSED
    ON CRIME
    FOR EACH ROW
BEGIN
   IF (:new.date_closed < :new.crime_date)  THEN
      raise_application_error(-20002, 'Date Closed must be after crime date');
   END IF;
END;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top