0

I want to treat a delete statement as an update but it throws this error, and I don't know what it means.

create or replace trigger Miembros_V_IOD
   instead of delete on Miembros_V 
   for each row
Begin
   update Miembros set (end_date = sysdate)
   where Miembros.nick = :old.nick
   and Miembros.club = :old.club;
end;

LINE/COL ERROR
-------- ----------------------------------------------------------
2/4      PL/SQL: SQL Statement ignored
2/34     PL/SQL: ORA-00907: missing right parenthesis
3
  • 2
    Try removing the parenthesis around end_date = SYSDATE. Commented Apr 6, 2020 at 16:30
  • @Del it does not work Commented Apr 6, 2020 at 16:39
  • @Del at first it didn't work but it was because I had put the name of a table wrong, then it worked. Thanks. Commented Apr 6, 2020 at 16:45

1 Answer 1

2

The error is pointing to the = sign. You're getting a PL/SQL error - albeit one caused by the inner SQL - and for a trigger the line numbers in PL/SQL errors start from the DECLARE (if you have one) or BEGIN, not from the start of the overall CREATE statement. So the 2/34 refers to character 34 of the second line of the PL/SQL part, which is:

   update Miembros set (end_date = sysdate)

... which is the =.

You shouldn't have the parenthesis around (end_date = sysdate):

create or replace trigger Miembros_V_IOD
instead of delete on Miembros_V 
for each row
begin
    update Miembros set end_date = sysdate
    where Miembros.nick = :old.nick
    and Miembros.club = :old.club;
end;
/

View MIEMBROS_V created.

db<>fiddle

The syntax diagram in the documentation shows that parentheses can go around a list of columns on the left-had side of the equals sign, or around a subquery on the right; but not around the whole set clause. Because you have set (end_date it's expecting that to either have a comma or closing parenthesis next, i.e. set (end_date) = ... - hence the ORA-00907 being thrown when it didn't see that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.