Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Oracle SQL Trigger not getting created

I have a table passenger as shown below

Column       Null?        Type
------------------------------------
NAME          -          VARCHAR2(20)
ID          NOT NULL     NUMBER
ADDRESS       -          VARCHAR2(20)
CHARGES       -          NUMBER

I am learning triggers and I want to create a trigger that updates charges as charges + 100 before a new insert is done. Here is the trigger I created.

create or replace trigger flight
before insert on passenger
for each row
set new.charges = new.charges + 100;
/

However, I am getting the error ORA-04079: invalid trigger specification. I have tried replacing new with :new, adding begin & end blocks, but none of them seem to work.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Invalid syntax.

create or replace trigger flight
  before insert on passenger
  for each row
begin
  :new.charges := :new.charges + 100;
end;
/
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading