What is wrong with below code, can some help me to resolve it?
CREATE OR REPLACE TRIGGER TEST_TRI
AFTER INSERT
ON TEST1
FOR EACH ROW WHEN (NEW.COL2 >= '01-MAY-16')
BEGIN
IF INSERTING
THEN
MERGE INTO TEST_HIST HIST
USING TEST1 T1
ON (T1.NEW.COL1=HIST.COL2)
WHEN MATCHED THEN
UPDATE SET
HIST.COL5=NEW.COL5
WHEN NOT MATCHED
THEN
INSERT INTO
VALUES (:NEW.COL1,:NEW.COL2,:NEW.COL3,:NEW.COL4,:NEW.COL5);
END IF;
END;
/
Error: Error(4,3):PL/SQL : Sql stmt ignored Error (12,14) : PL/SQL : ORA-00926: MISSING VALUES KEYWORD
Thanks for the info, i have changed code like below and getting new error.
CREATE OR REPLACE TRIGGER test_tri
after INSERT
ON test1
FOR EACH ROW WHEN (NEW.col5 >= '01-MAY-16')
DECLARE
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
IF INSERTING
THEN
MERGE INTO test_hist hist
USING test1 t1
ON (t1.PACKAGE_ID=hist.PACKAGE_ID)
WHEN MATCHED THEN
UPDATE SET
hist.col5=t1.col5
WHEN NOT MATCHED
THEN
INSERT (col1,col2, col3, col4, col5)
VALUES (:NEW.col1,:NEW.col2,:NEW.col3,:NEW.col4,:NEW.col5);
END IF;
COMMIT;
END;
/
While inserting record in test1 table am getting below error ORA-30926: unable to get a stable set of rows in the source table