Aaron Troeger
Aaron Troeger

Reputation: 165

Oracle Trigger changing a value

say you have a table that has {Name, value} Can you create a Trigger that if a new row is inserted with the name 'Bob', increase the value associated to Bob by 25%? If so, how?

Upvotes: 0

Views: 46

Answers (1)

Dhwani
Dhwani

Reputation: 7626

Try this:

CREATE OR REPLACE TRIGGER trigger_name
BEFORE INSERT ON TABLE_NAME
FOR EACH ROW BEGIN 
   IF :new.NAME = 'Bob' then
      :new.VALUE := :new.VALUE + (:new.VALUE*0.25) ;
  END IF; 
END; 
/

I'm not oracle expert but I tried. Hope u can have solution.

Upvotes: 1

Related Questions