0 Replies - 2279 Views - Last Post: 23 February 2012 - 04:39 PM

#1 Matty919  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 83
  • Joined: 10-May 09

Trigger - stop exceeding budget

Posted 23 February 2012 - 04:39 PM

I'm trying to stop a field being updated if it would cause the budget assigned to that department to go over budget.

E.g. If a new cost is being added and being assigned to a dept but if that would cause the dept to go over budget I want it not to be allowed.

CREATE OR REPLACE TRIGGER trig_new_cost_limit
BEFORE INSERT OR UPDATE OF dept ON costtable
FOR EACH ROW
WHEN (OLD.dept = NEW.dept)
BEGIN

--If assigning this cost to dept will cause over budget STOP

EXCEPTION
END trig_new_cost_limit;
/
SHOW ERRORS;



Any advice would be great.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1