Parent/Child Totaling

I have 2 browses in a window in a Parent/Child relationship. I can do totaling in the Child browse, but would like that total to be placed in a field in the Parent browse.

I am thinking that I could just PUT the totals in the Parent record manually, but am wondering if there is a template (CW 8 legacy) solution to this?

ty

If you’re dealing with ISAM files, such as TPS, the easiest way is via an ALIAS table in the dictionary. Write a GetTotal(LONG pYourSysID,*DECIMAL pOutTotal) procedure or something like that, using the alias so that it doesn’t mess with your child browse buffers.

No template that I know of. Also, the normal “real” database approach would be just to have a view something like:

select par:id,par.<other columns>,c.total
from parent par
join (select parent_id,sum(c.value) total
from child 
group by parent_id) c on c.parent_id = par.parent_id

i.e. the total is always calculated on the fly, not stored in the parent record. Easy and quick in a database, slower if you are dealing with ISAM files.