Re: Trigger question..please help.

From: Shakespeare <>
Date: Sat, 28 Mar 2009 01:43:40 +0100
Message-ID: <49cd72bc$0$186$>

pereges schreef:
> On Mar 27, 4:27 pm, Shakespeare <> wrote:

>> I don't think you need a procedure for this. You don't need to query the
>> emp table. Just do the bookkeeping in the trigger:
>> If an employee is inserted, add 1 to total employees, and add the salary
>> to the total;
>> If an employee is deleted, substract the salary and substract 1 from total;
>> if an employee gets updated, substract the old salary and add the new
>> salary.
>> Of course, this will fail when the table is truncated.....
> Yes I can do that but the dept_stat1 table also has an attribute dname
> (department name) and that must be updated too. Also, the
> total_employees and total_salary is for a particular department. How
> would the trigger know which department has been updated.

By the dno column in employees I would think.... it may be a bit more complex than I stated, but it can still be done this way. I just gave some direction.

Shakespeare Received on Fri Mar 27 2009 - 19:43:40 CDT

Original text of this message