Oracle Trigger errors

oracletrigger

I have a tables ENV_CONFIG and ENV_CONFIG_HIST where the latter table should get a new record on any insertion to the former. The trigger seems pretty straight forward but I'm getting compilation errors:

  • line 5 : SQL Statement ignored (Insert …)
  • line 13 : Column not allowed here (,new.PARAM_VALUE)

What am I missing?

create or replace TRIGGER TRG_ENV_CONFIG_INSERT
  AFTER INSERT
  ON ENV_CONFIG
  FOR EACH ROW 
BEGIN
  INSERT INTO ENV_CONFIG_HIST (
    PARAM_NAME
    ,PARAM_DESCR
    ,PARAM_VALUE
  ) VALUES (
    new.PARAM_NAME
   ,new.PARAM_DESCR
   ,new.PARAM_VALUE
 );
END;

Best Answer

you just need add Colon character (:) before new keyword same as below query:

create or replace TRIGGER TRG_ENV_CONFIG_INSERT
AFTER INSERT
  ON ENV_CONFIG
  FOR EACH ROW 
BEGIN
  INSERT INTO ENV_CONFIG_HIST (
    PARAM_NAME
    ,PARAM_DESCR
    ,PARAM_VALUE
  ) VALUES (
    :new.PARAM_NAME
   ,:new.PARAM_DESCR
   ,:new.PARAM_VALUE
 );
END;