0

I want to create a trigger on a table before update:

create or replace trigger backup_t
before update on e_naqi
for each row
begin
insert into e_naqi_bkp values(:old.employee_id,:old.first_name,:old.department_id,:old.manager_id,sysdate);
end;

but when I tried to execute it, error occurs which states as

2/108   PL/SQL: ORA-00933: SQL command not properly ended
2/1     PL/SQL: SQL Statement ignored
3/5     PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
          ( begin case declare end exception exit for goto if loop mod
          null pragma raise return select update while with
          <an identifier> <a double-quoted delimited-identifier>
          <a bind variable> << continue close current delete fetch lock
          insert open rollback savepoint set sql execute commit forall
          merge pipe purge

I tried to compile the trigger and it should be created successfully but error occurred.

Alex Poole
  • 183,384
  • 11
  • 179
  • 318
  • Where are you running this? The PLS-00103 is because you haven't terminated the PL/SQL block (which is what the trigger body is) with a `/` on a line on its own. If you add that do the other errors go away too? – Alex Poole Nov 09 '22 at 18:25
  • I am rnning it on Toad and using Oracle HR Schema. you want me to try the code like below, create or replace trigger backup_t before update on e_naqi for each row begin insert into e_naqi_bkp values(:old.employee_id,:old.first_name,:old.department_id,:old.manager_id,sysdate); end; / – Naqi Hassan Nov 09 '22 at 18:32
  • Probably, but hard to tell as you can't format code in comments... [like this](https://dbfiddle.uk/xdhNcmit). – Alex Poole Nov 09 '22 at 18:36
  • Or [this](https://stackoverflow.com/a/59661671/266304) may be relevant. How are you executing the code? – Alex Poole Nov 09 '22 at 18:40
  • Yes, My requirement is exactly the same as you sent but unfortunately I am unable to compile trigger although I have tried using / also. – Naqi Hassan Nov 09 '22 at 18:46
  • It works for me , I ran it using ''Run as a Script'' option. GOD Bless You brother – Naqi Hassan Nov 09 '22 at 18:52

0 Answers0