Compte Gmail
Compte Gmail

Reputation: 137

Trigger not working in PLSQL while retrieving new value

I'm trying to create a trigger that multiplies that salaries of employees who're paid more than 1000$ by 2 but it displaying me this error below, here's the code. I'm still discovering this "new/old" concept. But I don't see why my trigger isn't working. Does anybody know why?

CREATE OR REPLACE TRIGGER MAJ
AFTER UPDATE on EMPLOYEES
FOR EACH ROW
begin
IF (:new.salary <1000) THEN
:new.salary:= :new.salary*2;
end;
/

enter image description here

Upvotes: 0

Views: 39

Answers (1)

Ankit Bajpai
Ankit Bajpai

Reputation: 13509

You are forgetting an END IF in your code -

CREATE OR REPLACE TRIGGER MAJ
AFTER UPDATE on EMPLOYEES
FOR EACH ROW
BEGIN
     IF (:new.salary <1000) THEN
        :new.salary := :new.salary*2;
     END IF;
END;
/

Upvotes: 1

Related Questions