Creating trigger which will insert into table from view

oracleplsql

I have view LIVE_MATCHES (home,away,comp_name) and
table MATCHES (priority ,sport,sub_list)

I need to create a trigger that inserts in TABLE from VIEW after the view is updated or inserted (doesn't matter) and to check that unique column (sub_list) in table Matches isn't already inserted. Only need to insert from view is comp_name, sport and priority are fixed variables.

 CREATE OR REPLACE TRIGGER LIVE_MATCHES_TO_MATCHES 
        instead of insert ON LIVE_MATCHES 
       for each row
              declare
       p_priority number:= 1;
       p_sport number:=0;
       begin
         insert into MATCHES (sub_list , priority , sport, created) 
         select :old.comp_name , p_priority, p_sport,sysdate
         from dual
          where not exists (      
         select 1 from MATCHES 
        where sub_list = :old.comp_name);
       end;

I edited trigger so it is compiled now without errors but it does not insert into table MATCHES.

What am I doing wrong in this trigger.

Best Answer

SQL*Developer

SQL*Developer has a bad habit of interpreting the :new and :old identifiers of a trigger as run-time BIND variables. Usually, a window will pop up asking for a value for the BIND variable new and/or old.

SQL*Developer asks for BIND value for "new"

Workaround

One workaround is to edit the TRIGGER directly by going trough Connections.

A simple "recompile" works. Editing the TRIGGER code