Home > Software engineering >  Getting error while creating Trigger in Oracle
Getting error while creating Trigger in Oracle

Time:10-05

I have created a trigger below but its giving me error as

3/1 PLS-00428: an INTO clause is expected in this SELECT statement 5/1 PL/SQL: SQL Statement ignored 6/28 PL/SQL: ORA-00984: column not allowed here Errors: check compiler log

Below is my code

create or replace TRIGGER "APP_WFM"."TRG_INS_NE_SF_SITE_INSTANCE" 
    BEFORE INSERT OR UPDATE ON NE_SITE_INSTANCE
    FOR EACH ROW
BEGIN

select rf_siteid, sap_id, site_name from SF_NE_DETAILS;

INSERT INTO NE_SITE_INSTANCE (rf_siteid, sap_id, sitename)
VALUES (rf_siteid, sap_id, site_name);

END;

What can I try to resolve this?

CodePudding user response:

Based on your previous question, you want to use the :NEW record to get the inserted values and then insert into the second table that you are copying into:

CREATE TRIGGER APP_WFM.TRG_INS_NE_SF_SITE_INSTANCE
  BEFORE INSERT OR UPDATE ON NE_SITE_INSTANCE -- Table being copied from
  FOR EACH ROW
BEGIN
  INSERT INTO SF_NE_DETAILS ( -- Table being copied to
    rf_siteid,
    sap_id,
    site_name
  ) VALUES (
    :NEW.rf_siteid,
    :NEW.sap_id,
    :NEW.site_name
  );
END;
/

db<>fiddle here

  • Related