on ‎2011 Sep 29 11:22 AM
I have 2 tables (parent and child). On parent, I have a computed column that is sum of ColA in Child table by parent id.
My problem is: how to refresh computed column value when I have a insert/delete on child table? I don't need to process updates since my program doesn't allows it.
Request clarification before answering.
Use after insert, update and delete triggers like:
create TRIGGER "AInsert" after insert on child referencing new as new_row
create TRIGGER "AUpdate" after update of ColA, order 1 on child referencing new as new_row
create TRIGGER "ADelete" after delete order 1 on child referencing old as old_row
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the help, in section SQL Anywhere Server - SQL Usage » Database objects » Computed columns » Recalculating computed columns, it states:
Computed columns are not recalculated under the following circumstances:
The computed column is queried.
The computed column depends on the values of other rows (using a subquery or user-defined function), and these rows are changed.
| User | Count |
|---|---|
| 12 | |
| 9 | |
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.