Search the Community
Showing results for tags 'trigger loop update parent child'.
I'm looking for an example of successful trigger setup that effectively loops through and updates the child table when a parent table is updated. A use case is if loan terms are adjusted, the number of payments and the regularly scheduled payment might change. So for example if the parent table is a borrower table that has defined a loan amount, # of payments, and a scheduled amount and the child table contains entries for all of the scheduled payments, I want to set up a trigger on the parent table to adjust or update the records in the child table if anything in the parent table changes. So far my attempts only seem to update the data in each child record based on the last record of the loop. The table here shows the orignal data on insert of the parent child trigger. If I update the regular payment amount on the borrower table of mickey to 2000, I'm expecting the pmt amount on the child table pmt_amt to be updated as well as update the pmt_cum_amount but as you can see, it appears that it updates all of mickeys records with the data from the last loop. So even though the pmt_amt is correct the data is showing the value from the last iteration of the loop. Below is the trigger I'm using. Any help would be appreciated. Attached i