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.
Is this really a computed column, i.e. declared with COMPUTE(...)?
AFAIK, those should only be used with constant values and deterministic functions.
I would generally recommend to omit (or "delay") the computation completely by using a view instead of a computed column, say by something like
create view V_ParentWithSum as select parent.*, sum(child.colA) as SummedChild from parent key join child
If this does not need your requirements, I would use a trigger on child to update the parent. But then I would not declare the column as a computed column, as changing computed columns via triggers of other tables seems dangerous (and looks suspicious as well IMHO).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 12 | |
| 9 | |
| 7 | |
| 5 | |
| 4 | |
| 2 | |
| 2 | |
| 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.