Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Child table triggers
Message
De
08/10/1996 00:06:18
 
 
À
07/10/1996 20:52:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00009562
Message ID:
00009572
Vues:
32
>Given: > parent table w/ id & status fields. > child table w/ parents id & its own status field. > status is some value between 1 and 9. > >If I change the status of one of the children I want to update the parent with the least value of all of its children. > >So with both childrens' status = 3 parents status will be 3, but if child #1 status changes to 1 i want parents' status to = 1. > >update procedure on the child table: > >PROCEDURE _child_Update >LOCAL lcItem, lcStatus, lcOldError, llError >lcItem=child.itemid >lcStatus=child.status >lcOldError=ON("ERROR") >ON ERROR llError=.T. >llError=.F. >SELECT child && is this legal in trigger? >SCAN FOR child.itemid = lcItem > IF status < lcStatus > lcStatus = status > ENDIF >ENDSCAN >BEGIN TRANSACTION >UPDATE parent ; > SET status=lcStatus; > WHERE parent.itemid=lcItem >ON ERROR &lcOldError >IF llError > ROLLBACK > RETURN .F. >ELSE > END TRANSACTION >ENDIF >RETURN .T. > >All I'm getting back is that the trigger failed. >Looks like the scan is only finding one record. >Though I know there are multiple children. > >Thanks, kim > > Maybe you could use the SET FILTER TO command. Eg. SET FILTER TO child.itemid=lcItem GO TOP DO WHILE !EOF() IF status < lcStatus lcStatus = status ENDIF ENDDO This may work? -Alvin
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform