I am using oracle SQL and have two tables, lets just call them TriggerTest1 and TriggerTest2 , with the fields ID, NAME, FROM, UNTIL, where FROM and UNTIL are dates.
I have written this trigger:
CREATE OR REPLACE TRIGGER a
BEFORE INSERT ON TRIGGERTEST1
DECLARE
oldentry TRIGGERTEST1%rowtype;
BEGIN
IF EXISTS(SELECT * INTO oldentry FROM TRIGGERTEST1 a WHERE a.ID = New.ID) THEN
INSERT INTO TRIGGERTEST2
VALUES(oldEntry.NAME, oldEntry.FROM, New.FROM, oldEntry.ID);
DELETE FROM TRIGGERTEST1 b WHERE b.ID = new.ID;
END IF;
END;
Basically this should just move an entry in Triggertest1 to Triggertest2 when I try to insert an already existing ID into Triggertest1.
I get this error:
Error(3,21): PLS-00103: Encountered the symbol "INTO" when expecting one of the following: from
According to this my SELECT INTO statement should be correct, does anyone know what the problem is?