Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trigger -> Wrong Results
Message
From
22/02/2004 16:08:05
Larry Long
ProgRes (Programming Resources)
Georgia, United States
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00877269
Message ID:
00879768
Views:
14
This message has been marked as a message which has helped to the initial question of the thread.
How about something like this...
1) Save the old value for Total_B into Total_B_Old
2) Save the new value for Total_B into Total_B_New
3) Do your sum
4) Set m.Total_A[1] = m.Total_A[1]-Total_B_Old+Total_B_New
5) Do your update


Normally you should not use triggers except for short>Hello.
>
>Let me try to explain my problem!
>
>TableA -> Id_A, Total_A
>TableB -> Id_A, Id_B, Total_B
>
>Both tables have triggers for insert, update and delete. My problem is in Table_B, that calls the function TableB_Trigger for Insert, Update and Delete.
>
>
>Function TableB_Trigger
>m.Id_A = TableB.Id_A
>m.Id_B = TableB.Id_B
>Select Sum(Total_B) From TableB Where Id_B = m.Id_B Into Array Total_A
>m.Total_A = Iif(Type("Total_A[1]")#"N",0,Total_A[1])
>Update Table_A Where Id_A = m.Id_A Set Total_A = m.Total_A
>
>
>Ok. The code works fine, but the results doesn't!
>
>If I open the Table_B (Use) and change the value of field Total_B (from 10 to 50), my trigger is fired and the code returns Total_A = 10 ... and it should be 50, ok?
>
>I think the Select Sum(Total_B) is taking the "old value" in the table... because VFP doesn't know if that transaction will complete or won't.
>
>I just want to calculate this total and put it in other table...
>
>Do you have some "magic potion" to fix it?
>
>TIA! TIA! TIA!
L.A.Long
ProgRes
lalong1@charter.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform