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),
Sample Example:
Expand|Select|Wrap|Line Numbers
- emp_name tot_days
- guru 18
2.leave_data
Expand|Select|Wrap|Line Numbers
- emp_name From_date to_date no_of_days remaining_days
- guru 02/05/2012 03/05/2012 2 16
Expand|Select|Wrap|Line Numbers
- emp_name tot_days
- guru 16
can someone help me to update these 2 tables through TRIGGER?
Thank you,
Regards,
gurujothi