ORA-04082: NEW or OLD references not allowed in table level triggers

I am calling a stored procedure from a trigger. It shows the error: "ORA-04082: NEW or OLD references not allowed in table level triggers."

I am calling a stored procedure from a trigger. It shows the error: "ORA-04082: NEW or OLD references not allowed in table level triggers." The procedure is created with no error. But the trigger is not created. The trigger is:
CREATE OR REPLACE TRIGGER my_test_trigger
BEFORE INSERT ON my_table
DECLARE
   v_out   number ;
BEGIN
   my_procedure(:new.column1, :new.column2, v_out) ;
   :new.column3 := v_out ;
END;
There are two types of DML triggers: statement level and row level. The statement level trigger fires once per transaction, while the row level trigger fires for each record effected, per transactions. In order to use :new or :old, the trigger must be a row level trigger. The trigger you have created is a statement trigger. To change your trigger to a row level trigger, you must add the following line:
        FOR EACH ROW
Your trigger will then look like:
CREATE OR REPLACE TRIGGER my_test_trigger
BEFORE INSERT ON my_table
FOR EACH ROW
DECLARE
   v_out   number ;
BEGIN
   my_procedure(:new.column1, :new.column2, v_out) ;
   :new.column3 := v_out ;
END;

Dig Deeper on Oracle development languages

Data Management
Business Analytics
SearchSAP
TheServerSide.com
  • Why WebAssembly? Top 11 Wasm benefits

    Latency and lag time plague web applications that run JavaScript in the browser. Here are 11 reasons why WebAssembly has the ...

  • Why Java in 2023?

    Has there ever been a better time to be a Java programmer? From new Spring releases to active JUGs, the Java platform is ...

  • How developers can avoid remote work scams

    Software developers can find good remote programming jobs, but some job offers are too good to be true. Follow these tips to spot...

Data Center
Content Management
HRSoftware
Close