Trigger for Update [message #427430] |
Thu, 22 October 2009 10:33  |
namb
Messages: 35 Registered: September 2009
|
Member |
|
|
Dear All,
I have the following issue.
I want to create a statement level trigger for updating the data from one table that is the child table with the following fields
table name emp_att_child
Emp_code
Time_in
Time_out
Total_hrs
time in and time out are when the emp enters and leave the organization. Total hours calcaute the total working hours.
the parent table emp_att_parent also contains all these fields
This child table contains the records with modified data which has to be updated in the parent table using a update trigger defined at a statement level so that update trigger is called for each row automatically. Can someone please help how to define the trigger at the statement level. If possible please provide examples or the code.
Thanks in advance
|
|
|
|
Re: Trigger for Update [message #427439 is a reply to message #427430] |
Thu, 22 October 2009 10:56   |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
namb wrote on Thu, 22 October 2009 16:33Dear All,
I have the following issue.
I want to create a statement level trigger for updating the data from one table that is the child table with the following fields
table name emp_att_child
Emp_code
Time_in
Time_out
Total_hrs
time in and time out are when the emp enters and leave the organization. Total hours calcaute the total working hours.
the parent table emp_att_parent also contains all these fields
This child table contains the records with modified data which has to be updated in the parent table
That's a design decision you're almost certainly going to regret. It's far simpler to not store calculated fields and just calculate them when you need to display them.
Doing it this way always leads to performance issues (due to locking problems) and almost always bugs.
namb wrote on Thu, 22 October 2009 16:33This child table contains the records with modified data which has to be updated in the parent table using a update trigger defined at a statement level so that update trigger is called for each row automatically. Can someone please help how to define the trigger at the statement level. If possible please provide examples or the code.
Think you need to need to read up on triggers as that doesn't make sense. Statement level triggers are not called for each row - row level triggers are. Statement level triggers can't see which rows have been updated either.
|
|
|
|