Unexpected loop behaviour
Hi again all,
I once again am struggling writing a function that does what I want it to. I am aware the ultimate root of my problem is my inadequate knowledge of postgres/SQL in general and I promise I am working on it, but in the meantime any help with this particular issue would be appreciated.
The following function + trigger definition does mostly what I want it to:
It inserts the expected number of new rows in the target table, and populates the parent_instance, year, and effective_age columns properly, but not the balance. The balance shows up as 0 for every row except the last one generated by the function, which appears to calculate correctly. What the heck? Can anyone ELI5 what's happening? Thanks!
I once again am struggling writing a function that does what I want it to. I am aware the ultimate root of my problem is my inadequate knowledge of postgres/SQL in general and I promise I am working on it, but in the meantime any help with this particular issue would be appreciated.
The following function + trigger definition does mostly what I want it to:
It inserts the expected number of new rows in the target table, and populates the parent_instance, year, and effective_age columns properly, but not the balance. The balance shows up as 0 for every row except the last one generated by the function, which appears to calculate correctly. What the heck? Can anyone ELI5 what's happening? Thanks!