Domanda

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

È stato utile?

Soluzione

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;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top