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.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Question
Mary99
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
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.