Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Data Integrity Question
Message
De
04/08/1998 07:12:13
 
 
À
03/08/1998 21:02:34
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00123680
Message ID:
00123735
Vues:
18
Bill,

I have done similar triggers. If you only allow updates from the child,
do not do a SELECT on your child each time. Get your totals in
sync one time then in your child trigger just update the parent
value for the current child transaction.

Do set-up and seeks then
REPLACE TblParent.FldTotal WITH TblParent.FldTotal + TblChild.TranAmt
Do clean-up
-myron kirby-
========================================
>I'm trying to set up some data validation rules to keep totals in a separate table. I have devised something that works great when I'm browsing the table, but fails when I run a form.
>
>I have fields "parent.Total" and "child.Detail". (parent.Total is the sum of all the child.Detail(s).
>(I'm leaving out all the detail, just showing the "meat")
>
>In my row rule for child.dbf I have:
>private plChildValid
>plChildValid = .t. && to prevent triggering parent valid
>select ;
> sum(detail) ;
> for child.ForeignKey = parent.PrimaryKey ;
> into array laTotal
>&& Current value hasn't been stored yet.
>laTotal(1) = laTotal(1) - OldVal(child.Detail) + child.Detail
>select parent
>= seek(child.ForeignKey)
>replace Total with laTotal(1)
>select child
>return
>
>In the row rule for parent.dbf I have:
>&& skip if updating from the child table
>if type('plChildValid')='U' or empty(plChildValid)
> if parent.Total<>oldval(parent.Total)
> = messagebox( 'Edit Child.dbf to change Detail' )
> replace parent.Total with oldval(parent.Total)
> endif
>endif
>return
>
>This works just fine when I browse the table, but during the running of a form with buffering set on the views and tables, it doesn't work. I'm pretty sure that I've narrowed it down to the fact that buffering is set on in parent.dbf (which is off during browsing) so the parent row rule is not triggered until the table is closed (it's tableupdate() has already occured prior to the child's tableupdate()) and at that time type('plChildValid')='U'.
>
>I'm not sure I like the idea of putting a tableupdate(parent) in a valid routine for child. Any other ideas?
>
>TIA
----------------------------------
-myron kirby (mkirby2000@gmail.com)-
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform