Jump to content
  • 0

Looking for example of trigger loop that performs update on child table when parent is updated


Mary99

Question

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. 

 

 

image.png.8a6bf1533646e3383f38c75121996422.png

The table here shows the orignal data on insert of the parent child trigger. 

image.png.a9d45adc65bf4707ffc13db9cd19b056.png

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.

image.png.2c3d7313aea1e27021398a5c77392766.png

 

Below is the trigger I'm using.  Any help would be appreciated.   

image.png.33036b2fd7e73c134d5d428db9b5a21c.png

 

Attached i

image.png

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.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...