I have a table with 3 columns (value1, value2 and total).
When you update the value1 or value2 column, I need the sum of the two to be updated in the total column.
I know there’s a way to trigger it, but since it does it after the update and updates a column, won’t it stay in a loop?
2
Answers
you’ll need to check if the update affects to value1 or value2 to trigger it:
You may use generated column:
fiddle
Remember – you cannot set (in INSERT) or update (in UPDATE, INSERT ODKU, MERGE, etc.) the value in generated column, you can only retrieve its value.