Updating 2 Tables through Trigger [message #553098] |
Tue, 01 May 2012 22:45 |
|
gurujothi
Messages: 80 Registered: January 2012 Location: Banglore
|
Member |
|
|
Dear all,
I have 2 tables,
1.lv_data,
it has the following fields,
emp_name tot_days
guru 18
2.leave_data
it has the following fields,
emp_name From_date to_date no_of_days remaining_days
guru 02/05/2012 03/05/2012 2
In second table if the data is inserted ,
the no_of_days will be automatically calculated (from to_date - From_date)+1,
Here I need to write the trigger to update the remaining_days column,
In first table for all emp_name tot_days is 18 days,
so in second table whenever the record is inserted,
the remaining_days should be calculated like this,
remaining_days := tot_days - no_of_days and this(calculated) value should be updated in tot_days column in first table(lv_data),
Example:
emp_name tot_days
guru 18
2.leave_data
emp_name From_date to_date no_of_days remaining_days
guru 02/05/2012 03/05/2012 2 16
Now the first table should be updated like,
emp_name tot_days
guru 16
So I need to update 2 tables,
can someone help me to update these 2 tables through TRIGGER?
Thank you,
Regards,
gurujothi
|
|
|
Re: Updating 2 Tables through Trigger [message #553127 is a reply to message #553098] |
Wed, 02 May 2012 01:29 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Less than a week ago I told you this:
LF
Just a remark of another kind: please, before posting your next message, spend not more than 10 seconds in viewing this page. Knowledge you gather there will significantly improve your future messages.
Obviously, you didn't want to spend those 10 seconds and the result is a message you posted, right above this one.
Guess what? It is difficult to read. Column headings and values aren't aligned. I think I will not put any effort in trying to figure it out. Heck, if you don't want to make it easier for us, why would we bother?
|
|
|